Skip to content

stats: Scope should not be a parent-class of Store#23851

Merged
jmarantz merged 61 commits intoenvoyproxy:mainfrom
jmarantz:stats-store-is-not-a-scope
Dec 14, 2022
Merged

stats: Scope should not be a parent-class of Store#23851
jmarantz merged 61 commits intoenvoyproxy:mainfrom
jmarantz:stats-store-is-not-a-scope

Conversation

@jmarantz
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz commented Nov 6, 2022

Commit Message: Refactors so that Stats::Store is no longer a subclass of Stats::Scope. Previously it was, so that the root-scope was effectively the same thing as the Store. This causes issues and confusion because Stores are typically created directly as test-class member variables, but Scopes were mostly created as shared_ptr for various reasons. This refactor attempts to cleanly, but minimally, enable the memory management of Scopes to be strictly shared_ptr. It also separate two different concepts.

Additional Description:

This leaves behind a bit of technical debt to keep this refactor reviewable. This is tracked in #24007 and can be addressed in a follow-up PR that will be much larger than this one, but will be strictly a series of simple replacements (makeStats(store_) --> makeStats(*store_->rootScope()))

To reviewers: I recommend looking at scope.h and store.h carefully to see the real change that was done here. Then also look at isolated_store_impl.*, stat_test_utility.*, and the changes to the mocks. Finally look at test/integration/server.h for the change in the thread-safe wrapper around isolated store there. Everything else should be pretty quick to review once you have that context.

Risk Level: medium -- this is a pretty large refactor
Testing: //test/...
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a
Fixes: #23862

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #23851 was opened by jmarantz.

see: more, trace.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ats/... building (not passing)

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ation noise.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Dec 6, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #23851 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Dec 6, 2022

Greg - I think this is ready for a pass; no super great rush but IMO this is the right direction, and will also make it easier for @stevenzzzz to build and test a mechanism that uses scopes to hold onto live cluster stats across and xDS updates.

…, and it turns out we only need the one for Gauges.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Copy Markdown
Contributor Author

jmarantz commented Dec 6, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #23851 (comment) was created by @jmarantz.

see: more, trace.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

This looks good overall. I like the direction it's going.

/wait

virtual void forEachScope(SizeFn f_size, StatFn<const Scope> f_stat) const PURE;

/**
* @return a null counter that will ignore increemts and always return 0.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @return a null counter that will ignore increemts and always return 0.
* @return a null counter that will ignore increments and always return 0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

// accessing the rootScope() to call these methods.
operator Scope&() { return *rootScope(); }

// Delegate somea methods to the root scope; these are exposed to make it more
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Delegate somea methods to the root scope; these are exposed to make it more
// Delegate some methods to the root scope; these are exposed to make it more

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

operator Scope&() { return *rootScope(); }

// Delegate somea methods to the root scope; these are exposed to make it more
// convenient to use stats_macros.h. We mayconsider dropping them if desired,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// convenient to use stats_macros.h. We mayconsider dropping them if desired,
// convenient to use stats_macros.h. We may consider dropping them if desired,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz merged commit 5940a1d into envoyproxy:main Dec 14, 2022
@jmarantz jmarantz deleted the stats-store-is-not-a-scope branch December 14, 2022 20:39
dubious90 pushed a commit to envoyproxy/nighthawk that referenced this pull request Dec 20, 2022
- Change the way of calling deliverHistogramToSinks. Now deliverHistogramToSinks is a member of Store instead of Scope. This is due to the change of envoy envoyproxy/envoy#23851.
- Update config.yaml to envoy version
- No changes in other files.

Signed-off-by: fei-deng <feid@google.com>
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.

Stats::Store should not inherit from Stats::Scope

4 participants