tracing, metric, log, otel: complete native OpenTelemetry support for traces, metrics and logs#1408
Draft
applike-ss wants to merge 1 commit into
Draft
tracing, metric, log, otel: complete native OpenTelemetry support for traces, metrics and logs#1408applike-ss wants to merge 1 commit into
applike-ss wants to merge 1 commit into
Conversation
a88cbd7 to
a2b398e
Compare
- Add shared OTel core (pkg/otel): resource builder, OTLP exporters (gRPC/HTTP), TLS/mTLS, per-signal URL paths, retry, shutdown registry - Add OTel trace provider (tracing.otel exporter) with batch span processor - Add OTel metric writer with PeriodicReader - Add OTel log handler with BatchProcessor - Add graceful shutdown middleware for all OTel providers - Add OTel collector integration test component - Extract shared handlerBase in pkg/log - Isolate per-run configuration in test/suite
a2b398e to
b57b2a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the switch to native OpenTelemetry in gosoline for traces, metrics, and logs, emitting into an OTEL Collector → gateway → ClickHouse (ClickStack) pipeline. Everything is configurable through the native gosoline
cfgsystem. Transport is OTLP/gRPC by default with TLS/mTLS support; the existing Prometheus pull path is left unchanged.Relates to justtrack/devops/tickets#961 (native OTEL ingestion) and #962 (OTEL metric naming).
What's included
Shared core — new
pkg/otelBuildResourcederives the OTEL resource (service.name,service.namespace,deployment.environment, plus configurable attributes) from the app identity, so all three signals share identical resource attributes for correlation.BuildTraceExporter/BuildMetricExporter/BuildLogExporter: OTLP gRPC/HTTP exporter builders with gzip, headers, retry, and TLS/mTLS.ExporterSettingssplitshost/port(with optional fullendpointoverride) so the node IP can be injected from pod metadata (status.hostIP);Address()composes vianet.JoinHostPort.Traces (
pkg/tracing)otel_grpcandstdoutspan exporters; the exporter registry now returnssdktrace.SpanExporter.tracecontext,baggage).otel_http(config undertracing.otel.http.*) kept for back-compat.Metrics (
pkg/metric) — bridge, not rewriteotelwriter (WriterTypeOtel) bridges the existingDatumpipeline to an OTELMeterProvider+ OTLP exporter via aPeriodicReader.Kind→instrument (counter/gauge/histogram) and CloudWatch unit→UCUM mapping. Identity goes to resource attributes;Dimensionsbecome metric attributes.cloudwatch/prometheuswriters (operator picks viametric.writers). Existing Prometheus writer/pull endpoint unchanged.Metric naming (#962)
FormatOtelMetricNameenforces lowercase, dot-delimited, snake_case-within-segment names;ToUcumUnitmaps units. Identity and units are not part of the name (units live on the instrument; identity in resource attributes).Logs (
pkg/log)otellog handler bridges to the OTEL Logs SDK (BatchProcessor+ OTLP exporter). Level→severity and field→attribute mapping; trace/span context is attached fromctxfor trace↔log correlation.Docs & example
pkg/otel/AGENTS.md, updatedpkg/tracing/AGENTS.md, andexamples/otel/config.dist.ymlshowing all three signals.Resilience notes
OTLP exporters use background processors with bounded queues — the hot path only enqueues and never blocks on network I/O. On collector outage they retry/backoff then drop (lost telemetry, never app instability). Recommended deployment: push to a node-local collector agent that buffers/retries to the gateway.
Testing
go build ./...clean.go vetclean on changed packages.go test ./pkg/otel/ ./pkg/metric/ ./pkg/tracing/ ./pkg/log/pass.Address()(host/port/endpoint, IPv6), resource builder (identity → attributes).golangci-lintclean on all new code (2 remaining findings are pre-existing in untouched files).Follow-ups / not in scope
🤖 Draft — opened for review.