telemetry

package
v0.35.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 67 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DiagnosticsOK          = "ok"
	DiagnosticsTruncated   = "truncated"
	DiagnosticsUnsupported = "unsupported"
	DiagnosticsError       = "error"
	DiagnosticsInvalid     = "invalid"
	DiagnosticsStale       = "stale"
)

Availability states reported by PluginDiagnosticsStatusMetric. A plugin that is not "ok" or "truncated" contributes no measurement points.

View Source
const (

	// PluginDiagnosticsStatusMetric is the host-owned availability gauge.
	PluginDiagnosticsStatusMetric = "omniview.plugin.diagnostics.status"
)

Variables

This section is empty.

Functions

func ExtractContext

func ExtractContext(parent context.Context, carrier map[string]string) context.Context

ExtractContext extracts trace context from a string map carrier into the given parent context.

func GetValidLogLevels

func GetValidLogLevels() []string

GetValidLogLevels returns a copy of the accepted log level strings.

func InjectContext

func InjectContext(ctx context.Context) map[string]string

InjectContext injects the current trace context from ctx into a string map carrier.

func IsValidClientID added in v0.35.1

func IsValidClientID(id string) bool

IsValidClientID accepts an optional, bounded identifier safe for telemetry labels.

func IsValidLogLevel

func IsValidLogLevel(s string) bool

IsValidLogLevel reports whether s is a recognized log level.

func NewLogExporter

func NewLogExporter(ctx context.Context, endpoint, authHeader, authValue, tenantID string) (sdklog.Exporter, error)

NewLogExporter creates an OTLP HTTP log exporter.

func NewLoggerProvider

func NewLoggerProvider(res *resource.Resource, exp sdklog.Exporter) *sdklog.LoggerProvider

NewLoggerProvider creates a LoggerProvider with a batching log processor.

func NewLokiLogExporter added in v0.35.0

func NewLokiLogExporter(endpoint, tenant, authHeader, authValue string) (sdklog.Exporter, error)

NewLokiLogExporter creates an exporter for a complete Loki push URL.

func NewMeterProvider

func NewMeterProvider(res *resource.Resource, exp sdkmetric.Exporter) *sdkmetric.MeterProvider

NewMeterProvider creates a MeterProvider with a periodic reader wrapping the given exporter.

func NewMetricExporter

func NewMetricExporter(ctx context.Context, endpoint, authHeader, authValue string) (sdkmetric.Exporter, error)

NewMetricExporter creates an OTLP HTTP metric exporter.

func NewNoopTraceExporter

func NewNoopTraceExporter() sdktrace.SpanExporter

NewNoopTraceExporter returns a span exporter that discards all spans.

func NewResource

func NewResource(version, gitCommit, buildDate string, isDev bool) (*resource.Resource, error)

NewResource creates a shared OTel Resource that identifies this Omniview instance.

func NewTraceExporter

func NewTraceExporter(ctx context.Context, endpoint, authHeader, authValue string) (sdktrace.SpanExporter, error)

NewTraceExporter creates an OTLP HTTP trace exporter.

func NewTracerProvider

func NewTracerProvider(res *resource.Resource, exp sdktrace.SpanExporter) *sdktrace.TracerProvider

NewTracerProvider creates a TracerProvider with a batching span exporter.

func RecordPipelineDispatch added in v0.32.0

func RecordPipelineDispatch(ctx context.Context, queued time.Time, targets, pairs int)

func RecordPipelineEvent added in v0.32.0

func RecordPipelineEvent(ctx context.Context, event string, count int64)

func RecordPipelineProvider added in v0.32.0

func RecordPipelineProvider(ctx context.Context, operation string, started time.Time, err error)

func RecordPipelineResponse added in v0.32.0

func RecordPipelineResponse(ctx context.Context, bytes, results int)

func RecordPluginActive added in v0.32.0

func RecordPluginActive(ctx context.Context, delta int64)

func RecordPluginCrash added in v0.32.0

func RecordPluginCrash(ctx context.Context)

func RecordPluginHealthProbe added in v0.35.2

func RecordPluginHealthProbe(ctx context.Context, pluginID, outcome string, d time.Duration)

func RecordPluginInstall added in v0.35.2

func RecordPluginInstall(ctx context.Context, pluginID, source, outcome string, d time.Duration)

func RecordPluginQuarantine added in v0.32.0

func RecordPluginQuarantine(ctx context.Context)

func RecordPluginStreamEvent added in v0.35.2

func RecordPluginStreamEvent(ctx context.Context, pluginID, stream, event string)

func RecordResourceRecords added in v0.32.0

func RecordResourceRecords(ctx context.Context, operation string, count int64)

func RegisterPipelineState added in v0.32.0

func RegisterPipelineState(source func() PipelineState) func()

func RegisterPluginDiagnosticsSource added in v0.32.0

func RegisterPluginDiagnosticsSource(source func() []PluginDiagnosticsTarget)

RegisterPluginDiagnosticsSource supplies running backends and starts the polling goroutine. Passing nil stops polling and drops every cached reply.

func RegisterPluginProcessSource added in v0.32.0

func RegisterPluginProcessSource(source func() []PluginProcess)

RegisterPluginProcessSource supplies verified plugin PIDs and starts a background sampler. Sampling never runs inside the metric collection callback: the callback only reads the latest cached result, so a slow process listing or a lock held by the plugin manager cannot stall collection.

func StopPluginDiagnostics added in v0.32.0

func StopPluginDiagnostics()

StopPluginDiagnostics ends polling (telemetry shutdown).

func StopPluginProcessSampling added in v0.32.0

func StopPluginProcessSampling()

StopPluginProcessSampling ends background sampling (telemetry shutdown).

func ValidateLokiConfig added in v0.35.0

func ValidateLokiConfig(endpoint, tenant, authHeader, authValue string) error

ValidateLokiConfig validates the destination and headers for a Loki exporter.

func WithControllerProfile

func WithControllerProfile(ctx context.Context, controller, op string, fn func(context.Context))

WithControllerProfile wraps fn with Pyroscope labels identifying the controller and operation.

func WithPlugin added in v0.32.0

func WithPlugin(ctx context.Context, id string) context.Context

WithPlugin attaches the host-assigned plugin ID to measurements recorded with ctx. IDs come from installed manifests, never from plugin-supplied data.

func WithPluginProfile

func WithPluginProfile(ctx context.Context, pluginID string, fn func(context.Context))

WithPluginProfile wraps fn with Pyroscope labels identifying the plugin.

Types

type Config added in v0.4.0

type Config struct {
	Enabled           bool
	ClientID          string
	Traces            bool
	Metrics           bool
	LogsShip          bool
	LogsShipLevel     string
	Profiling         bool
	OTLPEndpoint      string
	LogFormat         string
	OTLPLogEndpoint   string
	OTLPLogAuthHeader string
	OTLPLogAuthValue  string
	OTLPLogTenantID   string
	LokiEndpoint      string
	LokiTenantID      string
	LokiAuthHeader    string
	LokiAuthValue     string
	PyroscopeEndpoint string
	AuthHeader        string
	AuthValue         string
}

Config holds all telemetry-related configuration. AuthHeader/AuthValue are set at runtime via the settings UI, never at build time.

func DefaultConfig

func DefaultConfig(isDev bool) Config

DefaultConfig returns sensible defaults based on whether the app is running in development mode or production mode.

func (Config) WithSettings added in v0.4.0

func (c Config) WithSettings(vals map[string]any) Config

WithSettings returns a copy of c with the values of the "telemetry" settings category overlaid. Keys that are missing or have the wrong type are ignored.

type FrontendError

type FrontendError struct {
	Type       string `json:"type"`
	Message    string `json:"message"`
	Stacktrace string `json:"stacktrace,omitempty"`
}

FrontendError represents a frontend exception or unhandled error.

type FrontendLog

type FrontendLog struct {
	Message string            `json:"message"`
	Level   string            `json:"level"`
	Context map[string]string `json:"context,omitempty"`
}

FrontendLog represents a single log entry from the frontend.

type FrontendMeasurement

type FrontendMeasurement struct {
	Type   string             `json:"type"`
	Values map[string]float64 `json:"values,omitempty"`
}

FrontendMeasurement represents a frontend performance measurement.

type FrontendSignals

type FrontendSignals struct {
	Logs         []FrontendLog         `json:"logs,omitempty"`
	Errors       []FrontendError       `json:"errors,omitempty"`
	Measurements []FrontendMeasurement `json:"measurements,omitempty"`
}

FrontendSignals is the JSON envelope sent by the frontend telemetry transport.

type Metrics

type Metrics struct {
	PluginLoadDuration        metric.Float64Histogram
	PluginActive              metric.Int64UpDownCounter
	PluginCrashes             metric.Int64Counter
	PluginQuarantines         metric.Int64Counter
	PluginHealthProbes        metric.Int64Counter
	PluginHealthProbeDuration metric.Float64Histogram
	PluginInstalls            metric.Int64Counter
	PluginInstallDuration     metric.Float64Histogram
	PluginStreamEvents        metric.Int64Counter

	ResourceOpDuration  metric.Float64Histogram
	ResourceOpErrors    metric.Int64Counter
	ResourceWatchActive metric.Int64UpDownCounter

	WailsCallDuration        metric.Float64Histogram
	OperationCalls           metric.Int64Counter
	OperationActive          metric.Int64UpDownCounter
	ResourceRecords          metric.Int64Counter
	PipelineEvents           metric.Int64Counter
	PipelineQueueDuration    metric.Float64Histogram
	PipelineProviderDuration metric.Float64Histogram
	PipelineWork             metric.Int64Counter
	PipelineResponseBytes    metric.Int64Histogram
	WailsCalls               metric.Int64Counter
}

Metrics holds all registered application metrics.

func NewMetrics

func NewMetrics(mp metric.MeterProvider) (*Metrics, error)

NewMetrics registers all application metrics with the given MeterProvider.

type Operation added in v0.32.0

type Operation struct {
	// contains filtered or unexported fields
}

Operation measures one host operation. End must be deferred immediately. Attribute values are normalized here, never copied from caller identities.

func BeginOperation added in v0.32.0

func BeginOperation(ctx context.Context, domain, operation string) Operation

func (Operation) End added in v0.32.0

func (o Operation) End(err error)

type PipelineState added in v0.32.0

type PipelineState struct {
	Queued, Inflight, CatalogInflight, CatalogWaiters, CacheEntries, CacheBytes, Observations, SnapshotBytes int64
}

PipelineState is sampled under the coordinator's own lock. Inflight includes retired providers until they return, not merely until cancellation is requested.

type PluginDiagnosticsTarget added in v0.32.0

type PluginDiagnosticsTarget struct {
	PluginID   string
	Generation any
	Fetch      func(ctx context.Context) (*lifecyclepb.GetDiagnosticsResponse, error)
}

PluginDiagnosticsTarget is one running plugin backend. Generation is a comparable token that changes whenever the backend is replaced; a capability probe result is only reused for the same generation.

type PluginProcess added in v0.32.0

type PluginProcess struct {
	PluginID string
	PID      int
}

PluginProcess is one verified child process owned by a plugin.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the top-level telemetry orchestrator. It initialises tracing, metrics, log shipping, profiling and a triple-core Zap logger.

func New

func New(cfg Config, version, commit, date string, isDev bool, logDir string) *Service

New creates a telemetry Service. Call Init to start it. logDir is the directory where log files are stored.

func (*Service) ApplyConfig

func (s *Service) ApplyConfig(ctx context.Context, cfg Config) error

ApplyConfig applies new telemetry settings at runtime by swapping exporters. This is the primary hot-toggle mechanism — called when the user changes telemetry settings via the UI. The context is used for exporter creation.

func (*Service) ClientID added in v0.35.1

func (s *Service) ClientID() string

ClientID returns the installation identity fixed at telemetry initialization.

func (*Service) Config

func (s *Service) Config() Config

Config returns the current telemetry configuration.

func (*Service) Init

func (s *Service) Init(ctx context.Context) error

Init bootstraps all configured telemetry subsystems and sets OTel globals.

func (*Service) LoggerProvider

func (s *Service) LoggerProvider() *sdklog.LoggerProvider

LoggerProvider returns the SDK LoggerProvider, or nil when log shipping is disabled.

func (*Service) Resource

func (s *Service) Resource() *resource.Resource

Resource returns the OTel resource describing this Omniview instance.

func (*Service) SetDiagnostics added in v0.32.0

func (s *Service) SetDiagnostics(service *diagnostics.Service)

SetDiagnostics installs the single local collection path before Init.

func (*Service) SetLogShipLevel

func (s *Service) SetLogShipLevel(level string)

SetLogShipLevel hot-toggles the minimum log level shipped via OTLP. This is safe to call from any goroutine.

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Shutdown gracefully stops all telemetry subsystems, flushing any buffered data. It first swaps global OTel providers to noop implementations so that callers using otel.Tracer() / otel.Meter() after shutdown get safe no-ops instead of closed providers.

func (*Service) StartPluginTraceReceiver added in v0.35.1

func (s *Service) StartPluginTraceReceiver(pluginID string) (string, string, func(), error)

StartPluginTraceReceiver creates a capability-protected receiver owned by one plugin process. The capability is unrelated to the collector credentials.

func (*Service) TracerProvider

func (s *Service) TracerProvider() *sdktrace.TracerProvider

TracerProvider returns the SDK TracerProvider, or nil when telemetry is disabled.

func (*Service) ZapLogger

func (s *Service) ZapLogger() *zap.Logger

ZapLogger returns the triple-core Zap logger.

type SwitchableLogExporter

type SwitchableLogExporter struct {
	// contains filtered or unexported fields
}

SwitchableLogExporter wraps a sdklog.Exporter.

func (*SwitchableLogExporter) Export

func (s *SwitchableLogExporter) Export(ctx context.Context, records []sdklog.Record) error

func (*SwitchableLogExporter) ForceFlush

func (s *SwitchableLogExporter) ForceFlush(ctx context.Context) error

func (*SwitchableLogExporter) Shutdown

func (s *SwitchableLogExporter) Shutdown(ctx context.Context) error

func (*SwitchableLogExporter) Swap

type SwitchableMetricExporter

type SwitchableMetricExporter struct {
	// contains filtered or unexported fields
}

SwitchableMetricExporter wraps a sdkmetric.Exporter.

func (*SwitchableMetricExporter) Aggregation

func (*SwitchableMetricExporter) Export

func (*SwitchableMetricExporter) ForceFlush

func (s *SwitchableMetricExporter) ForceFlush(ctx context.Context) error

func (*SwitchableMetricExporter) Shutdown

func (s *SwitchableMetricExporter) Shutdown(ctx context.Context) error

func (*SwitchableMetricExporter) Swap

func (*SwitchableMetricExporter) Temporality

type SwitchableSpanExporter

type SwitchableSpanExporter struct {
	// contains filtered or unexported fields
}

SwitchableSpanExporter wraps a sdktrace.SpanExporter and allows swapping the inner exporter at runtime via atomic operations.

func (*SwitchableSpanExporter) ExportSpans

func (s *SwitchableSpanExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (*SwitchableSpanExporter) Shutdown

func (s *SwitchableSpanExporter) Shutdown(ctx context.Context) error

func (*SwitchableSpanExporter) Swap

type TelemetryBinding

type TelemetryBinding struct {
	// contains filtered or unexported fields
}

TelemetryBinding exposes telemetry operations to the Wails frontend.

func NewTelemetryBinding

func NewTelemetryBinding(svc *Service) *TelemetryBinding

NewTelemetryBinding creates a binding backed by the given telemetry Service.

func (*TelemetryBinding) IngestFrontendSignals

func (b *TelemetryBinding) IngestFrontendSignals(payload string) error

IngestFrontendSignals accepts a JSON payload from the frontend containing logs, errors, and measurements, and converts them into backend telemetry signals (Zap logs, OTel trace span events).

type ZapBackend

type ZapBackend struct {
	// contains filtered or unexported fields
}

ZapBackend implements the plugin-sdk logging.Backend interface, bridging plugin log records into a structured Zap logger.

func NewZapBackend

func NewZapBackend(logger *zap.Logger) *ZapBackend

NewZapBackend creates a ZapBackend that writes plugin-sdk log records to the given Zap logger.

func (*ZapBackend) Sync

func (b *ZapBackend) Sync(_ context.Context) error

Sync flushes the underlying Zap logger buffers. It suppresses the well-known spurious "sync /dev/stderr" error that occurs on macOS/Linux when stderr is a terminal.

func (*ZapBackend) Write

func (b *ZapBackend) Write(ctx context.Context, r logging.Record) error

Write converts a plugin-sdk Record into a Zap log entry and writes it. If the context carries an active OTel span, trace_id and span_id are extracted and added as structured fields for log↔trace correlation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL