Release v1.0.0: HTTP instrumentation, slog correlation, TLS by default
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:
1 parent
362267470e
commit
2c83b28342
15 files changed
+695
-119
No files matched your search
@@ -4,16 +4,17 @@ Universal guide for AI coding agents working with this codebase.
|
||||
|
||||
## Overview
|
||||
|
||||
`git.codelab.vc/pkg/obsx` is a Go observability library providing Prometheus metrics and OpenTelemetry tracing setup with consistent defaults and isolated registries.
|
||||
`git.codelab.vc/pkg/obsx` is a Go observability library providing Prometheus metrics, OpenTelemetry tracing, trace-correlated slog logging and HTTP instrumentation with consistent defaults and isolated registries. The public API is stable (v1): do not break it.
|
||||
|
||||
## Package map
|
||||
|
||||
```
|
||||
obsx/ Root — tracing, metrics, config
|
||||
obsx/ Root — single package
|
||||
├── doc.go Package documentation
|
||||
├── tracer.go SetupTracer, StartSpan, TracerConfig
|
||||
├── metrics.go Metrics factory, NewMetrics, Counter/Histogram/Gauge, Handler
|
||||
└── config.go (empty — configs are co-located with their components)
|
||||
├── http.go HTTPMiddleware (server), HTTPTransport (client)
|
||||
└── log.go LogHandler (slog trace correlation)
|
||||
```
|
||||
|
||||
## Architecture
|
||||
@@ -65,8 +66,10 @@ obsx/ Root — tracing, metrics, config
|
||||
- **SetupTracer sets the global provider**: calling it multiple times overwrites the previous provider; the old provider is not shut down automatically
|
||||
- **Isolated registry**: `NewMetrics` creates its own `prometheus.Registry`, not the global default. Metrics registered here will not appear in `promhttp.Handler()` — use `m.Handler()` instead
|
||||
- **Sampler default**: if `TracerConfig.Sampler` is 0 or negative, it defaults to 1.0 (sample everything), not 0
|
||||
- **Insecure gRPC**: `SetupTracer` always uses `otlptracegrpc.WithInsecure()` — no TLS for the OTLP endpoint
|
||||
- **StartSpan tracer name**: uses the hardcoded tracer name `"obsx"` — all spans created via this helper share the same instrumentation scope
|
||||
- **TLS by default**: the OTLP connection is plaintext only with `TracerConfig.Insecure: true`
|
||||
- **Tracer name**: `StartSpan` and the HTTP instrumentation share the instrumentation scope `git.codelab.vc/pkg/obsx`
|
||||
- **HTTPMiddleware registers metrics**: calling it twice with the same `Metrics` panics (duplicate registration); the route label comes from `Request.Pattern`, so it must wrap the `http.ServeMux` directly
|
||||
- **LogHandler needs the context**: only `slog.*Context` calls get `trace_id` / `span_id`
|
||||
|
||||
## Commands
|
||||
|
||||
|
||||
Reference in new issue
Block a user