-
Notifications
You must be signed in to change notification settings - Fork 934
Prom exporter update #7934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jack-berg
merged 16 commits into
open-telemetry:main
from
zeitlinger:prom-exporter-update
Jan 8, 2026
+225
−85
Merged
Prom exporter update #7934
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
df3a644
update prom exporter settings
zeitlinger 2936c8b
update prom exporter settings
zeitlinger dbfdb10
update prom exporter settings
zeitlinger dd129e1
update prom exporter settings
zeitlinger 57c492b
update prom exporter settings
zeitlinger 22bc874
update prom exporter settings
zeitlinger c74c1a8
update prom exporter settings
zeitlinger 68e6207
add @CanIgnoreReturnValue
zeitlinger c63772e
rename
zeitlinger b13b64d
re-use PrometheusMetricReader
zeitlinger 10d21a7
fix
zeitlinger 9cff6a4
fix
zeitlinger c90bc2b
remove @CanIgnoreReturnValue
zeitlinger a4e8fdf
pr review
zeitlinger e78dc7e
pr review
zeitlinger 2030944
make getter package private
jack-berg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
68 changes: 68 additions & 0 deletions
68
...eus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusMetricReaderBuilder.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.prometheus; | ||
|
|
||
| import java.util.function.Predicate; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** Builder for {@link PrometheusMetricReader}. */ | ||
| public final class PrometheusMetricReaderBuilder { | ||
|
|
||
| private boolean otelScopeLabelsEnabled = true; | ||
| private boolean targetInfoMetricEnabled = true; | ||
| @Nullable private Predicate<String> allowedResourceAttributesFilter; | ||
|
|
||
| PrometheusMetricReaderBuilder() {} | ||
|
|
||
| PrometheusMetricReaderBuilder(PrometheusMetricReaderBuilder metricReaderBuilder) { | ||
| this.otelScopeLabelsEnabled = metricReaderBuilder.otelScopeLabelsEnabled; | ||
| this.targetInfoMetricEnabled = metricReaderBuilder.targetInfoMetricEnabled; | ||
| this.allowedResourceAttributesFilter = metricReaderBuilder.allowedResourceAttributesFilter; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether to add OpenTelemetry scope labels (otel_scope_name, otel_scope_version, etc.) to | ||
| * exported metrics. Default is {@code true}. | ||
| * | ||
| * @param otelScopeLabelsEnabled whether to add scope labels | ||
| * @return this builder | ||
| */ | ||
| public PrometheusMetricReaderBuilder setOtelScopeLabelsEnabled(boolean otelScopeLabelsEnabled) { | ||
| this.otelScopeLabelsEnabled = otelScopeLabelsEnabled; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether to export the target_info metric with resource attributes. Default is {@code | ||
| * true}. | ||
| * | ||
| * @param targetInfoMetricEnabled whether to export target_info metric | ||
| * @return this builder | ||
| */ | ||
| public PrometheusMetricReaderBuilder setTargetInfoMetricEnabled(boolean targetInfoMetricEnabled) { | ||
| this.targetInfoMetricEnabled = targetInfoMetricEnabled; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets a filter to control which resource attributes are added as labels on each exported metric. | ||
| * If {@code null}, no resource attributes will be added as labels. Default is {@code null}. | ||
| * | ||
| * @param allowedResourceAttributesFilter predicate to filter resource attributes, or {@code null} | ||
| * @return this builder | ||
| */ | ||
| public PrometheusMetricReaderBuilder setAllowedResourceAttributesFilter( | ||
| @Nullable Predicate<String> allowedResourceAttributesFilter) { | ||
| this.allowedResourceAttributesFilter = allowedResourceAttributesFilter; | ||
| return this; | ||
| } | ||
|
|
||
| /** Builds a new {@link PrometheusMetricReader}. */ | ||
| public PrometheusMetricReader build() { | ||
| return new PrometheusMetricReader( | ||
| allowedResourceAttributesFilter, otelScopeLabelsEnabled, targetInfoMetricEnabled); | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.