Documentation ¶
Overview ¶
Package otelhandler shows a slog.Handler wrapper that adds extra attributes to log statements.
Example ¶
package main import ( "context" "log/slog" "os" "github.com/vikstrous/slogexamples/otelhandler" ) func main() { ctx := context.Background() sl := slog.New(otelhandler.NewOtelHandler(slog.NewTextHandler(os.Stderr, nil))) sl.InfoContext(ctx, "example") }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OtelHandler ¶
OtelHandler adds extra fields to the record being logged containing traceID and spanID so that logs can be correlated with traces
func NewOtelHandler ¶
func NewOtelHandler(h slog.Handler) OtelHandler
Click to show internal directories.
Click to hide internal directories.