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

+8 -4
View File
@@ -12,14 +12,17 @@ go vet ./... # static analysis
## Architecture
- **Module**: `git.codelab.vc/pkg/obsx`, Go 1.25.7, depends on OpenTelemetry and Prometheus client_golang
- **Module**: `git.codelab.vc/pkg/obsx`, Go 1.26, depends on OpenTelemetry and Prometheus client_golang
- **Single package** `obsx`
### Core patterns
- **SetupTracer** — creates OTLP gRPC exporter, builds `sdktrace.TracerProvider` with batcher and ratio sampler, sets it as global `otel.TracerProvider`
- **StartSpan** — convenience function using `otel.Tracer("obsx")` to start spans via the global provider
- **TracerConfig** — service name, version, OTLP endpoint, sampling ratio; `defaults()` sets `Sampler` to 1.0 if unset
- **SetupTracer** — creates OTLP gRPC exporter (TLS unless `Insecure`), builds `sdktrace.TracerProvider` with batcher and parent-based ratio sampler, sets it and W3C propagators as OpenTelemetry globals
- **StartSpan** — convenience function starting spans via the global provider
- **TracerConfig** — service name, version, OTLP endpoint, insecure, headers, sampling ratio, resource attributes; `defaults()` sets `Sampler` to 1.0 if unset
- **HTTPMiddleware** — server span + `http_requests_total` / `http_request_duration_seconds` per request; route label from `Request.Pattern`
- **HTTPTransport** — `http.RoundTripper` with client spans and trace context injection
- **LogHandler** — `slog.Handler` wrapper adding `trace_id` / `span_id`
- **Metrics** — factory that creates Prometheus `CounterVec`, `HistogramVec`, `GaugeVec` with consistent namespace/subsystem
- **NewMetrics** — creates an isolated `prometheus.Registry` pre-loaded with process and Go collectors
- **Handler()** — returns `promhttp.HandlerFor` using the isolated registry
@@ -36,6 +39,7 @@ go vet ./... # static analysis
- Isolated Prometheus registry — not the global default, avoids conflicts in tests and multi-tenant setups
- `nil` buckets in `Histogram()` defaults to `prometheus.DefBuckets`
- No functional options — direct struct configuration only
- Public API is stable since v1.0.0 — no breaking changes; record changes in `CHANGELOG.md`
## See also