-
Notifications
You must be signed in to change notification settings - Fork 479
[SDK] Implement spec: MetricFilter #3235
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
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
bbd4ca5
to
9e8e4b7
Compare
d6f5504
to
1473ebe
Compare
Thanks for the PR. Please remember to sign the EasyCLA, so this PR can be processed. |
e0d8498
to
9c3f930
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3235 +/- ##
==========================================
+ Coverage 89.41% 89.49% +0.08%
==========================================
Files 207 208 +1
Lines 6458 6497 +39
==========================================
+ Hits 5774 5814 +40
+ Misses 684 683 -1
🚀 New features to boost your workflow:
|
a36ed14
to
a4384fa
Compare
@IcySteam Thanks for the PR. I believe you are working to get the CLA signed, as the PR can't be reviewed without that. |
a4384fa
to
4bff481
Compare
4bff481
to
7b19eb4
Compare
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.
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.
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; |
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.
This was righty pointed out by @marcalff in community meeting - does this method need to return shared_ptr?
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.
@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?
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.
@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?
72cbd97
to
de7b80e
Compare
de7b80e
to
0421775
Compare
@lalitb Thanks for approving the CI workflows as always; for some reason, |
ca24682
to
0c944f1
Compare
Hi @lalitb, I've pushed another commit which uses a |
eea4047
to
8fa2622
Compare
8fa2622
to
8dd3291
Compare
8dd3291
to
085ad96
Compare
Hi @lalitb, I've resolved the merge conflicts from the latest upstream changes. Have you had the chance to review the PR yet? Thanks. |
085ad96
to
244f223
Compare
auto context = std::shared_ptr<MeterContext>(new MeterContext(ViewRegistryFactory::Create())); | ||
auto scope = InstrumentationScope::Create("CollectWithMetricFilterTestMetricTest1"); | ||
auto meter = std::shared_ptr<Meter>(new Meter(context, std::move(scope))); | ||
context->AddMeter(meter); |
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.
nit - there can be a helper method to create Meter, and used across tests.
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.
Thanks for the comment; since context
and meter
are directly needed by the test code below, creating a helper method here to create meter
might not simplify much. We could use a common meter
between test cases, but that would require us to make sure there are no duplicate instrument names. Do you think it would be better if we used a common meter
?
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.
Good point. I believe we can leave it as for now, and can improve later.
if (attributes_filter_result == MetricFilter::AttributesFilterResult::kAccept) | ||
{ | ||
filtered_point_data_attrs.emplace_back(std::move(point_data_attr)); | ||
} |
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.
Can we reuse the existing vector by filtering in-place?
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.
We could reuse the existing metric.point_data_attr_
here by deleting the filtered entries from it, but I think in this case it would be slower than creating a new vector and std::move
ing the wanted entries to it.
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.
Agree. This looks good.
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.
LGTM. Thanks for implementing this.
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.
LGTM, thanks for the feature.
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 changesMetricProducer::MetricProducer
MetricCollector::MetricCollector
MeterContext::AddMetricReader
MeterProvider::AddMetricReader