tracing

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFromBytes

func ExtractFromBytes(data []byte) context.Context

ExtractFromBytes deserializes a 26-byte binary trace context and returns a Go context with the remote span context attached. Returns context.Background() if data is nil or malformed.

func Init

func Init(ctx context.Context, cfg Config) func(context.Context) error

Init sets up the global OTel TracerProvider. When Endpoint is empty it registers a no-op provider (zero overhead). Returns a shutdown function that must be called on process exit to flush pending spans.

func InjectIntoBytes

func InjectIntoBytes(ctx context.Context) []byte

InjectIntoBytes serializes the span context from ctx into a compact 26-byte binary representation. Returns nil if the span context is invalid.

func Tracer

func Tracer() trace.Tracer

Tracer returns the package-level tracer for swytch instrumentation.

Types

type Config

type Config struct {
	Endpoint    string // OTLP HTTP endpoint (e.g. http://localhost:4318). Empty = disabled.
	ServiceName string // OTel service name. Defaults to "swytch".
	NodeID      uint64 // Cluster node ID, added as a resource attribute.
	Insecure    bool   // Use HTTP instead of HTTPS for the OTLP endpoint.
}

Config holds OpenTelemetry tracing configuration.

type TracingHandler

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

TracingHandler wraps an slog.Handler to inject trace_id and span_id attributes from the context into every log record.

func NewTracingHandler

func NewTracingHandler(inner slog.Handler) *TracingHandler

NewTracingHandler creates a new TracingHandler wrapping the given handler.

func (*TracingHandler) Enabled

func (h *TracingHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*TracingHandler) Handle

func (h *TracingHandler) Handle(ctx context.Context, r slog.Record) error

func (*TracingHandler) WithAttrs

func (h *TracingHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*TracingHandler) WithGroup

func (h *TracingHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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