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

[SDK] Implement spec: MetricFilter #3235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IcySteam
Copy link

@IcySteam IcySteam commented Jan 9, 2025

Fixes #2447

Changes

This PR implements the MetricFilter spec in opentelemetry-cpp.

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
    • MetricProducer::MetricProducer
    • MetricCollector::MetricCollector
    • MeterContext::AddMetricReader
    • MeterProvider::AddMetricReader

@IcySteam IcySteam requested a review from a team as a code owner January 9, 2025 11:15
Copy link

linux-foundation-easycla bot commented Jan 9, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: IcySteam / name: IcySteam (de7b80e)

Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit de7b80e
🔍 Latest deploy log https://app.netlify.com/sites/opentelemetry-cpp-api-docs/deploys/6799b1ea440e6b00091c3375

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch 3 times, most recently from bbd4ca5 to 9e8e4b7 Compare January 9, 2025 11:54
@marcalff marcalff added the pr:waiting-on-cla Waiting on CLA label Jan 9, 2025
@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch 4 times, most recently from d6f5504 to 1473ebe Compare January 11, 2025 16:49
@marcalff
Copy link
Member

@IcySteam

Thanks for the PR.

Please remember to sign the EasyCLA, so this PR can be processed.

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch 3 times, most recently from e0d8498 to 9c3f930 Compare January 12, 2025 10:38
Copy link

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.87%. Comparing base (6603c3a) to head (de7b80e).

Files with missing lines Patch % Lines
sdk/src/metrics/state/metric_collector.cc 97.06% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3235      +/-   ##
==========================================
+ Coverage   87.80%   87.87%   +0.08%     
==========================================
  Files         198      199       +1     
  Lines        6324     6362      +38     
==========================================
+ Hits         5552     5590      +38     
  Misses        772      772              
Files with missing lines Coverage Δ
...e/opentelemetry/sdk/metrics/export/metric_filter.h 100.00% <100.00%> (ø)
...opentelemetry/sdk/metrics/export/metric_producer.h 100.00% <100.00%> (ø)
...opentelemetry/sdk/metrics/state/metric_collector.h 100.00% <ø> (ø)
sdk/src/metrics/meter_context.cc 76.06% <100.00%> (ø)
sdk/src/metrics/meter_provider.cc 86.85% <100.00%> (-0.33%) ⬇️
sdk/src/metrics/state/metric_collector.cc 91.53% <97.06%> (+4.43%) ⬆️

... and 1 file with indirect coverage changes

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch 3 times, most recently from a36ed14 to a4384fa Compare January 13, 2025 16:08
@marcalff marcalff removed the pr:waiting-on-cla Waiting on CLA label Jan 13, 2025
@lalitb
Copy link
Member

lalitb commented Jan 16, 2025

@IcySteam Thanks for the PR. I believe you are working to get the CLA signed, as the PR can't be reviewed without that.

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch from a4384fa to 4bff481 Compare January 17, 2025 18:45
@IcySteam
Copy link
Author

Thanks for the reminder @marcalff and @lalitb, CLA signing should be all done now.

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch from 4bff481 to 7b19eb4 Compare January 18, 2025 05:50
Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, and for signing the CLA.

Before looking in more details at the code,
please see some preliminary comments below.

There should be no changes in third_party/opentelemetry-proto.

Please make sure to initialize and update git submodules in your branch.

Please check the "include-what-you-use" build in CI for warnings,
and fix the code to resolve them.

There should be no more warnings in the PR compared to the main branch.

More comments to follow.

@marcalff marcalff self-assigned this Jan 22, 2025
@lalitb lalitb self-assigned this Jan 24, 2025
void AddMetricReader(std::shared_ptr<MetricReader> reader) noexcept;
std::shared_ptr<MetricCollector> AddMetricReader(
std::shared_ptr<MetricReader> reader,
std::unique_ptr<MetricFilter> metric_filter = nullptr) noexcept;
Copy link
Member

Choose a reason for hiding this comment

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

This was righty pointed out by @marcalff in community meeting - does this method need to return shared_ptr?

Copy link
Member

@lalitb lalitb Jan 29, 2025

Choose a reason for hiding this comment

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

@IcySteam It looks like you've now changed it to return a weak_ptr. Sorry I was not clear earlier, the question was—why does this method need to return anything at all?

Copy link
Author

@IcySteam IcySteam Feb 3, 2025

Choose a reason for hiding this comment

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

@lalitb Returning the MetricCollector created by the MeterContext does seem like one of the only few ways to access the MetricCollector, as it is needed by MetricCollectorTest. Extending MetricCollector with a test class is also potentially viable, but that would require changing some of MetricCollector's private members to protected (or a friend class). What are your thoughts on writing proper tests in this case?

@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch from 7b19eb4 to 72cbd97 Compare January 29, 2025 04:24
@IcySteam IcySteam force-pushed the otel-metricfilter-fn branch from 72cbd97 to de7b80e Compare January 29, 2025 04:43
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.

[SDK] Add predicate to MetricReader and MetricProducer
3 participants