telemetry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 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 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 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 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 WithPluginProfile

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

WithPluginProfile wraps fn with Pyroscope labels identifying the plugin.

Types

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

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

	WailsCallDuration metric.Float64Histogram
	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 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 TelemetryConfig, version, commit, date string, isDev bool) *Service

New creates a telemetry Service. Call Init to start it.

func (*Service) ApplyConfig

func (s *Service) ApplyConfig(ctx context.Context, cfg TelemetryConfig) 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) Config

func (s *Service) Config() TelemetryConfig

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) 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) 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 TelemetryConfig

type TelemetryConfig struct {
	Enabled           bool
	Traces            bool
	Metrics           bool
	LogsShip          bool
	LogsShipLevel     string
	Profiling         bool
	OTLPEndpoint      string
	PyroscopeEndpoint string
	AuthHeader        string
	AuthValue         string
}

TelemetryConfig 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) TelemetryConfig

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