Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

proxy.golang.org : github.com/vincentfree/opentelemetry/otelslog

Package otelslog provides a function to extend structured logs using slog with the Open Telemetry trace related context. Currently, slog is offered through golang.org/x/exp/slog slog.Logger is decorated with standard metadata extracted from the trace.SpanContext, a traceID, spanID and additional information is injected into a log. The initialization uses file level variable configuration to set defaults for the functions to use. SetLogOptions can overwrite the defaults. When the configuration is done AddTracingContext and AddTracingContextWithAttributes decorate slog logs with data from the trace context. To add trace context data to logging, the context can be passed by using slog.LogAttrs(nil, slog.LevelInfo, "this is a log", otelslog.AddTracingContext(span)...) for example. The use of slog.LogAttrs is advised due to AddTracingContext and AddTracingContextWithAttributes returning []slog.Attr which slog.LogAttrs accepts as a type. Other functions accept ...any which in my tests resulted in !BADKEY entries. Next to using native slog, this package also offers a Logger which extends the slog.Logger with its own functions to simplify working with slog.Logger's. The Logger can be used as follows: Functions Types Structs import "github.com/vincentfree/opentelemetry/otelslog"

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/vincentfree/opentelemetry/otelslog
Keywords: logging, logs, middleware, opentelemetry, opentelemetry-go, traces, tracing
License: Apache-2.0
Latest release: 9 months ago
First release: 10 months ago
Namespace: github.com/vincentfree/opentelemetry
Stars: 2 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 18 days ago

    Loading...
    Readme
    Loading...