Documentation
¶
Index ¶
- Constants
- func ExtractContext(parent context.Context, carrier map[string]string) context.Context
- func GetValidLogLevels() []string
- func InjectContext(ctx context.Context) map[string]string
- func IsValidClientID(id string) bool
- func IsValidLogLevel(s string) bool
- func NewLogExporter(ctx context.Context, endpoint, authHeader, authValue, tenantID string) (sdklog.Exporter, error)
- func NewLoggerProvider(res *resource.Resource, exp sdklog.Exporter) *sdklog.LoggerProvider
- func NewLokiLogExporter(endpoint, tenant, authHeader, authValue string) (sdklog.Exporter, error)
- func NewMeterProvider(res *resource.Resource, exp sdkmetric.Exporter) *sdkmetric.MeterProvider
- func NewMetricExporter(ctx context.Context, endpoint, authHeader, authValue string) (sdkmetric.Exporter, error)
- func NewNoopTraceExporter() sdktrace.SpanExporter
- func NewResource(version, gitCommit, buildDate string, isDev bool) (*resource.Resource, error)
- func NewTraceExporter(ctx context.Context, endpoint, authHeader, authValue string) (sdktrace.SpanExporter, error)
- func NewTracerProvider(res *resource.Resource, exp sdktrace.SpanExporter) *sdktrace.TracerProvider
- func RecordPipelineDispatch(ctx context.Context, queued time.Time, targets, pairs int)
- func RecordPipelineEvent(ctx context.Context, event string, count int64)
- func RecordPipelineProvider(ctx context.Context, operation string, started time.Time, err error)
- func RecordPipelineResponse(ctx context.Context, bytes, results int)
- func RecordPluginActive(ctx context.Context, delta int64)
- func RecordPluginCrash(ctx context.Context)
- func RecordPluginHealthProbe(ctx context.Context, pluginID, outcome string, d time.Duration)
- func RecordPluginInstall(ctx context.Context, pluginID, source, outcome string, d time.Duration)
- func RecordPluginQuarantine(ctx context.Context)
- func RecordPluginStreamEvent(ctx context.Context, pluginID, stream, event string)
- func RecordResourceRecords(ctx context.Context, operation string, count int64)
- func RegisterPipelineState(source func() PipelineState) func()
- func RegisterPluginDiagnosticsSource(source func() []PluginDiagnosticsTarget)
- func RegisterPluginProcessSource(source func() []PluginProcess)
- func StopPluginDiagnostics()
- func StopPluginProcessSampling()
- func ValidateLokiConfig(endpoint, tenant, authHeader, authValue string) error
- func WithControllerProfile(ctx context.Context, controller, op string, fn func(context.Context))
- func WithPlugin(ctx context.Context, id string) context.Context
- func WithPluginProfile(ctx context.Context, pluginID string, fn func(context.Context))
- type Config
- type FrontendError
- type FrontendLog
- type FrontendMeasurement
- type FrontendSignals
- type Metrics
- type Operation
- type PipelineState
- type PluginDiagnosticsTarget
- type PluginProcess
- type Service
- func (s *Service) ApplyConfig(ctx context.Context, cfg Config) error
- func (s *Service) ClientID() string
- func (s *Service) Config() Config
- func (s *Service) Init(ctx context.Context) error
- func (s *Service) LoggerProvider() *sdklog.LoggerProvider
- func (s *Service) Resource() *resource.Resource
- func (s *Service) SetDiagnostics(service *diagnostics.Service)
- func (s *Service) SetLogShipLevel(level string)
- func (s *Service) Shutdown(ctx context.Context) error
- func (s *Service) StartPluginTraceReceiver(pluginID string) (string, string, func(), error)
- func (s *Service) TracerProvider() *sdktrace.TracerProvider
- func (s *Service) ZapLogger() *zap.Logger
- type SwitchableLogExporter
- func (s *SwitchableLogExporter) Export(ctx context.Context, records []sdklog.Record) error
- func (s *SwitchableLogExporter) ForceFlush(ctx context.Context) error
- func (s *SwitchableLogExporter) Shutdown(ctx context.Context) error
- func (s *SwitchableLogExporter) Swap(exp sdklog.Exporter) sdklog.Exporter
- type SwitchableMetricExporter
- func (s *SwitchableMetricExporter) Aggregation(k sdkmetric.InstrumentKind) sdkmetric.Aggregation
- func (s *SwitchableMetricExporter) Export(ctx context.Context, rm *metricdata.ResourceMetrics) error
- func (s *SwitchableMetricExporter) ForceFlush(ctx context.Context) error
- func (s *SwitchableMetricExporter) Shutdown(ctx context.Context) error
- func (s *SwitchableMetricExporter) Swap(exp sdkmetric.Exporter) sdkmetric.Exporter
- func (s *SwitchableMetricExporter) Temporality(k sdkmetric.InstrumentKind) metricdata.Temporality
- type SwitchableSpanExporter
- type TelemetryBinding
- type ZapBackend
Constants ¶
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.
const (
// PluginDiagnosticsStatusMetric is the host-owned availability gauge.
PluginDiagnosticsStatusMetric = "omniview.plugin.diagnostics.status"
)
Variables ¶
This section is empty.
Functions ¶
func ExtractContext ¶
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 ¶
InjectContext injects the current trace context from ctx into a string map carrier.
func IsValidClientID ¶ added in v0.35.1
IsValidClientID accepts an optional, bounded identifier safe for telemetry labels.
func IsValidLogLevel ¶
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 ¶
NewLoggerProvider creates a LoggerProvider with a batching log processor.
func NewLokiLogExporter ¶ added in v0.35.0
NewLokiLogExporter creates an exporter for a complete Loki push URL.
func NewMeterProvider ¶
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 ¶
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 RecordPipelineEvent ¶ added in v0.32.0
func RecordPipelineProvider ¶ added in v0.32.0
func RecordPipelineResponse ¶ added in v0.32.0
func RecordPluginActive ¶ added in v0.32.0
func RecordPluginCrash ¶ added in v0.32.0
func RecordPluginHealthProbe ¶ added in v0.35.2
func RecordPluginInstall ¶ added in v0.35.2
func RecordPluginQuarantine ¶ added in v0.32.0
func RecordPluginStreamEvent ¶ added in v0.35.2
func RecordResourceRecords ¶ added in v0.32.0
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
ValidateLokiConfig validates the destination and headers for a Loki exporter.
func WithControllerProfile ¶
WithControllerProfile wraps fn with Pyroscope labels identifying the controller and operation.
func WithPlugin ¶ added in v0.32.0
WithPlugin attaches the host-assigned plugin ID to measurements recorded with ctx. IDs come from installed manifests, never from plugin-supplied data.
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 ¶
DefaultConfig returns sensible defaults based on whether the app is running in development mode or production mode.
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
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
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 ¶
New creates a telemetry Service. Call Init to start it. logDir is the directory where log files are stored.
func (*Service) ApplyConfig ¶
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
ClientID returns the installation identity fixed at telemetry initialization.
func (*Service) LoggerProvider ¶
func (s *Service) LoggerProvider() *sdklog.LoggerProvider
LoggerProvider returns the SDK LoggerProvider, or nil when log shipping is disabled.
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 ¶
SetLogShipLevel hot-toggles the minimum log level shipped via OTLP. This is safe to call from any goroutine.
func (*Service) Shutdown ¶
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
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.
type SwitchableLogExporter ¶
type SwitchableLogExporter struct {
// contains filtered or unexported fields
}
SwitchableLogExporter wraps a sdklog.Exporter.
func (*SwitchableLogExporter) ForceFlush ¶
func (s *SwitchableLogExporter) ForceFlush(ctx context.Context) error
type SwitchableMetricExporter ¶
type SwitchableMetricExporter struct {
// contains filtered or unexported fields
}
SwitchableMetricExporter wraps a sdkmetric.Exporter.
func (*SwitchableMetricExporter) Aggregation ¶
func (s *SwitchableMetricExporter) Aggregation(k sdkmetric.InstrumentKind) sdkmetric.Aggregation
func (*SwitchableMetricExporter) Export ¶
func (s *SwitchableMetricExporter) Export(ctx context.Context, rm *metricdata.ResourceMetrics) error
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 (s *SwitchableMetricExporter) Swap(exp sdkmetric.Exporter) sdkmetric.Exporter
func (*SwitchableMetricExporter) Temporality ¶
func (s *SwitchableMetricExporter) Temporality(k sdkmetric.InstrumentKind) metricdata.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 ¶
func (s *SwitchableSpanExporter) Swap(exp sdktrace.SpanExporter) sdktrace.SpanExporter
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.