-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add option for resource attributes in metrics for prometheus exporter (…
…#4733) * add option for resource attributes in metrics for prometheus exporter This PR adds the `WithResourceAsConstantLabels` option to the Prometheus exporter to allow users to configure resource attributes to be applied on every metric. Fixes #4732 Signed-off-by: Alex Boten <aboten@lightstep.com> * add test, changelog Signed-off-by: Alex Boten <aboten@lightstep.com> * add test for including only a subset of tags, dont use a ptr Signed-off-by: Alex Boten <aboten@lightstep.com> * Update exporters/prometheus/config.go Co-authored-by: David Ashpole <dashpole@google.com> * include feedback from review Signed-off-by: Alex Boten <aboten@lightstep.com> * cache results Signed-off-by: Alex Boten <aboten@lightstep.com> * removed map in favour of single keyVals Signed-off-by: Alex Boten <aboten@lightstep.com> * Update exporters/prometheus/config.go Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * move check outside the createResourceAttributes and rename func Signed-off-by: Alex Boten <aboten@lightstep.com> --------- Signed-off-by: Alex Boten <aboten@lightstep.com> Co-authored-by: David Ashpole <dashpole@google.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
- Loading branch information
1 parent
0405492
commit 6027c1a
Showing
6 changed files
with
137 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
9 changes: 9 additions & 0 deletions
9
exporters/prometheus/testdata/with_allow_resource_attributes_filter.txt
This file contains 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,9 @@ | ||
# HELP foo_total a simple counter | ||
# TYPE foo_total counter | ||
foo_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0",service_name="prometheus_test"} 16.2 | ||
# HELP otel_scope_info Instrumentation Scope metadata | ||
# TYPE otel_scope_info gauge | ||
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1 | ||
# HELP target_info Target metadata | ||
# TYPE target_info gauge | ||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 |
9 changes: 9 additions & 0 deletions
9
exporters/prometheus/testdata/with_resource_attributes_filter.txt
This file contains 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,9 @@ | ||
# HELP foo_total a simple counter | ||
# TYPE foo_total counter | ||
foo_total{A="B",C="D",E="true",F="42",otel_scope_name="testmeter",otel_scope_version="v0.1.0",service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 24.9 | ||
# HELP otel_scope_info Instrumentation Scope metadata | ||
# TYPE otel_scope_info gauge | ||
otel_scope_info{otel_scope_name="testmeter",otel_scope_version="v0.1.0"} 1 | ||
# HELP target_info Target metadata | ||
# TYPE target_info gauge | ||
target_info{service_name="prometheus_test",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 |