Repository navigation
Add DB pool metrics and OpenTelemetry tracing - #1277
Merged
Merged
Conversation
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.
Add DB pool metrics and OpenTelemetry tracing
Summary
Adds two production observability pieces:
osctrl-apiandosctrl-tls.Tracing is disabled by default. The new metrics are only registered when the existing Prometheus listener is enabled.
Closes #1261.
Motivation
The previous observability work exposed HTTP and cache metrics, but operators still could not see:
Changes
Database pool metrics
Added
pkg/backend/metrics.gowith a scrape-time collector. It exposes:osctrl_db_pool_open_connectionsosctrl_db_pool_in_use_connectionsosctrl_db_pool_idle_connectionsosctrl_db_pool_max_open_connectionsosctrl_db_pool_wait_count_totalosctrl_db_pool_wait_duration_seconds_totalEach metric carries
role="primary"orrole="read"when a read replica is configured. The collector readssql.DB.Stats()at scrape time and adds no hot-path cost.Registered on both API and TLS Prometheus listeners.
OpenTelemetry tracing
Added
pkg/tracingwith:traceparentpropagationInstrumentation
Flusher,Hijacker,Pusher, andReaderFromfor SSE and downloadsConfiguration
YAML:
Flags:
Environment variables:
tracingEndpointacceptshost:portor a full URL. When empty, the exporter falls back to the standardOTEL_EXPORTER_OTLP_*environment variables.http://endpoints andtracingInsecure: truedisable exporter TLS.The sample ratio defaults to
0.1. An explicit0disables sampling.Both sample configs include the new section:
deploy/config/api.ymldeploy/config/tls.ymlDocumentation
ARCHITECTURE.md.README.md.Safety and privacy
unmatched.Dependencies
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp.go.sumupdated viago mod tidy.Tests
Validation
go test ./...— passed.git diff --check— clean.Follow-ups