Release v1.0.0: HTTP instrumentation, slog correlation, TLS by default
CI / test (push) Successful in 1m17s
Publish / publish (push) Successful in 1m24s

Add HTTPMiddleware, HTTPTransport and LogHandler; extend TracerConfig with
Insecure, Headers and Attributes; install W3C propagators; parent-based
sampling; end-to-end OTLP export tests; update dependencies (Go 1.26).

Breaking since v0.2.0: the OTLP connection uses TLS unless Insecure is set.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Aleksey ShakhmatovandClaude committed 2026-11-10 20:20:09 +03:00
1 parent 362267470e
commit 2c83b28342
15 files changed
+695 -119

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package obsx
import (
"context"
"log/slog"
"go.opentelemetry.io/otel/trace"
)
// LogHandler wraps h so that records logged with a context carrying a span
// (slog.InfoContext and friends) get trace_id and span_id attributes,
// linking logs to traces.
func LogHandler(h slog.Handler) slog.Handler { return logHandler{h} }
type logHandler struct{ slog.Handler }
func (h logHandler) Handle(ctx context.Context, r slog.Record) error {
if sc := trace.SpanContextFromContext(ctx); sc.IsValid() {
r.AddAttrs(
slog.String("trace_id", sc.TraceID().String()),
slog.String("span_id", sc.SpanID().String()),
)
}
return h.Handler.Handle(ctx, r)
}
func (h logHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
return logHandler{h.Handler.WithAttrs(attrs)}
}
func (h logHandler) WithGroup(name string) slog.Handler {
return logHandler{h.Handler.WithGroup(name)}
}