-
Notifications
You must be signed in to change notification settings - Fork 506
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
Chore/metrics advanced #2204
Merged
cijothomas
merged 7 commits into
open-telemetry:main
from
pitoniak32:chore/metrics-advanced
Oct 14, 2024
Merged
Chore/metrics advanced #2204
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a37fbbf
chore: move DeltaTemporalitySelector into reader
pitoniak32 e84b182
example: update advanced metrics to use delta temporality
pitoniak32 8bb841a
Merge branch 'main' into chore/metrics-advanced
cijothomas 00161aa
Merge branch 'main' into chore/metrics-advanced
cijothomas ea76960
Merge branch 'main' into chore/metrics-advanced
cijothomas d3754eb
Merge branch 'main' into chore/metrics-advanced
cijothomas d28b42a
Merge branch 'main' into chore/metrics-advanced
cijothomas 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
metrics::{ | ||
data::{ResourceMetrics, Temporality}, | ||
exporter::PushMetricsExporter, | ||
reader::{DefaultTemporalitySelector, TemporalitySelector}, | ||
reader::{DefaultTemporalitySelector, DeltaTemporalitySelector, TemporalitySelector}, | ||
InstrumentKind, PeriodicReader, SdkMeterProvider, | ||
}, | ||
runtime::Runtime, | ||
|
@@ -169,7 +169,7 @@ | |
/// | ||
/// [exporter-docs]: https://github.com/open-telemetry/opentelemetry-specification/blob/a1c13d59bb7d0fb086df2b3e1eaec9df9efef6cc/specification/metrics/sdk_exporters/otlp.md#additional-configuration | ||
pub fn with_delta_temporality(self) -> Self { | ||
self.with_temporality_selector(DeltaTemporalitySelector) | ||
self.with_temporality_selector(DeltaTemporalitySelector::new()) | ||
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. the future of these methods in OTLP crate is unknown based on #1811 |
||
} | ||
} | ||
|
||
|
@@ -237,35 +237,6 @@ | |
} | ||
} | ||
|
||
/// A temporality selector that returns [`Delta`][Temporality::Delta] for all | ||
/// instruments except `UpDownCounter` and `ObservableUpDownCounter`. | ||
/// | ||
/// This temporality selector is equivalent to OTLP Metrics Exporter's | ||
/// `Delta` temporality preference (see [its documentation][exporter-docs]). | ||
/// | ||
/// [exporter-docs]: https://github.com/open-telemetry/opentelemetry-specification/blob/a1c13d59bb7d0fb086df2b3e1eaec9df9efef6cc/specification/metrics/sdk_exporters/otlp.md#additional-configuration | ||
#[derive(Debug)] | ||
struct DeltaTemporalitySelector; | ||
|
||
impl TemporalitySelector for DeltaTemporalitySelector { | ||
#[rustfmt::skip] | ||
fn temporality(&self, kind: InstrumentKind) -> Temporality { | ||
match kind { | ||
InstrumentKind::Counter | ||
| InstrumentKind::Histogram | ||
| InstrumentKind::ObservableCounter | ||
| InstrumentKind::Gauge | ||
| InstrumentKind::ObservableGauge => { | ||
Temporality::Delta | ||
} | ||
InstrumentKind::UpDownCounter | ||
| InstrumentKind::ObservableUpDownCounter => { | ||
Temporality::Cumulative | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// An interface for OTLP metrics clients | ||
#[async_trait] | ||
pub trait MetricsClient: fmt::Debug + Send + Sync + 'static { | ||
|
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
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.
While the concept is somewhat advanced, it is a common ask. Could you make this in the metrics-basic itself, as a code comment, so users can pick between delta vs cumulative by removing commented out code?
(It is possible that we'll have different ways to configure this in the future, but this change is still very good)