telemetry

package
v0.0.0-...-6a26c61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package telemetry provides observability via structured logging, metrics, and tracing.

Features: - Structured JSON logging via log/slog - Prometheus metrics on /metrics - OpenTelemetry spans - SIGIL_TELEMETRY=none disables all telemetry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceName string
	Enabled     bool
	LogWriter   io.Writer // For testing, defaults to os.Stdout
}

Config holds telemetry configuration.

type Span

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

Span wraps OpenTelemetry span.

func (*Span) End

func (s *Span) End()

End ends the span.

func (*Span) SetAttribute

func (s *Span) SetAttribute(key string, value interface{})

SetAttribute sets an attribute on the span.

type Telemetry

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

Telemetry manages observability across logging, metrics, and tracing.

func New

func New(config Config) *Telemetry

New creates a new telemetry instance.

Reads SIGIL_TELEMETRY environment variable: - "none" = disabled - anything else or unset = enabled

func (*Telemetry) IncrementChallengesCreated

func (t *Telemetry) IncrementChallengesCreated(actionType string)

IncrementChallengesCreated increments the challenge creation counter.

func (*Telemetry) IncrementChallengesVerified

func (t *Telemetry) IncrementChallengesVerified(actionType string, success bool)

IncrementChallengesVerified increments the challenge verification counter.

func (*Telemetry) IncrementMPARequests

func (t *Telemetry) IncrementMPARequests(actionType string)

IncrementMPARequests increments the MPA request counter.

func (*Telemetry) IsEnabled

func (t *Telemetry) IsEnabled() bool

IsEnabled returns true if telemetry is enabled.

func (*Telemetry) LogChallengeCreated

func (t *Telemetry) LogChallengeCreated(ctx context.Context, fields map[string]interface{})

LogChallengeCreated logs a challenge.created event per Knox §6.

func (*Telemetry) LogChallengeVerified

func (t *Telemetry) LogChallengeVerified(ctx context.Context, fields map[string]interface{})

LogChallengeVerified logs a challenge.verified event per Knox §6.

func (*Telemetry) LogMPAQuorumSatisfied

func (t *Telemetry) LogMPAQuorumSatisfied(ctx context.Context, fields map[string]interface{})

LogMPAQuorumSatisfied logs an mpa.quorum_satisfied event per Knox §6.

func (*Telemetry) LogMPARequest

func (t *Telemetry) LogMPARequest(ctx context.Context, fields map[string]interface{})

LogMPARequest logs an mpa.request event per Knox §6.

func (*Telemetry) MetricsHandler

func (t *Telemetry) MetricsHandler() http.Handler

MetricsHandler returns an HTTP handler for Prometheus /metrics endpoint.

func (*Telemetry) RecordChallengeVerifyDuration

func (t *Telemetry) RecordChallengeVerifyDuration(durationMs float64)

RecordChallengeVerifyDuration records challenge verification duration in milliseconds.

func (*Telemetry) RecordMPARequestDuration

func (t *Telemetry) RecordMPARequestDuration(durationMs float64)

RecordMPARequestDuration records MPA request duration in milliseconds.

func (*Telemetry) Shutdown

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the telemetry, flushing any pending traces.

func (*Telemetry) StartSpan

func (t *Telemetry) StartSpan(ctx context.Context, name string) (context.Context, *Span)

StartSpan starts a new OpenTelemetry span.

Returns context with span and the span itself. Caller must call span.End() when done.

Jump to

Keyboard shortcuts

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