stats: add utilities to create stats from a vector of tokens, mixing dynamic and symbolic elements.#10735
Conversation
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
@snowp @mattklein123 @danzh2010 ptal Snow/Matt: curious what you think about this pattern of putting this helper function in Stats::Utility rather than making it a method of Scope. The downside is it's more cumbersome as a static method at call-sites. The upside is that there are several derivations of Scope and it's annoying to have to duplicate the code. I think Snow ran into this too. One alternative which I've used a lot in the past, but is less common in Envoy, is to have a shared helper class between the interface and the implementations with common methods factored out there. The other question is whether we should discourage extensive use of dynamic StatNames as they are more expensive, and you could argue this makes it too easy. Curious to hear your thoughts. If I do go through with this, there are about 15 or so more places in the code where we could do some simplifications of creating stats based on this. Wouldn't all need to get done at once though. |
…ollision? Signed-off-by: Joshua Marantz <jmarantz@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
At a high level this looks like a good improvement to me!
/wait
|
I agree that this is an improvement, I think we can document the pitfalls of using dynamic names instead of complicating the API intentionally. I think any attempt to make this more explicit (e.g. no implicit cast from string_view) still makes it easy to mess up unless docs are consulted - unless we make it kinda ridiculous scary sounding, e.g. , which I don't think is worth it |
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>
…sed to new util functions. Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
I pushed a version where it's not quite as verbose as what @snowp suggested, but I did add a type-wrapper so you have to use Stats::Utility::Dynamic(str) when you want to compose a joined stat-name that includes a dynamic string. Otherwise i think it won't be at all clear at the call-sites that dynamics are being added. Still working on cleaning up the other non-test uses of join(). |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ments. Signed-off-by: Joshua Marantz <jmarantz@google.com>
…*FromElements." This reverts commit 85b57ed. Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…mentation. Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s), but failed to run 2 pipeline(s). |
|
This is ready for review; thanks! |
snowp
left a comment
There was a problem hiding this comment.
This is a massive improvement IMO, thanks for doing this! A couple comments
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks this is a great improvement. One small perf suggestion.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…s. The latter didn't work for alll call-sites. Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
I need another review due to a commit (969c26a) to undo a suggestion about how to write the constructor, which apparently did not work at some call-site that I didn't manually re-test. |
Signed-off-by: Spencer Lewis <slewis@squareup.com> * master: fault injection: add support for setting gRPC status (envoyproxy#10841) tests: tag tests that fail on Windows with fails_on_windows (envoyproxy#10940) Fix typo on Postgres Proxy documentation. (envoyproxy#10930) fuzz: improve header/data stop/continue modeling in HCM fuzzer. (envoyproxy#10931) gzip filter: allow setting zlib compressor's chunk size (envoyproxy#10508) http: replace vector/reserve with InlinedVector in codec helper (envoyproxy#10941) stats: add utilities to create stats from a vector of tokens, mixing dynamic and symbolic elements. (envoyproxy#10735) hcm: avoid invoking 100-continue handling on decode filter. (envoyproxy#10929) prometheus stats: Correctly group lines of the same metric name. (envoyproxy#10833) status: Fix ASAN error in Status payload handling (envoyproxy#10906) path: Fix merge slash for paths ending with slash and present query args (envoyproxy#10922) compressor filter: add benchmark (envoyproxy#10464) xray: expected_span_name is not captured by the lambda with MSVC (envoyproxy#10934) ci: update before purge in cleanup (envoyproxy#10938) tracer: Improve test coverage for x-ray (envoyproxy#10890) Revert "init: order dynamic resource initialization to make RTDS always be first (envoyproxy#10362)" (envoyproxy#10919)
Description: Creating joined stat names is a bit awkward due to the way the memory management needs to work, and having dynamic components to the name adds further complexity. This PR adds some utility helper methods to make this much easier and terse to express.
There's one subtle semantic change in the grpc status, which is to use a Dynamic stat name rather than building a locally controlled mutex-protected map from strings to symbolic stat names.
Risk Level: low -- this is mostly a refactoring
Testing: //test/...
Docs Changes: n/a
Release Notes: n/a