seqotel

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 7 Imported by: 0

README

Release Go Version Go Reference Go Report License

seqotel

OpenTelemetry integration for slog-seq.

See the main README for documentation and examples.

Installation

go get github.com/desertwitch/slog-seq/seqotel

License

MIT

Documentation

Overview

Package seqotel provides OpenTelemetry integration for slog-seq, including automatic trace context enrichment for slog events and a SpanProcessor that forwards completed spans to Seq as CLEF events.

Use NewSeqOTelHandler to create a handler with trace correlation enabled:

handler := seqotel.NewSeqOTelHandler("http://seq:5341/ingest/clef",
	slogseq.WithAPIKey("your-api-key"),
	slogseq.WithBatchSize(50),
)
defer handler.Close()
slog.SetDefault(slog.New(handler))

Use NewLoggingSpanProcessor to forward spans to Seq:

processor := seqotel.NewLoggingSpanProcessor(handler)
tp := trace.NewTracerProvider(trace.WithSpanProcessor(processor))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoggingSpanProcessor

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

LoggingSpanProcessor is an OpenTelemetry trace.SpanProcessor and trace.SpanExporter that converts completed spans and their events into CLEF events and dispatches them to Seq via a SeqOTelHandler.

Span events are emitted before the span itself to preserve chronological ordering. The processor does not manage the handler's lifecycle - the caller is responsible for closing the handler.

func NewLoggingSpanProcessor

func NewLoggingSpanProcessor(handler *SeqOTelHandler) *LoggingSpanProcessor

NewLoggingSpanProcessor creates a LoggingSpanProcessor that forwards completed spans to Seq via the given SeqOTelHandler.

func (*LoggingSpanProcessor) ExportSpans

func (p *LoggingSpanProcessor) ExportSpans(_ context.Context, spans []trace.ReadOnlySpan) error

ExportSpans converts a batch of completed spans and their events into CLEF events and dispatches them to the handler. This method satisfies the trace.SpanExporter interface.

func (*LoggingSpanProcessor) ForceFlush

func (p *LoggingSpanProcessor) ForceFlush(_ context.Context) error

ForceFlush is a no-op. Events are flushed on the configured interval and fully drained when the handler is closed.

func (*LoggingSpanProcessor) OnEnd

OnEnd converts a completed span and its events into CLEF events and dispatches them to the handler. Span events are emitted first, followed by the span itself.

func (*LoggingSpanProcessor) OnStart

OnStart is a no-op. This processor only acts on completed spans.

func (*LoggingSpanProcessor) Shutdown

func (p *LoggingSpanProcessor) Shutdown(_ context.Context) error

Shutdown is a no-op. The handler's lifecycle is managed by the caller who created it, not by the span processor.

type SeqOTelHandler

type SeqOTelHandler struct {
	*slogseq.SeqHandler
}

SeqOTelHandler is a slog.Handler extending slogseq.SeqHandler with OpenTelemetry trace context enrichment.

Create one using NewSeqOTelHandler. Do not construct directly.

func NewLogger

func NewLogger(seqURL string, opts ...slogseq.SeqOption) (*slog.Logger, *SeqOTelHandler)

NewLogger is a convenience function that creates a SeqOTelHandler and wraps it in an slog.Logger. Refer to NewSeqOTelHandler for teardown information.

func NewSeqOTelHandler

func NewSeqOTelHandler(seqURL string, opts ...slogseq.SeqOption) *SeqOTelHandler

NewSeqOTelHandler creates and starts a new SeqOTelHandler with OpenTelemetry trace context enrichment enabled. Log events are automatically correlated with active spans. Derived handlers (via WithAttrs and WithGroup) share the same workers and connection. Close must be called on the original handler when no longer needed, rendering all (sub-)handlers unusable.

See slogseq package documentation for all possible slogseq.SeqOption.

Jump to

Keyboard shortcuts

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