-
Notifications
You must be signed in to change notification settings - Fork 440
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
Merged
esigo
merged 16 commits into
open-telemetry:main
from
esigo:metrics-context-circular-reference
Aug 11, 2022
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
aad1981
Fix metrics context circular reference
esigo e1d217d
Merge branch 'main' into metrics-context-circular-reference
esigo 266f757
Merge branch 'main' into metrics-context-circular-reference
esigo 61795b2
revert changes from main merge
esigo d1aa868
collector cannot have smart pointer to the context
esigo 4b8b3f1
fix CI
esigo 37fe3d1
context and storage null check
esigo 42473ab
revert unrelated change
esigo c7486c9
fix log messages
esigo f6afdb2
format
esigo 10c8f81
format
esigo 7ac22d7
revert unrelated change
esigo ecda02d
Merge branch 'main' into metrics-context-circular-reference
esigo 236672c
Merge branch 'main' into metrics-context-circular-reference
lalitb e7ee255
Merge branch 'main' into metrics-context-circular-reference
esigo a4052af
Merge branch 'main' into metrics-context-circular-reference
esigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ namespace metrics = opentelemetry::metrics; | |
namespace nostd = opentelemetry::nostd; | ||
|
||
Meter::Meter( | ||
std::shared_ptr<MeterContext> meter_context, | ||
std::weak_ptr<MeterContext> meter_context, | ||
std::unique_ptr<sdk::instrumentationscope::InstrumentationScope> instrumentation_scope) noexcept | ||
: scope_{std::move(instrumentation_scope)}, meter_context_{meter_context} | ||
{} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
auto view_registry = ctx->GetViewRegistry(); | ||
std::unique_ptr<WritableMetricStorage> storages(new MultiMetricStorage()); | ||
|
||
auto success = view_registry->FindViews( | ||
|
@@ -238,11 +239,11 @@ std::vector<MetricData> Meter::Collect(CollectorHandle *collector, | |
opentelemetry::common::SystemTimestamp collect_ts) noexcept | ||
{ | ||
std::vector<MetricData> metric_data_list; | ||
auto ctx = meter_context_.lock(); | ||
for (auto &metric_storage : storage_registry_) | ||
{ | ||
metric_storage.second->Collect(collector, meter_context_->GetCollectors(), | ||
meter_context_->GetSDKStartTime(), collect_ts, | ||
[&metric_data_list](MetricData metric_data) { | ||
metric_storage.second->Collect(collector, ctx->GetCollectors(), ctx->GetSDKStartTime(), | ||
collect_ts, [&metric_data_list](MetricData metric_data) { | ||
metric_data_list.push_back(metric_data); | ||
return true; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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