Update stats interface in preparation for tags#1803
Update stats interface in preparation for tags#1803htuch merged 11 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
ca45ce9 to
b9dee1b
Compare
htuch
left a comment
There was a problem hiding this comment.
Generally looks great. Main question is why we need to have histogram aware of the underlying type, seems TimeSpan provides the abstraction needed already.
| /** | ||
| * Flush a counter delta. | ||
| */ | ||
| virtual void flushCounter(const std::string& name, uint64_t delta) PURE; |
There was a problem hiding this comment.
Shouldn't this be Counter (and Gauge) below?
include/envoy/stats/stats.h
Outdated
| virtual ~Histogram() {} | ||
|
|
||
| enum ValueType { | ||
| Integer, |
There was a problem hiding this comment.
What value does this subtyping provide? Would it be possible to treat everything as just integers at the interface level (and for time, it's just # of ms in the implementation already).
There was a problem hiding this comment.
FWIW this would be fine for Lyft, my concern is for implementation where somehow a histogram is different from a timer. I'm not sure if that is a real issue or not... Let's discuss tomorrow.
include/envoy/stats/stats_macros.h
Outdated
| #define GENERATE_COUNTER_STRUCT(NAME) Stats::Counter& NAME##_; | ||
| #define GENERATE_GAUGE_STRUCT(NAME) Stats::Gauge& NAME##_; | ||
| #define GENERATE_TIMER_STRUCT(NAME) Stats::Timer& NAME##_; | ||
| #define GENERATE_TIMER_STRUCT(NAME) Stats::Histogram& NAME##_; |
There was a problem hiding this comment.
Can we get rid of this distinction in this file and just switch to pure histogram?
There was a problem hiding this comment.
I think this depends on if we decide to treat them differently from the user's perspective as discussed above.
include/envoy/stats/timespan.h
Outdated
| * Complete the timespan and send the time to the histogram. | ||
| */ | ||
| virtual void complete() { | ||
| histogram_.recordValue(std::chrono::duration_cast<std::chrono::milliseconds>( |
There was a problem hiding this comment.
Should this stuff be in the source/common implementation rather than interface?
There was a problem hiding this comment.
As was discussed in #1751, if we move this to source/common everything that wants to create a Timespan having to depend on some stats implementation lib rather than just the set of stats interfaces (everything else in stats currently works this way outside of the creation of the store). The implementation of this class is relatively small. I'm cool changing it if we're okay with those tradeoffs.
include/envoy/stats/timespan.h
Outdated
| */ | ||
| virtual void complete() { | ||
| histogram_.recordValue(std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| std::chrono::steady_clock::now() - start_) |
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
|
@htuch @mattklein123 Updated in line with our discussion earlier today. I added a small blurb to the docs and added a slightly longer comment above the histogram class. Let me know if you think more explanation's needed. |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks for doing this super tedious change. This is great. Few minor comments.
include/envoy/stats/timespan.h
Outdated
| namespace Stats { | ||
|
|
||
| /** | ||
| * An individual timespan that flushes its measured value to a Duration histogram. The initial time |
There was a problem hiding this comment.
nit: I would probably remove "Duration"
include/envoy/stats/timespan.h
Outdated
| Timespan(Histogram& histogram) | ||
| : histogram_(histogram), start_(std::chrono::steady_clock::now()) {} | ||
|
|
||
| virtual ~Timespan() {} |
There was a problem hiding this comment.
Good point. Removed it and made all the methods non-virtual since nothing's inheriting from it.
source/common/http/user_agent.cc
Outdated
|
|
||
| void UserAgent::completeConnectionLength(Stats::Timespan& span) { | ||
| if (!stats_) { | ||
| if (!stats_ || !scope_) { |
There was a problem hiding this comment.
nit: I think scope_ must be not nullptr if stats is not nullptr?
There was a problem hiding this comment.
Yup, I was being a little conservative in case the implementation changes below, but I'm fine leaving it out of the if if that's not a concern.
There was a problem hiding this comment.
Removed it and added a quick comment noting the expectation.
Signed-off-by: Matt Rice <mattrice@google.com>
Signed-off-by: Matt Rice <mattrice@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM, thanks. Will defer to @htuch for any further comments.
Before:
$ bazel-bin/src/envoy/envoy --version
bazel-bin/src/envoy/envoy version: 0/1.8.0-dev//DEBUG
After:
$ bazel-bin/src/envoy/envoy --version
bazel-bin/src/envoy/envoy version: f315a32fc7c6f727fc9645cc1ca27d4160c1d0e0/1.8.0-dev/Clean/DEBUG
Fixes envoyproxy#1803.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
…#1803) Description: Move main_ios_dist in artifacts workflow to Engflow remote execution and improve build times by ~2x Risk Level: Low Testing: See artifacts check Docs Changes: Release Notes: Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com> Signed-off-by: JP Simard <jp@jpsim.com>
…#1803) Description: Move main_ios_dist in artifacts workflow to Engflow remote execution and improve build times by ~2x Risk Level: Low Testing: See artifacts check Docs Changes: Release Notes: Signed-off-by: Luis Fernando Pino Duque <luis@engflow.com> Signed-off-by: JP Simard <jp@jpsim.com>
Tags will require all stats have non-trivial state associated with them. This enforces that all stats are represented as objects before being exported. As a part of this addition, there are a few structural changes to the way stats work in Envoy:
Metriccalss has been added as a base class for all stats objects. This will contain identifying information.Histogramclass has replaced theTimerclass. This object represents histograms of any data that can be represented byuint64_t. It also contains a methodtype()to identify the type of data represented (this includesDuration).Timespanhas been moved into an independent class, which will be created with a referenceHistogram.HISTOGRAMmacros have been added to createIntegerhistogram objects.This is the first stage of what was previously #1751 with some modifications based on the discussion in that PR.