-
Notifications
You must be signed in to change notification settings - Fork 661
Implement scope_info_enabled #3503
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
Open
ArthurSens
wants to merge
1
commit into
open-telemetry:main
Choose a base branch
from
ArthurSens:prometheus-scope-labels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,18 +6,32 @@ use std::sync::{Arc, Mutex}; | |
| use crate::{Collector, PrometheusExporter, ResourceSelector}; | ||
|
|
||
| /// [PrometheusExporter] configuration options | ||
| #[derive(Default)] | ||
| pub struct ExporterBuilder { | ||
| registry: Option<prometheus::Registry>, | ||
| disable_target_info: bool, | ||
| without_units: bool, | ||
| without_counter_suffixes: bool, | ||
| namespace: Option<String>, | ||
| disable_scope_info: bool, | ||
| scope_info_enabled: bool, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ :) |
||
| reader: ManualReaderBuilder, | ||
| resource_selector: ResourceSelector, | ||
| } | ||
|
|
||
| impl Default for ExporterBuilder { | ||
| fn default() -> Self { | ||
| ExporterBuilder { | ||
| registry: None, | ||
| disable_target_info: false, | ||
| without_units: false, | ||
| without_counter_suffixes: false, | ||
| namespace: None, | ||
| scope_info_enabled: true, | ||
| reader: ManualReaderBuilder::default(), | ||
| resource_selector: ResourceSelector::default(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl fmt::Debug for ExporterBuilder { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| f.debug_struct("ExporterBuilder") | ||
|
|
@@ -26,7 +40,7 @@ impl fmt::Debug for ExporterBuilder { | |
| .field("without_units", &self.without_units) | ||
| .field("without_counter_suffixes", &self.without_counter_suffixes) | ||
| .field("namespace", &self.namespace) | ||
| .field("disable_scope_info", &self.disable_scope_info) | ||
| .field("scope_info_enabled", &self.scope_info_enabled) | ||
| .finish() | ||
| } | ||
| } | ||
|
|
@@ -66,20 +80,27 @@ impl ExporterBuilder { | |
| self | ||
| } | ||
|
|
||
| /// Configures the exporter to not export the `otel_scope_info` metric. | ||
| /// Configures whether to export instrumentation scope labels on metric points. | ||
| /// | ||
| /// If not specified, scope info is enabled and the exporter adds | ||
| /// `otel_scope_*` labels to all metric points. | ||
| pub fn scope_info_enabled(mut self, enabled: bool) -> Self { | ||
| self.scope_info_enabled = enabled; | ||
| self | ||
| } | ||
|
|
||
| /// Configures the exporter to not export instrumentation scope labels on metric points. | ||
| /// | ||
| /// If not specified, the exporter will create a `otel_scope_info` metric | ||
| /// containing the metrics' Instrumentation Scope, and also add labels about | ||
| /// Instrumentation Scope to all metric points. | ||
| /// Deprecated: use [`scope_info_enabled(false)`](Self::scope_info_enabled) instead. | ||
| pub fn without_scope_info(mut self) -> Self { | ||
| self.disable_scope_info = true; | ||
| self.scope_info_enabled = false; | ||
| self | ||
| } | ||
|
Comment on lines
95
to
98
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept the function just for backwards compatibility, but happy to remove it it isn't needed |
||
|
|
||
| /// Configures the exporter to prefix metrics with the given namespace. | ||
| /// | ||
| /// Metrics such as `target_info` and `otel_scope_info` are not prefixed since | ||
| /// these have special behavior based on their name. | ||
| /// Metrics such as `target_info` are not prefixed since these have special | ||
| /// behavior based on their name. | ||
| pub fn with_namespace(mut self, namespace: impl Into<String>) -> Self { | ||
| let mut namespace = namespace.into(); | ||
|
|
||
|
|
@@ -123,7 +144,7 @@ impl ExporterBuilder { | |
| disable_target_info: self.disable_target_info, | ||
| without_units: self.without_units, | ||
| without_counter_suffixes: self.without_counter_suffixes, | ||
| disable_scope_info: self.disable_scope_info, | ||
| scope_info_enabled: self.scope_info_enabled, | ||
| create_target_info_once: OnceCell::new(), | ||
| namespace: self.namespace, | ||
| inner: Mutex::new(Default::default()), | ||
|
|
||
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
8 changes: 2 additions & 6 deletions
8
opentelemetry-prometheus/tests/data/conflict_help_two_counters_1.txt
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 |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| # HELP bar_bytes_total meter a bar | ||
| # TYPE bar_bytes_total counter | ||
| bar_bytes_total{type="bar",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 | ||
| bar_bytes_total{type="bar",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 | ||
| # HELP otel_scope_info Instrumentation Scope metadata | ||
| # TYPE otel_scope_info gauge | ||
| otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 | ||
| otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 | ||
| bar_bytes_total{type="bar",otel_scope_name="ma",otel_scope_version="v0.1.0",otel_scope_schema_url="https://opentelemetry.io/schemas/1.0.0",otel_scope_k="v"} 100 | ||
| bar_bytes_total{type="bar",otel_scope_name="mb",otel_scope_version="v0.1.0",otel_scope_schema_url="https://opentelemetry.io/schemas/1.0.0",otel_scope_k="v"} 100 | ||
| # HELP target_info Target metadata | ||
| # TYPE target_info gauge | ||
| target_info{service_name="prometheus_test",telemetry_sdk_language="rust",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 |
8 changes: 2 additions & 6 deletions
8
opentelemetry-prometheus/tests/data/conflict_help_two_counters_2.txt
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 |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| # HELP bar_bytes_total meter b bar | ||
| # TYPE bar_bytes_total counter | ||
| bar_bytes_total{type="bar",otel_scope_name="ma",otel_scope_version="v0.1.0"} 100 | ||
| bar_bytes_total{type="bar",otel_scope_name="mb",otel_scope_version="v0.1.0"} 100 | ||
| # HELP otel_scope_info Instrumentation Scope metadata | ||
| # TYPE otel_scope_info gauge | ||
| otel_scope_info{otel_scope_name="ma",otel_scope_version="v0.1.0"} 1 | ||
| otel_scope_info{otel_scope_name="mb",otel_scope_version="v0.1.0"} 1 | ||
| bar_bytes_total{type="bar",otel_scope_name="ma",otel_scope_version="v0.1.0",otel_scope_schema_url="https://opentelemetry.io/schemas/1.0.0",otel_scope_k="v"} 100 | ||
| bar_bytes_total{type="bar",otel_scope_name="mb",otel_scope_version="v0.1.0",otel_scope_schema_url="https://opentelemetry.io/schemas/1.0.0",otel_scope_k="v"} 100 | ||
| # HELP target_info Target metadata | ||
| # TYPE target_info gauge | ||
| target_info{service_name="prometheus_test",telemetry_sdk_language="rust",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="latest"} 1 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't understand why the LLM decided to add this here lol. I tried doing some research, but it seems way beyond my Rust knowledge