-
Notifications
You must be signed in to change notification settings - Fork 5.3k
stats: Shared scopes phase 1, changes scope APIs to use ScopeSharedPtr, leaving ScopePtr alias behind #19791
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
Changes from all commits
dfac8eb
fa3229e
80a85ac
f3b90e7
a0782ea
6e81807
10c6ce3
b87e4d3
3e6e71d
1e54c9d
b7516cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,7 @@ class IsolatedStoreImpl : public StoreImpl { | |
| public: | ||
| IsolatedStoreImpl(); | ||
| explicit IsolatedStoreImpl(SymbolTable& symbol_table); | ||
| ~IsolatedStoreImpl() override; | ||
|
|
||
| // Stats::Scope | ||
| Counter& counterFromStatNameWithTags(const StatName& name, | ||
|
|
@@ -140,8 +141,8 @@ class IsolatedStoreImpl : public StoreImpl { | |
| Counter& counter = counters_.get(joiner.nameWithTags()); | ||
| return counter; | ||
| } | ||
| ScopePtr createScope(const std::string& name) override; | ||
| ScopePtr scopeFromStatName(StatName name) override; | ||
| ScopeSharedPtr createScope(const std::string& name) override; | ||
| ScopeSharedPtr scopeFromStatName(StatName name) override; | ||
| void deliverHistogramToSinks(const Histogram&, uint64_t) override {} | ||
| Gauge& gaugeFromStatNameWithTags(const StatName& name, StatNameTagVectorOptConstRef tags, | ||
| Gauge::ImportMode import_mode) override { | ||
|
|
@@ -234,10 +235,12 @@ class IsolatedStoreImpl : public StoreImpl { | |
|
|
||
| void forEachScope(SizeFn f_size, StatFn<const Scope> f_stat) const override { | ||
| if (f_size != nullptr) { | ||
| f_size(1); | ||
| f_size(scopes_.size() + 1); | ||
|
Member
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. This is unrelated to this change but because of this change we can now do the API correctly? Is that right?
Contributor
Author
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. Sorry, which API are you referring to?
Member
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.
|
||
| } | ||
| f_stat(*default_scope_); | ||
| for (const ScopeSharedPtr& scope : scopes_) { | ||
| f_stat(*scope); | ||
| } | ||
| const Scope& scope = *this; | ||
| f_stat(scope); | ||
| } | ||
|
|
||
| Stats::StatName prefix() const override { return StatName(); } | ||
|
|
@@ -265,6 +268,8 @@ class IsolatedStoreImpl : public StoreImpl { | |
| IsolatedStatsCache<TextReadout> text_readouts_; | ||
| RefcountPtr<NullCounterImpl> null_counter_; | ||
| RefcountPtr<NullGaugeImpl> null_gauge_; | ||
| ScopeSharedPtr default_scope_; | ||
| std::vector<ScopeSharedPtr> scopes_; | ||
| }; | ||
|
|
||
| } // namespace Stats | ||
|
|
||
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 run into a situation wherein we have a shared_ptr to ScopePrefixer for the admin panel, but not the underlying scope?
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.
The lifetime concerns are not changed by this PR; the Store needs to outlive all the Scopes declared from it.
In general if you instantiate any Scope-derived object on the stack, and you will get some time of failure (e.g. a weak_ptr exception).
That is why I changed default_scope_ to be allocated with make_shared, enabling #19693 to hold onto a reference to it, and mirroring the implementation in thread_local_store.cc.