Skip to content

feat: support metric name filtering in OpenTelemetry exporter#2344

Open
subhramit wants to merge 1 commit into
prometheus:mainfrom
subhramit:otel-exporter-metric-filtering
Open

feat: support metric name filtering in OpenTelemetry exporter#2344
subhramit wants to merge 1 commit into
prometheus:mainfrom
subhramit:otel-exporter-metric-filtering

Conversation

@subhramit

@subhramit subhramit commented Jul 25, 2026

Copy link
Copy Markdown

Closes the last pending high-priority item in #1816 (as all others have already been addressed).

Currently, PrometheusMetricProducer always exported all metrics in the registry unconditionally. The code already had a TODO sketching how filtering could be added:

// Note: Currently all metrics from the registry are exported. To add metric filtering
// similar to the Servlet exporter, one could:
// 1. Add filter properties to ExporterOpenTelemetryProperties (allowedNames, excludedNames,
// etc.)
// 2. Convert these properties to a Predicate<String> using MetricNameFilter.builder()
// 3. Call registry.scrape(filter) instead of registry.scrape()
// OpenTelemetry also provides its own Views API for filtering and aggregation, which may be
// preferred for OpenTelemetry-specific deployments.

this PR implements that by reusing ExporterFilterProperties and MetricNameFilter, as already done by PrometheusScrapeHandler.

As a result, the OpenTelemetry exporter now honors the shared io.prometheus.exporter.filter.* configuration, making its behavior consistent with the HTTP/Servlet exporters.

Signed-off-by: subhramit <subhramit.bb@live.in>
@subhramit

Copy link
Copy Markdown
Author

cc @zeitlinger :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant