Skip to content
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

New metrics SDK #1000

Merged
merged 19 commits into from
Mar 28, 2023
Merged

New metrics SDK #1000

merged 19 commits into from
Mar 28, 2023

Conversation

jtescher
Copy link
Member

This patch updates the metrics SDK to the latest spec. The following breaking changes are introduced.

Metrics API changes:

  • Move AttributeSet to SDK as it's not mentioned in the spec or used in the api
  • Consolidate AsyncCounter, AsyncUpDownCounter, and AsyncGauge into AsyncInstrument trait and add downcasting for observer callbacks.
  • Add AsyncInstrumentBuilder to allow per-instrument callback configuration.
  • Allow metric name and description fields to be Cow<'static, str>
  • Warn on metric misconfiguration when using instrument builder init rather than returning error
  • Update Meter::register_callback to take a list of async instruments and validate they are registered in the callback through the associated Observer
  • Allow registered callbacks to be unregistered.

Metrics SDK changes:

  • Introduce Scope as type alias for InstrumentationLibrary
  • Update Aggregation to match aggregation spec
  • Refactor BasicController to spec compliant ManualReader
  • Refactor PushController to spec compliant PeriodicReader
  • Update metric data fields to match spec, including exemplars.
  • Split MetricsExporter into Readers and PushMetricExporters
  • Add View implementation
  • Remove AtomicNumbers
  • Refactor Processors into Pipeline

Metrics exporter changes:

  • Update otlp exporter to match new metrics data
  • Update otlp exporter configuration to allow aggregation and temporality selectors to be optional.
  • Update prometheus exporter to match new metrics data

Example changes:

  • Update otlp metrics and prometheus examples.
  • Remove basic example as we should be focusing on the OTLP variants

Given the size of the changes I would have preferred to land them individually, but as they all rely on each other it was not practical.

Resolves #897

@jtescher jtescher requested a review from a team as a code owner March 19, 2023 04:49
@jtescher jtescher force-pushed the new-metrics branch 2 times, most recently from b04f672 to 970884a Compare March 19, 2023 05:30
This patch updates the metrics SDK to the latest spec. The following
breaking changes are introduced.

Metrics API changes:

* Move `AttributeSet` to SDK as it's not mentioned in the spec or used
  in the api
* Consolidate `AsyncCounter`, `AsyncUpDownCounter`, and `AsyncGauge`
  into `AsyncInstrument` trait and add downcasting for observer
callbacks.
* Add `AsyncInstrumentBuilder` to allow per-instrument callback
  configuration.
* Allow metric `name` and `description` fields to be `Cow<'static, str>`
* Warn on metric misconfiguration when using instrument builder `init`
  rather than returning error
* Update `Meter::register_callback` to take a list of async instruments
  and validate they are registered in the callback through the
associated `Observer`
* Allow registered callbacks to be unregistered.

Metrics SDK changes:

* Introduce `Scope` as type alias for `InstrumentationLibrary`
* Update `Aggregation` to match aggregation spec
* Refactor `BasicController` to spec compliant `ManualReader`
* Refactor `PushController` to spec compliant `PeriodicReader`
* Update metric data fields to match spec, including exemplars.
* Split `MetricsExporter` into `Reader`s and `PushMetricExporter`s
* Add `View` implementation
* Remove `AtomicNumber`s
* Refactor `Processor`s into `Pipeline`

Metrics exporter changes:

* Update otlp exporter to match new metrics data
* Update otlp exporter configuration to allow aggregation and
  temporality selectors to be optional.
* Update prometheus exporter to match new metrics data

Example changes:
* Update otlp metrics and prometheus examples.
* Remove basic example as we should be focusing on the OTLP variants
examples/basic-otlp/Cargo.toml Show resolved Hide resolved
opentelemetry-otlp/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@hdost hdost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work overall! Don't see any blockers, and I think anything that we missed on this go we can iterate on 😄

@TommyCpp
Copy link
Contributor

Sorry was little busy recently. I will finish reviewing this weekend if that's OK. Or we can merge this and address any issue in the followup PR. Overall great work 🎉

@hdost
Copy link
Contributor

hdost commented Mar 24, 2023

Sorry was little busy recently. I will finish reviewing this weekend if that's OK. Or we can merge this and address any issue in the followup PR. Overall great work tada

I guess I thought we were waiting until after 0.19.0 to merge this? Or are we just not releasing 0.19.0 😅

@TommyCpp
Copy link
Contributor

Sorry was little busy recently. I will finish reviewing this weekend if that's OK. Or we can merge this and address any issue in the followup PR. Overall great work tada

I guess I thought we were waiting until after 0.19.0 to merge this? Or are we just not releasing 0.19.0 😅

Haha yeah, we want to after 0.19. I was worried I will block others from merging the release PR and then this PR. I will #1002 today

# Conflicts:
#	opentelemetry-dynatrace/Cargo.toml
#	opentelemetry-otlp/Cargo.toml
#	opentelemetry-prometheus/Cargo.toml
Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits and can be addressed in follow-up PRs

opentelemetry-sdk/src/metrics/view.rs Outdated Show resolved Hide resolved
opentelemetry-api/src/metrics/meter.rs Show resolved Hide resolved
opentelemetry-api/src/metrics/meter.rs Outdated Show resolved Hide resolved
opentelemetry-api/src/metrics/meter.rs Outdated Show resolved Hide resolved
opentelemetry-prometheus/src/lib.rs Show resolved Hide resolved
opentelemetry-sdk/src/metrics/data/mod.rs Outdated Show resolved Hide resolved
opentelemetry-sdk/src/metrics/pipeline.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Patch coverage: 39.1% and project coverage change: -12.8 ⚠️

Comparison is base (879d6ff) 69.9% compared to head (0ea2e6d) 57.2%.

Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1000      +/-   ##
========================================
- Coverage   69.9%   57.2%   -12.8%     
========================================
  Files        116     143      +27     
  Lines       9027   17461    +8434     
========================================
+ Hits        6316    9999    +3683     
- Misses      2711    7462    +4751     
Impacted Files Coverage Δ
opentelemetry-api/src/lib.rs 100.0% <ø> (ø)
...entelemetry-api/src/metrics/instruments/counter.rs 30.3% <0.0%> (-19.7%) ⬇️
opentelemetry-api/src/metrics/instruments/gauge.rs 0.0% <0.0%> (-42.9%) ⬇️
...try-api/src/metrics/instruments/up_down_counter.rs 27.7% <0.0%> (-6.9%) ⬇️
opentelemetry-api/src/metrics/mod.rs 7.0% <0.0%> (-4.4%) ⬇️
opentelemetry-api/src/metrics/noop.rs 5.6% <0.0%> (-28.7%) ⬇️
opentelemetry-otlp/src/lib.rs 29.7% <ø> (ø)
opentelemetry-otlp/src/metric.rs 0.0% <0.0%> (ø)
opentelemetry-otlp/src/span.rs 34.9% <ø> (+34.9%) ⬆️
opentelemetry-otlp/src/transform/metrics.rs 0.0% <0.0%> (ø)
... and 29 more

... and 104 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jtescher
Copy link
Member Author

@TommyCpp any other comments or we good to merge?

@TommyCpp
Copy link
Contributor

@TommyCpp any other comments or we good to merge?

Nope good to merge. Great work!

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.

add view support
5 participants