-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Is your feature request related to a problem? Please describe.
I need all server-side HTTP metrics (for example, http.server.request.duration) to include certain request headers (like X-Tenant-Id or X-Env) as metric attributes.
Currently, these headers can only be captured as span attributes using OTEL_INSTRUMENTATION_HTTP_SERVER_CAPTURE_REQUEST_HEADERS, but they are not propagated to the corresponding metrics produced by the agent.
Without these attributes, it’s impossible to filter or group request metrics per tenant, environment, or user domain.
Describe the solution you'd like
Introduce an environment variable or configuration option similar to
OTEL_INSTRUMENTATION_HTTP_SERVER_CAPTURE_REQUEST_HEADERS,
for example:
OTEL_INSTRUMENTATION_HTTP_SERVER_METRICS_CAPTURE_HEADERS=x-tenant-id,x-skd-version
This setting would copy the captured request header values into the metric attributes of the automatically generated HTTP server metrics (e.g., http.server.request.duration, http.server.active_requests, etc.).
The implementation should sanitize and lower-case header names and handle cardinality limits safely.
Describe alternatives you've considered
- Deriving metrics from spans using the Collector
spanmetricsconnector.
This works but adds deployment complexity and duplicate metric names. - Emitting a custom
http.server.request.durationmetric in application code, which duplicates logic already handled by the agent.
Additional context
Having these headers as attributes on built-in HTTP metrics would allow consistent per-tenant, per-version, or per-xxx filtering in metric backends like Prometheus, Grafana Cloud, or Datadog, without extra Collector configuration.
Tip[/+]
[+]React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.