-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Update stats interface in preparation for tags #1803
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
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
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.
Generally looks great. Main question is why we need to have histogram aware of the underlying type, seems TimeSpan
provides the abstraction needed already.
include/envoy/stats/stats.h
Outdated
@@ -109,12 +108,12 @@ class Sink { | |||
/** | |||
* Flush a counter delta. | |||
*/ | |||
virtual void flushCounter(const std::string& name, uint64_t delta) PURE; | |||
virtual void flushCounter(const Metric& counter, uint64_t delta) PURE; |
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.
Shouldn't this be Counter
(and Gauge
) below?
include/envoy/stats/stats.h
Outdated
|
||
enum ValueType { | ||
Integer, | ||
Duration, |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -28,15 +28,18 @@ namespace Envoy { | |||
|
|||
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of this distinction in this file and just switch to pure histogram?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this stuff be in the source/common
implementation rather than interface?
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.
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_) |
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.
Use getRawDuration()
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.
Good point. Updated.
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not needed
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.
Good point. Removed it and made all the methods non-virtual since nothing's inheriting from it.
source/common/http/user_agent.cc
Outdated
@@ -12,11 +12,11 @@ namespace Envoy { | |||
namespace Http { | |||
|
|||
void UserAgent::completeConnectionLength(Stats::Timespan& span) { | |||
if (!stats_) { | |||
if (!stats_ || !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.
nit: I think scope_ must be not nullptr if stats is not nullptr?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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.
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:
Metric
calss has been added as a base class for all stats objects. This will contain identifying information.Histogram
class has replaced theTimer
class. 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
).Timespan
has been moved into an independent class, which will be created with a referenceHistogram
.HISTOGRAM
macros have been added to createInteger
histogram objects.This is the first stage of what was previously #1751 with some modifications based on the discussion in that PR.