Skip to content

Conversation

mrice32
Copy link
Member

@mrice32 mrice32 commented Oct 3, 2017

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:

  • The Metric calss has been added as a base class for all stats objects. This will contain identifying information.
  • The Histogram class has replaced the Timer class. This object represents histograms of any data that can be represented by uint64_t. It also contains a method type() to identify the type of data represented (this includes Duration).
  • Timespan has been moved into an independent class, which will be created with a reference Histogram.
  • HISTOGRAM macros have been added to create Integer histogram objects.

This is the first stage of what was previously #1751 with some modifications based on the discussion in that PR.

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>
@mrice32 mrice32 force-pushed the stats_interface_update branch from ca45ce9 to b9dee1b Compare October 4, 2017 13:58
Copy link
Member

@htuch htuch left a 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.

@@ -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;
Copy link
Member

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?


enum ValueType {
Integer,
Duration,
Copy link
Member

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).

Copy link
Member

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.

@@ -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##_;
Copy link
Member

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?

Copy link
Member Author

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.

* Complete the timespan and send the time to the histogram.
*/
virtual void complete() {
histogram_.recordValue(std::chrono::duration_cast<std::chrono::milliseconds>(
Copy link
Member

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?

Copy link
Member Author

@mrice32 mrice32 Oct 5, 2017

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.

*/
virtual void complete() {
histogram_.recordValue(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start_)
Copy link
Member

Choose a reason for hiding this comment

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

Use getRawDuration() here?

Copy link
Member Author

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>
@mrice32
Copy link
Member Author

mrice32 commented Oct 5, 2017

@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.

Copy link
Member

@mattklein123 mattklein123 left a 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.

namespace Stats {

/**
* An individual timespan that flushes its measured value to a Duration histogram. The initial time
Copy link
Member

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"

Timespan(Histogram& histogram)
: histogram_(histogram), start_(std::chrono::steady_clock::now()) {}

virtual ~Timespan() {}
Copy link
Member

Choose a reason for hiding this comment

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

nit: not needed

Copy link
Member Author

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.

@@ -12,11 +12,11 @@ namespace Envoy {
namespace Http {

void UserAgent::completeConnectionLength(Stats::Timespan& span) {
if (!stats_) {
if (!stats_ || !scope_) {
Copy link
Member

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?

Copy link
Member Author

@mrice32 mrice32 Oct 5, 2017

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.

Copy link
Member Author

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>
Copy link
Member

@mattklein123 mattklein123 left a 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.

@htuch htuch merged commit d1431cf into envoyproxy:master Oct 6, 2017
@mrice32 mrice32 deleted the stats_interface_update branch October 6, 2017 14:14
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
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>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
…#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>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
…#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>
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.

3 participants