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

METRICS SDK - Calling Observable Instruments callback during metrics collection #1554

Merged
merged 10 commits into from
Aug 15, 2022

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Aug 11, 2022

Fixes #1550, #1556

Changes

Please provide a brief description of the changes here.

  1. Create ObservableRegistry during Meter creation.
  2. Store the reference to ObservableRegistry while Instruments created from that Meter.
  3. During the collection (in Meter::Collect()), call all the registered callbacks once.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team August 11, 2022 00:56
@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Merging #1554 (7a46d43) into main (d04e1ce) will increase coverage by 1.64%.
The diff coverage is 54.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1554      +/-   ##
==========================================
+ Coverage   83.38%   85.02%   +1.64%     
==========================================
  Files         156      156              
  Lines        4975     4977       +2     
==========================================
+ Hits         4148     4231      +83     
+ Misses        827      746      -81     
Impacted Files Coverage Δ
sdk/src/metrics/meter.cc 33.08% <44.45%> (+28.28%) ⬆️
sdk/src/metrics/async_instruments.cc 80.00% <100.00%> (+26.67%) ⬆️
...etry/sdk/metrics/aggregation/default_aggregation.h 40.00% <0.00%> (+7.28%) ⬆️
sdk/src/metrics/meter_context.cc 57.15% <0.00%> (+14.29%) ⬆️
...telemetry/sdk/metrics/state/multi_metric_storage.h 80.00% <0.00%> (+23.34%) ⬆️
sdk/src/metrics/state/metric_collector.cc 76.00% <0.00%> (+28.00%) ⬆️
sdk/include/opentelemetry/sdk/metrics/view/view.h 100.00% <0.00%> (+36.37%) ⬆️
sdk/src/metrics/state/observable_registry.cc 57.15% <0.00%> (+42.86%) ⬆️

@esigo
Copy link
Member

esigo commented Aug 12, 2022

is this finished?

@lalitb
Copy link
Member Author

lalitb commented Aug 12, 2022

is this finished?

Yes changes are fine, as I tested with ostream exporter, I need to add unit test. Will be finishing it today.

@lalitb
Copy link
Member Author

lalitb commented Aug 12, 2022

is this finished?

Yes changes are fine, as I tested with ostream exporter, I need to add unit test. Will be finishing it today.

I have now added basic tests to validate the async flow, it should be good to review now.

@lalitb lalitb changed the title [WIP] - METRICS SDK - Calling Observable Instruments callback during metrics collection METRICS SDK - Calling Observable Instruments callback during metrics collection Aug 13, 2022
Copy link
Member

@esigo esigo left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for the fix.

@ThomsonTan ThomsonTan merged commit ad23f20 into open-telemetry:main Aug 15, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
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.

Nothing calls ObservableRegistry::Observe()
3 participants