-
Notifications
You must be signed in to change notification settings - Fork 438
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
Fix metrics context circular reference #1535
Fix metrics context circular reference #1535
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1535 +/- ##
==========================================
- Coverage 83.85% 83.28% -0.56%
==========================================
Files 156 156
Lines 4908 4970 +62
==========================================
+ Hits 4115 4139 +24
- Misses 793 831 +38
|
@esigo - I have gone through the circular reference between |
@@ -135,7 +135,8 @@ class Meter final : public opentelemetry::metrics::Meter | |||
void *), | |||
void *state = nullptr) | |||
{ | |||
auto view_registry = meter_context_->GetViewRegistry(); | |||
auto ctx = meter_context_.lock(); |
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.
Should we be checking if the ctx
is valid here?
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.
makes sense. Shall we log something too?
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.
yes, I think we should log here if meter context is no more valid.
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.
done
sdk/src/metrics/meter.cc
Outdated
@@ -201,7 +201,8 @@ const sdk::instrumentationscope::InstrumentationScope *Meter::GetInstrumentation | |||
std::unique_ptr<WritableMetricStorage> Meter::RegisterMetricStorage( | |||
InstrumentDescriptor &instrument_descriptor) | |||
{ | |||
auto view_registry = meter_context_->GetViewRegistry(); | |||
auto ctx = meter_context_.lock(); |
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.
Check if ctx
is valid here before using?
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.
done
Fixes #1534 (issue)
Changes
removed the cycles by using a
wrak_ptr
to the context inmeter
. Alsometer_collector
can't haveweak_ptr
to the context so I used raw pointer.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes