Documentation
¶
Overview ¶
Package performance implements the portable, payload-free client performance-evidence service described by docs/composable-presentation.md.
The package is deliberately independent of any view toolkit. A client runtime mounts a collector with exact immutable identities and injects a scoped Recorder into selected plugins. Recording callers can supply only closed enums and integers; they cannot attach labels, event payloads, URLs, session identifiers, or diagnostics.
Index ¶
- Constants
- Variables
- func CollectorDescriptor() plugin.Descriptor
- func CollectorDescriptorIdentity() (plugin.Identity, error)
- func ConfigurationContract() plugin.Contract
- func DurationBucketUpperBoundsNS() []uint64
- func MarshalSnapshot(snapshot Snapshot) ([]byte, error)
- func ServiceContract() plugin.Contract
- type ClientPlatform
- type ClockDomain
- type ClockIdentity
- type ClockProvenance
- type Configuration
- type CounterAggregate
- type Coverage
- type CoverageReason
- type Dimension
- type DimensionName
- type DimensionValue
- type DropCounter
- type DropReason
- type DurationHistogram
- type EvidenceClass
- type GaugeAggregate
- type Limits
- type Metric
- type MetricFamily
- type MountScope
- type ObservabilityMode
- type Provider
- type Recorder
- func (recorder Recorder) AddCounter(metric Metric, delta uint64, dimensions ...Dimension) error
- func (recorder Recorder) BeginDuration(metric Metric, startNS uint64, dimensions ...Dimension) (Span, error)
- func (recorder Recorder) CompleteDuration(span Span, endNS uint64) error
- func (recorder Recorder) RecordDuration(metric Metric, nanoseconds uint64, dimensions ...Dimension) error
- func (recorder Recorder) SetCoverage(metric Metric, coverage Coverage, reason CoverageReason, ...) error
- func (recorder Recorder) SetGauge(metric Metric, value int64, dimensions ...Dimension) error
- type RejectedError
- type RejectionCounter
- type RejectionReason
- type RuntimeBinding
- type RuntimeIdentity
- type Sampling
- type Series
- type Service
- type Snapshot
- type SnapshotReader
- type SourceIdentity
- type Span
Constants ¶
const ( SchemaIdentity = "openrealtime/presentation/client-performance-evidence/v1" ConfigurationSchemaIdentity = "openrealtime/presentation/client-performance-evidence-config/v1" SnapshotFormatVersion = uint64(1) ConfigurationVersion = uint64(1) MaxSources = uint16(128) MaxSeries = uint16(256) MaxDimensionsPerSeries = uint8(4) MaxPendingSpans = uint16(256) MaxObservationsPerSeries = uint32(4096) MaxSnapshotBytes = 256 << 10 MaxDurationNS = uint64(24 * 60 * 60 * 1_000_000_000) )
const ( DimensionTransport DimensionName = "transport" DimensionMedia DimensionName = "media" DimensionQueue DimensionName = "queue" DimensionRender DimensionName = "render" ValueWebSocket DimensionValue = "websocket" ValueWebRTC DimensionValue = "webrtc" ValueAudio DimensionValue = "audio" ValueVideo DimensionValue = "video" ValueData DimensionValue = "data" ValueOutboundMessage DimensionValue = "outbound_messages" ValueOutboundBytes DimensionValue = "outbound_bytes" ValueAudioPlayout DimensionValue = "audio_playout" ValueVideoCapture DimensionValue = "video_capture" ValueConversation DimensionValue = "conversation" ValueLiveSnapshot DimensionValue = "live_snapshot" ValueDelta DimensionValue = "delta" ValueTrace DimensionValue = "trace" )
Variables ¶
Functions ¶
func CollectorDescriptor ¶
func CollectorDescriptor() plugin.Descriptor
CollectorDescriptor returns the immutable semantic descriptor for the portable collector. Implementations and their artifacts remain deployment bindings and are not smuggled into this descriptor.
func CollectorDescriptorIdentity ¶
CollectorDescriptorIdentity is convenient for descriptor locks and runtime registration tests.
func ConfigurationContract ¶
ConfigurationContract identifies the separately fingerprinted collector configuration schema used by descriptor/profile compilation.
func DurationBucketUpperBoundsNS ¶
func DurationBucketUpperBoundsNS() []uint64
func MarshalSnapshot ¶
func ServiceContract ¶
ServiceContract returns a copy of the exact service contract used by client profile dependency resolution. Returning a value, rather than exporting a mutable package variable, prevents callers from changing the identity seen by later registrations.
Types ¶
type ClientPlatform ¶
type ClientPlatform string
const ( PlatformHeadless ClientPlatform = "headless" PlatformBrowser ClientPlatform = "browser" PlatformMacOS ClientPlatform = "macos" )
type ClockDomain ¶
type ClockDomain string
const ( ClockVirtualInteger ClockDomain = "virtual_integer_ns" ClockProcessMonotonic ClockDomain = "process_monotonic_ns" ClockBrowserMonotonic ClockDomain = "browser_monotonic_ns" ClockMachContinuous ClockDomain = "mach_continuous_ns" )
type ClockIdentity ¶
type ClockIdentity struct {
Domain ClockDomain `json:"domain"`
ResolutionNS uint64 `json:"resolution_ns"`
Provenance ClockProvenance `json:"provenance"`
CrossHostSynchronized bool `json:"cross_host_synchronized"`
CrossHostErrorBoundNS uint64 `json:"cross_host_error_bound_ns,omitempty"`
}
type ClockProvenance ¶
type ClockProvenance string
const ( ClockFromFixture ClockProvenance = "deterministic_fixture" ClockFromGoMonotonic ClockProvenance = "go_monotonic" ClockFromBrowserAPI ClockProvenance = "browser_performance_api" ClockFromMachClock ClockProvenance = "mach_continuous_time" ClockFromSynchronized ClockProvenance = "bounded_cross_host_sync" )
type Configuration ¶
type Configuration struct {
FormatVersion uint64 `json:"format_version"`
Mode ObservabilityMode `json:"mode"`
Sampling Sampling `json:"sampling"`
Limits Limits `json:"limits"`
Fingerprint string `json:"fingerprint"`
}
func DefaultConfiguration ¶
func DefaultConfiguration(mode ObservabilityMode) (Configuration, error)
func FreezeConfiguration ¶
func FreezeConfiguration(source Configuration) (Configuration, error)
func (Configuration) Validate ¶
func (configuration Configuration) Validate() error
type CounterAggregate ¶
type CoverageReason ¶
type CoverageReason string
const ( CoverageReasonNone CoverageReason = "none" CoverageReasonClockUnsynchronized CoverageReason = "clock_unsynchronized" )
type Dimension ¶
type Dimension struct {
Name DimensionName `json:"name"`
Value DimensionValue `json:"value"`
}
type DimensionName ¶
type DimensionName string
DimensionName and DimensionValue are separate closed vocabularies. Only the name/value pairs in dimensionPairs are valid.
type DimensionValue ¶
type DimensionValue string
type DropCounter ¶
type DropCounter struct {
Reason DropReason `json:"reason"`
Count uint64 `json:"count"`
}
type DropReason ¶
type DropReason string
const DropDeterministicSampling DropReason = "deterministic_sampling"
type DurationHistogram ¶
type EvidenceClass ¶
type EvidenceClass string
EvidenceClass says what environment can truthfully support the evidence.
const ( EvidenceDeterministicFixture EvidenceClass = "deterministic_fixture" EvidenceBrowserRuntime EvidenceClass = "browser_runtime" EvidenceMacOSNative EvidenceClass = "macos_native" )
type GaugeAggregate ¶
type Limits ¶
type Limits struct {
MaxSources uint16 `json:"max_sources"`
MaxSeries uint16 `json:"max_series"`
MaxDimensionsPerSeries uint8 `json:"max_dimensions_per_series"`
MaxPendingSpans uint16 `json:"max_pending_spans"`
MaxObservationsPerSeries uint32 `json:"max_observations_per_series"`
MaxArtifactBytes uint32 `json:"max_artifact_bytes"`
}
func DefaultLimits ¶
func DefaultLimits() Limits
type Metric ¶
type Metric string
Metric is the complete v1 metric vocabulary. Units and families are fixed by metricSpecifications; a caller cannot rename or reinterpret a series.
const ( MetricEndpointToFirstRenderedAudio Metric = "endpoint_to_first_rendered_audio_ns" MetricServerOutputToRenderedAudio Metric = "server_output_to_rendered_audio_ns" MetricAudioScheduled Metric = "audio_scheduled_ns" MetricAudioCompleted Metric = "audio_completed_ns" MetricVideoCaptureToAdmissionAck Metric = "video_capture_to_admission_ack_ns" MetricReconnectDetection Metric = "reconnect_detection_ns" MetricReconnectRecovery Metric = "reconnect_recovery_ns" MetricReducerToViewCommit Metric = "reducer_publish_to_view_commit_ns" MetricLongTask Metric = "long_task_ns" MetricMainLoopStall Metric = "main_loop_stall_ns" MetricLiveSnapshotRender Metric = "live_snapshot_render_ns" MetricDeltaRender Metric = "delta_render_ns" MetricTraceRender Metric = "trace_render_ns" MetricAudioGap Metric = "audio_gap_count" MetricAudioUnderflow Metric = "audio_underflow_count" MetricAudioOverrun Metric = "audio_overrun_count" MetricAudioCaptureDrop Metric = "audio_capture_drop_count" MetricVideoCaptureDrop Metric = "video_capture_drop_count" MetricReconnectLostEvent Metric = "reconnect_lost_event_count" MetricReconnectDuplicate Metric = "reconnect_duplicate_event_count" MetricClientMessageQueue Metric = "client_message_queue_depth" MetricClientByteQueue Metric = "client_byte_queue_bytes" MetricMemoryBaseline Metric = "memory_baseline_bytes" MetricMemoryCurrent Metric = "memory_current_bytes" MetricMemoryHighWater Metric = "memory_high_water_bytes" MetricMemoryGrowth Metric = "memory_growth_bytes" )
type MetricFamily ¶
type MetricFamily string
const ( FamilyDuration MetricFamily = "duration_ns" FamilyCounter MetricFamily = "counter" FamilyGauge MetricFamily = "gauge" )
func FamilyOf ¶
func FamilyOf(metric Metric) (MetricFamily, bool)
type MountScope ¶
type MountScope struct {
// contains filtered or unexported fields
}
func NewMountScope ¶
func NewMountScope() *MountScope
func (*MountScope) Lose ¶
func (scope *MountScope) Lose(provider *Provider) error
Lose invalidates every recorder and pending span created by provider. It is idempotent for the provider that was most recently lost. A later Mount gets a fresh generation and an entirely separate aggregate.
func (*MountScope) Mount ¶
func (scope *MountScope) Mount(binding RuntimeBinding, configuration Configuration) (*Provider, error)
type ObservabilityMode ¶
type ObservabilityMode string
ObservabilityMode is part of the frozen collector configuration. Disabled is a closed vocabulary member but cannot be mounted: a disabled profile must omit both collector and probes so it remains a valid overhead baseline.
const ( ObservabilityDisabled ObservabilityMode = "disabled" ObservabilitySampled ObservabilityMode = "sampled" ObservabilityRelease ObservabilityMode = "release" )
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func (*Provider) Identity ¶
func (provider *Provider) Identity() RuntimeIdentity
Identity returns a recursively independent copy of the runtime-injected envelope. Mutating it cannot affect the provider or later snapshots.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a scoped, identity-free recording face. Its fields are private so it cannot be retargeted to another source or generation.
func (Recorder) AddCounter ¶
func (Recorder) BeginDuration ¶
func (Recorder) CompleteDuration ¶
func (Recorder) RecordDuration ¶
func (Recorder) SetCoverage ¶
type RejectedError ¶
type RejectedError struct {
Reason RejectionReason
}
func (RejectedError) Error ¶
func (rejection RejectedError) Error() string
func (RejectedError) Is ¶
func (rejection RejectedError) Is(target error) bool
type RejectionCounter ¶
type RejectionCounter struct {
Reason RejectionReason `json:"reason"`
Count uint64 `json:"count"`
}
type RejectionReason ¶
type RejectionReason string
const ( RejectUnknownEnum RejectionReason = "unknown_enum" RejectWrongMetricFamily RejectionReason = "wrong_metric_family" RejectBackwardTime RejectionReason = "backward_time" RejectTimingOverflow RejectionReason = "timing_overflow" RejectUnmatchedSpan RejectionReason = "unmatched_span" RejectDuplicateSpan RejectionReason = "duplicate_span" RejectSourceBound RejectionReason = "source_bound" RejectSeriesBound RejectionReason = "series_bound" RejectDimensionBound RejectionReason = "dimension_bound" RejectPendingSpanBound RejectionReason = "pending_span_bound" RejectObservationBound RejectionReason = "observation_bound" RejectCounterOverflow RejectionReason = "counter_overflow" RejectCoverageConflict RejectionReason = "coverage_conflict" RejectIdentityMismatch RejectionReason = "identity_mismatch" RejectArtifactBound RejectionReason = "artifact_bound" )
func RejectionReasonOf ¶
func RejectionReasonOf(err error) (RejectionReason, bool)
RejectionReasonOf extracts the closed reason from a rejected recorder call.
type RuntimeBinding ¶
type RuntimeBinding struct {
EvidenceClass EvidenceClass `json:"evidence_class"`
Platform ClientPlatform `json:"platform"`
Clock ClockIdentity `json:"clock"`
ProfileFingerprint string `json:"profile_fingerprint"`
LockFingerprint string `json:"lock_fingerprint"`
PlanFingerprint string `json:"plan_fingerprint"`
ManifestFingerprint string `json:"manifest_fingerprint"`
Collector plugin.Identity `json:"collector"`
ImplementationDigest string `json:"implementation_digest"`
ConfigurationDigest string `json:"configuration_digest"`
FixtureDigest string `json:"fixture_digest,omitempty"`
Sources []SourceIdentity `json:"sources"`
}
RuntimeBinding is supplied by the client composition runtime. Generation is intentionally absent: MountScope injects it, and recording callers never receive a setter for any field in the resulting identity.
type RuntimeIdentity ¶
type RuntimeIdentity struct {
EvidenceClass EvidenceClass `json:"evidence_class"`
Platform ClientPlatform `json:"platform"`
Clock ClockIdentity `json:"clock"`
ProfileFingerprint string `json:"profile_fingerprint"`
LockFingerprint string `json:"lock_fingerprint"`
PlanFingerprint string `json:"plan_fingerprint"`
ManifestFingerprint string `json:"manifest_fingerprint"`
Collector plugin.Identity `json:"collector"`
ImplementationDigest string `json:"implementation_digest"`
ConfigurationDigest string `json:"configuration_digest"`
FixtureDigest string `json:"fixture_digest,omitempty"`
ObservabilityMode ObservabilityMode `json:"observability_mode"`
Generation uint64 `json:"generation"`
Sources []SourceIdentity `json:"sources"`
}
func (RuntimeIdentity) Clone ¶
func (identity RuntimeIdentity) Clone() RuntimeIdentity
type Series ¶
type Series struct {
Source uint16 `json:"source"`
Metric Metric `json:"metric"`
Family MetricFamily `json:"family"`
Dimensions []Dimension `json:"dimensions"`
Coverage Coverage `json:"coverage"`
CoverageReason CoverageReason `json:"coverage_reason"`
Attempts uint64 `json:"attempts"`
SamplingDropped uint64 `json:"sampling_dropped"`
Duration *DurationHistogram `json:"duration,omitempty"`
Counter *CounterAggregate `json:"counter,omitempty"`
Gauge *GaugeAggregate `json:"gauge,omitempty"`
}
type Service ¶
type Service interface {
SnapshotReader
Recorder(source uint16) (Recorder, error)
}
Service is the provider face mounted under ServiceContract. Client runtimes inject individual Recorder values into probes and may separately export the narrower SnapshotReader face.
type Snapshot ¶
type Snapshot struct {
FormatVersion uint64 `json:"format_version"`
Schema string `json:"schema"`
Contract plugin.Contract `json:"contract"`
Identity RuntimeIdentity `json:"identity"`
Configuration Configuration `json:"configuration"`
DurationBucketsNS []uint64 `json:"duration_buckets_ns"`
Series []Series `json:"series"`
Rejections []RejectionCounter `json:"rejections"`
Drops []DropCounter `json:"drops"`
Fingerprint string `json:"fingerprint"`
}
func DecodeSnapshot ¶
DecodeSnapshot accepts only the exact compact canonical representation produced by MarshalSnapshot. Duplicate keys, unknown fields, trailing data, enum drift, ordering drift, fingerprint drift, and oversized artifacts fail closed.
type SnapshotReader ¶
SnapshotReader is the narrow read-only face intended for exporters and observability views. It cannot obtain a recorder or mutate collector state.