Documentation
¶
Index ¶
- Constants
- Variables
- func ClassifyCronError(raw any) string
- func ClassifyExitReason(raw, state any, restartRequested bool) *string
- func ClassifyGatewayError(raw any) string
- func CmdMonitoring(ctx context.Context, h string, ns map[string]any, w, errw io.Writer) (int, error)
- func Emit(event any)
- func EmitExecutionState(record map[string]any, deliveryOutcome *string)
- func EmitRuntimeStatusTransition(previous, current *pyjson.Object)
- func EnsureInstallID(ctx context.Context, cfg map[string]any) string
- func ExportBatch(provider *TracerProvider, batch []*pyjson.Object) int
- func IsOTLPEnabled(cfg map[string]any) bool
- func PlatformForSubsystem(subsystem string) *string
- func RedactBounded(raw any) string
- func RedactBoundedWith(raw any, limit int, empty, unavailable string) (out string)
- func RedactForExport(text any) (string, bool)
- func ResolveHeaders(headersEnv any) map[string]string
- func RuntimeResourceAttributes(cfg map[string]any, telemetryScope string) map[string]string
- func SafeResourceAttributes(raw any) map[string]string
- func SetCronHealthSources(s CronHealthSources)
- func SignalEndpoint(endpoint, signal string) string
- func SourceLoggerForExport(name any) *string
- func SpanAttrs(ev *pyjson.Object) map[string]any
- func SubsystemForLogger(loggerName string) string
- type BatchSpanProcessor
- type CronExecutionEvent
- type CronHealthSnapshot
- type CronHealthSources
- type CronJobHealth
- type EmitterStats
- type Event
- type GatewayDiagnosticEvent
- type GatewayDiagnosticLogHandler
- type GatewayDiagnosticLogStreamer
- type GatewayHealthEvent
- type GatewayHealthExportRuntime
- type GatewayHealthSnapshot
- type GatewayMetric
- type InMemorySpanExporter
- type MonitoringEmitter
- type OTLPHTTPSpanExporter
- type OTLPStreamer
- type Span
- type SpanExporter
- type Subscriber
- type Tracer
- type TracerProvider
Constants ¶
const OTelSDKModule = "go.opentelemetry.io/otel/sdk"
OTelSDKModule is the Go OpenTelemetry SDK module the exporter is linked against
RedactionUnavailable is what egress carries when the secret redactor itself fails
Variables ¶
var ( // Runtime status payload of the active gateway, assigned by the gateway package GatewayReadRuntimeStatus func() *pyjson.Object // Live background work counters, assigned by the tools package AsyncDelegationActiveTaskCount func() int AsyncDelegationActiveCount func() int ProcessRegistryCountRunning func() int )
var ( // Runtime status contract derivations, assigned by the gateway package GatewayDeriveBusy func(gatewayRunning bool, gatewayState, activeAgents any) (bool, error) GatewayDeriveDrainable func(gatewayRunning bool, gatewayState any) bool )
var GatewayParseActiveAgents func(raw any) (any, error)
Runtime status contract parse of active_agents, assigned by the gateway package
Functions ¶
func ClassifyCronError ¶
First matching error class of the lowered error text, auth by word boundary, unknown when none match
func ClassifyExitReason ¶
Bounded operational class of free form shutdown text, nil when there is no reason to classify
func ClassifyGatewayError ¶
Bounded class of free form gateway error text, unknown when no rule matches
func CmdMonitoring ¶
func CmdMonitoring(ctx context.Context, h string, ns map[string]any, w, errw io.Writer) (int, error)
Prints the gateway monitoring status
func EmitExecutionState ¶
Emits the lifecycle event of a record, flushing terminal states for up to a second, never failing the caller
func EmitRuntimeStatusTransition ¶
Emits content free gateway events for a runtime status change, failing open with a debug log
func EnsureInstallID ¶
Stable install id of the monitoring section, a fresh uuid minted and persisted to config.yaml when empty
func ExportBatch ¶
func ExportBatch(provider *TracerProvider, batch []*pyjson.Object) int
ExportBatch maps a batch of events to spans on the provider and returns how many it created
func IsOTLPEnabled ¶
IsOTLPEnabled reports an enabled export with an endpoint
func PlatformForSubsystem ¶
Platform named by a platform subsystem, nil for every other subsystem
func RedactBounded ¶
Redacted and length bounded text of a value with the default limit and markers
func RedactBoundedWith ¶
Redacted text of a falsy defaulted value cut to limit characters, empty and failure markers substituted
func RedactForExport ¶
Scrubs a value for egress, secrets first, then email, uuid and phone shapes, false for None
func ResolveHeaders ¶
ResolveHeaders maps header names to the values of the env vars named for them, unset vars skipped
func RuntimeResourceAttributes ¶
RuntimeResourceAttributes builds the safe OTLP resource shared by spans, metrics and diagnostic logs
func SafeResourceAttributes ¶
SafeResourceAttributes keeps allowlisted bounded resource labels, rejecting values redaction would change
func SetCronHealthSources ¶
func SetCronHealthSources(s CronHealthSources)
Installs the cron readers the health snapshot projects
func SignalEndpoint ¶
SignalEndpoint rewrites a traces or metrics OTLP path to the named signal, other paths passing through
func SourceLoggerForExport ¶
Bounded source controlled gateway logger name for the OTLP scope, nil for any other name
func SubsystemForLogger ¶
Subsystem of a gateway logger, the relay and each platform module named apart
Types ¶
type BatchSpanProcessor ¶
type BatchSpanProcessor struct {
// contains filtered or unexported fields
}
BatchSpanProcessor queues spans and exports them in bounded batches on a schedule, on flush and on shutdown
func NewBatchSpanProcessor ¶
func NewBatchSpanProcessor(exporter SpanExporter) *BatchSpanProcessor
NewBatchSpanProcessor wraps an exporter with the OpenTelemetry batch defaults
func (*BatchSpanProcessor) ForceFlush ¶
func (p *BatchSpanProcessor) ForceFlush()
ForceFlush exports everything queued before returning
func (*BatchSpanProcessor) OnEnd ¶
func (p *BatchSpanProcessor) OnEnd(span *Span)
Queues a finished span, dropping it when the queue is full
func (*BatchSpanProcessor) Shutdown ¶
func (p *BatchSpanProcessor) Shutdown()
Shutdown stops the schedule, drains the queue and shuts the exporter down
type CronExecutionEvent ¶
type CronExecutionEvent struct {
Status string
JobKey string
Source string
DurationMS *int64
DeliveryOutcome *string
ErrorClass *string
TsNS int64
}
CronExecutionEvent is a content free durable cron execution lifecycle projection
func NewCronExecutionEvent ¶
func NewCronExecutionEvent(status, jobKey string) CronExecutionEvent
Cron event with unknown source and the current nanosecond timestamp
func ProjectExecutionEvent ¶
func ProjectExecutionEvent(record map[string]any, deliveryOutcome *string) CronExecutionEvent
Content free event of a ledger record with opaque job key and bucketed status, source and outcome
func (CronExecutionEvent) ToDict ¶
func (e CronExecutionEvent) ToDict() *pyjson.Object
type CronHealthSnapshot ¶
type CronHealthSnapshot struct {
Metrics []GatewayMetric
Events []CronExecutionEvent
}
CronHealthSnapshot holds the cron gauges and the always empty event list of one snapshot
func BuildCronHealthSnapshot ¶
func BuildCronHealthSnapshot(ctx context.Context) CronHealthSnapshot
Scheduler freshness, job, running and store gauges with no events
type CronHealthSources ¶
type CronHealthSources struct {
Now func() time.Time
LoadJobs func(ctx context.Context) ([]CronJobHealth, error)
TickerHeartbeatAge func() (*float64, error)
TickerSuccessAge func() (*float64, error)
CatchUpOccurrenceCount func() (int, error)
RunningJobCount func() (int, error)
DegradedSkippedRuns func() ([]int, error)
}
CronHealthSources are the cron readers pkg/cron registers in init, each fail open on its own
type CronJobHealth ¶
CronJobHealth is the view of one stored job the overdue gauge reads
type EmitterStats ¶
type EmitterStats struct {
Queued, Dispatched, Dropped, Subscribers int
}
EmitterStats is the queued, dispatched, dropped and subscriber count snapshot
type Event ¶
Event is a typed monitoring event whose dict form leads with its event name in wire order
type GatewayDiagnosticEvent ¶
type GatewayDiagnosticEvent struct {
Name string
Subsystem string
ErrorClass string
ErrorCode *string
Platform *string
OldState *string
NewState *string
Profile *string
Version *string
Severity string
TsNS int64
SourceLogger *string
}
GatewayDiagnosticEvent is a redacted gateway diagnostic event for operator owned observability
func NewGatewayDiagnosticEvent ¶
func NewGatewayDiagnosticEvent(name, subsystem string) GatewayDiagnosticEvent
Diagnostic event with unknown class, warning severity and the current nanosecond timestamp
func (GatewayDiagnosticEvent) ToDict ¶
func (e GatewayDiagnosticEvent) ToDict() *pyjson.Object
type GatewayDiagnosticLogHandler ¶
GatewayDiagnosticLogHandler bridges gateway warning and error records into allowlisted diagnostic events
func NewGatewayDiagnosticLogHandler ¶
func NewGatewayDiagnosticLogHandler(profile, version string) *GatewayDiagnosticLogHandler
Warning level handler stamping each event with the given profile and version
func (*GatewayDiagnosticLogHandler) Close ¶
func (h *GatewayDiagnosticLogHandler) Close() error
func (*GatewayDiagnosticLogHandler) Handle ¶
Emits a diagnostic event for a gateway logger record at warning or above
func (*GatewayDiagnosticLogHandler) Level ¶
func (h *GatewayDiagnosticLogHandler) Level() int
type GatewayDiagnosticLogStreamer ¶
type GatewayDiagnosticLogStreamer struct {
// contains filtered or unexported fields
}
GatewayDiagnosticLogStreamer is the emitter subscriber sending gateway diagnostic events as OTLP logs
func (*GatewayDiagnosticLogStreamer) Call ¶
func (s *GatewayDiagnosticLogStreamer) Call(batch []*pyjson.Object)
Emits one log record per gateway diagnostic event of the batch, scoped by its source logger
func (*GatewayDiagnosticLogStreamer) Exported ¶
func (s *GatewayDiagnosticLogStreamer) Exported() int
Count of log records the streamer emitted
func (*GatewayDiagnosticLogStreamer) Shutdown ¶
func (s *GatewayDiagnosticLogStreamer) Shutdown()
Unsubscribes from the emitter, flushes queued records and shuts the processor down
type GatewayHealthEvent ¶
type GatewayHealthEvent struct {
Name string
GatewayState *string
OldState *string
NewState *string
ExitReason *string
RestartRequested *bool
ActiveAgents any
GatewayBusy bool
GatewayDrainable bool
PlatformCount int
FatalPlatformCount int
Profile *string
InstallID *string
Version *string
SupervisionMode *string
PID any
TsNS int64
}
GatewayHealthEvent is a content free gateway health snapshot or lifecycle event
func NewGatewayHealthEvent ¶
func NewGatewayHealthEvent(name string) GatewayHealthEvent
Health event with the dataclass defaults and the current nanosecond timestamp
func (GatewayHealthEvent) ToDict ¶
func (e GatewayHealthEvent) ToDict() *pyjson.Object
type GatewayHealthExportRuntime ¶
type GatewayHealthExportRuntime struct {
Enabled bool
Reason string
Streamer *OTLPStreamer
MetricProvider *sdkmetric.MeterProvider
LogHandler *GatewayDiagnosticLogHandler
LogStreamer *GatewayDiagnosticLogStreamer
// contains filtered or unexported fields
}
GatewayHealthExportRuntime owns the metric provider, streamers, log handler and snapshot loop of one export
func StartGatewayHealthExport ¶
func StartGatewayHealthExport(cfg map[string]any) *GatewayHealthExportRuntime
Starts the gateway health export the config enables, a disabled runtime with its reason otherwise
func (*GatewayHealthExportRuntime) Shutdown ¶
func (r *GatewayHealthExportRuntime) Shutdown()
Stops the snapshot loop, detaches the handler, drains the emitter and closes exporters within two seconds
type GatewayHealthSnapshot ¶
type GatewayHealthSnapshot struct {
Metrics []GatewayMetric
Events []Event
}
GatewayHealthSnapshot holds the gauges and events one runtime status read produces
func BuildGatewayHealthSnapshot ¶
func BuildGatewayHealthSnapshot(runtime *pyjson.Object, gatewayRunning bool, profile, installID, version, supervisionMode string) (GatewayHealthSnapshot, error)
Converts gateway_state.json compatible runtime state into service health gauges and events
type GatewayMetric ¶
GatewayMetric is one exported gauge with its value and string attributes
type InMemorySpanExporter ¶
type InMemorySpanExporter struct {
// contains filtered or unexported fields
}
InMemorySpanExporter keeps every exported span, the test double of the OTLP exporter
type MonitoringEmitter ¶
type MonitoringEmitter struct {
// contains filtered or unexported fields
}
MonitoringEmitter owns the bounded queue, the dispatcher goroutine and the subscriber list
func GetEmitter ¶
func GetEmitter() *MonitoringEmitter
Process wide emitter, created disabled until an exporter subscribes
func NewMonitoringEmitter ¶
func NewMonitoringEmitter(enabled bool) *MonitoringEmitter
Emitter that collects only while enabled
func (*MonitoringEmitter) Close ¶
func (e *MonitoringEmitter) Close()
Stops the dispatcher, waiting up to two seconds for it to exit
func (*MonitoringEmitter) Emit ¶
func (e *MonitoringEmitter) Emit(event any)
Enqueues an event without blocking or panicking, dropping the oldest entry when the queue is full
func (*MonitoringEmitter) Flush ¶
func (e *MonitoringEmitter) Flush(timeout float64)
Waits up to timeout seconds for queued and in flight batches to finish dispatch
func (*MonitoringEmitter) Stats ¶
func (e *MonitoringEmitter) Stats() EmitterStats
Queue depth, dispatched and dropped totals and subscriber count
func (*MonitoringEmitter) Subscribe ¶
func (e *MonitoringEmitter) Subscribe(cb *Subscriber)
Registers a live batch subscriber once and enables collection
func (*MonitoringEmitter) Unsubscribe ¶
func (e *MonitoringEmitter) Unsubscribe(cb *Subscriber)
Removes the first registration of a subscriber and disables collection when none remain
type OTLPHTTPSpanExporter ¶
type OTLPHTTPSpanExporter struct {
Endpoint string
Headers map[string]string
Client *http.Client
Resource map[string]string
}
OTLPHTTPSpanExporter posts spans to an OTLP/HTTP traces endpoint as JSON
func BuildExporter ¶
func BuildExporter(cfg map[string]any) (*OTLPHTTPSpanExporter, error)
BuildExporter constructs the OTLP span exporter the config names, an error without an endpoint
func NewOTLPHTTPSpanExporter ¶
func NewOTLPHTTPSpanExporter(endpoint string, headers map[string]string) *OTLPHTTPSpanExporter
NewOTLPHTTPSpanExporter targets the endpoint with the resolved headers and a ten second timeout
func (*OTLPHTTPSpanExporter) Export ¶
func (e *OTLPHTTPSpanExporter) Export(spans []*Span) error
Export posts one ExportTraceServiceRequest, a non 2xx status an error
func (*OTLPHTTPSpanExporter) Shutdown ¶
func (e *OTLPHTTPSpanExporter) Shutdown() error
type OTLPStreamer ¶
type OTLPStreamer struct {
// contains filtered or unexported fields
}
OTLPStreamer pushes each emitter batch to OTLP as spans, scoped to its plane by the event filter
func NewOTLPStreamer ¶
func NewOTLPStreamer(cfg map[string]any, eventFilter func(*pyjson.Object) bool) (*OTLPStreamer, error)
NewOTLPStreamer builds the provider the config names and the subscriber that exports every batch
func StartStreaming ¶
StartStreaming attaches a streamer to the singleton emitter when OTLP is enabled, nil otherwise or when the provider cannot build
func (*OTLPStreamer) Call ¶
func (s *OTLPStreamer) Call(batch []*pyjson.Object)
Call exports the batch after the filter, the emitter callable
func (*OTLPStreamer) Exported ¶
func (s *OTLPStreamer) Exported() int
Exported counts the spans the streamer created
func (*OTLPStreamer) Shutdown ¶
func (s *OTLPStreamer) Shutdown()
Shutdown unsubscribes from the singleton emitter, flushes the processor and shuts the provider down
func (*OTLPStreamer) Subscriber ¶
func (s *OTLPStreamer) Subscriber() *Subscriber
Subscriber is the emitter registration of this streamer
type Span ¶
type Span struct {
Name string
Attributes map[string]any
TraceID string
SpanID string
Start, End time.Time
}
Span is one finished monitoring span with its attributes
type SpanExporter ¶
SpanExporter receives finished spans in batches
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber receives dispatched batches on the dispatcher goroutine and is matched by identity
func NewSubscriber ¶
func NewSubscriber(fn func(batch []*pyjson.Object)) *Subscriber
Subscriber handle around a batch callback
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer records zero duration spans for monitoring events
type TracerProvider ¶
type TracerProvider struct {
// contains filtered or unexported fields
}
TracerProvider owns the resource and the processor every tracer records spans into
func NewTracerProvider ¶
func NewTracerProvider(resource map[string]string, processor *BatchSpanProcessor) *TracerProvider
NewTracerProvider pairs a resource with a batch processor
func (*TracerProvider) Resource ¶
func (tp *TracerProvider) Resource() map[string]string
Resource returns the provider's resource attributes
func (*TracerProvider) Shutdown ¶
func (tp *TracerProvider) Shutdown()
Shutdown drains the processor or the simple exporter
func (*TracerProvider) Tracer ¶
func (tp *TracerProvider) Tracer(scope string) *Tracer
Tracer returns a tracer recording spans under the instrumentation scope name