Add tracking of response body-size and header-size#265
Add tracking of response body-size and header-size#265mum4k merged 81 commits intoenvoyproxy:masterfrom
Conversation
- Define NH version in the code in a canonical place. - Update the fortio output formatter - add missing version field - Add RELEASE_PROCEDURE.md - Consume the new version information in various places to make --version output of executables sensible. Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…nse-size-tracking Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
Please mark this again as waiting-for-review once the merge conflicts are resolved. |
…cking Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
@eric846 please review and assign back to me when ready. Looks to be a lot of lines, but most of them are golden files. |
…cking Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…cking Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…cking Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
eric846
left a comment
There was a problem hiding this comment.
LGTM
I would consider all my comments optional.
| result->set_name(name.data(), name.size()); | ||
| for (auto& statistic : statistics) { | ||
| *(result->add_statistics()) = statistic->toProto(); | ||
| // TODO(#XXX): Looking at if the statistic id ends with "_size" to determine how it should be |
source/common/statistic_impl.cc
Outdated
| const auto& b = dynamic_cast<const SimpleStatistic&>(statistic); | ||
| auto combined = std::make_unique<SimpleStatistic>(); | ||
|
|
||
| combined->min_ = a.min() > b.min() ? b.min() : a.min(); |
There was a problem hiding this comment.
Any reason not to use std::min() and std::max()?
source/client/factories_impl.cc
Outdated
| // StreamingStatistic for the stats that track response sizes. Ideally we would have options | ||
| // for this to route the right stat to the right backend (HdrStatistic, SimpleStatistic, | ||
| // NullStatistic). | ||
| // TODO(#XXX): Create options and have the StatisticFactory consider those when instantiating |
source/common/statistic_impl.cc
Outdated
| if (domain == Statistic::SerializationDomain::DURATION) { | ||
| int64_t nanos; | ||
| nanos = count() == 0 ? 0 : static_cast<int64_t>(std::round(mean())); | ||
| statistic.mutable_mean()->set_seconds(nanos / 1000000000); |
There was a problem hiding this comment.
Can we change 1000000000 to (1000 * 1000 * 1000) to avoid accidents?
There was a problem hiding this comment.
Also since this pattern with /1000000000 and %1000000000, maybe there should be a helper method for setting a proto duration, taking mutable Duration* and int64_t nanos
| uint64_t HdrStatistic::min() const { | ||
| return count() == 0 ? UINT64_MAX : hdr_value_at_percentile(histogram_, 0); | ||
| } | ||
| uint64_t HdrStatistic::max() const { return hdr_value_at_percentile(histogram_, 100); } |
There was a problem hiding this comment.
Will max() blow up if count()==0?
There was a problem hiding this comment.
We should be ok with respect to that (see TypedStatisticTest::Empty)
source/common/statistic_impl.h
Outdated
| return streaming_stats_->resistsCatastrophicCancellation(); | ||
| } | ||
| uint64_t significantDigits() const override { return streaming_stats_->significantDigits(); } | ||
| StatisticPtr createNewInstance() const override { return std::make_unique<InMemoryStatistic>(); }; |
There was a problem hiding this comment.
+1 on the clever elimination of the factory.
When I saw this being called, I assumed createNewInstance() would create a copy of the existing object -- the most obvious explanation for why it would be an instance method on an existing object. What about createNewInstanceOfSameType() to clarify the meaning?
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
PR summary:
StreamingStatistic.min/maxin our statistics, and wires that through to our output.StreamingStatistic::combineThe new statistics will show in the CLI as:
Assuming we don't need full blown histograms for this, this fixes #271
Note: I observed that the fortio seems to be tracking different things for size/headersize in fortio, depending on if the fast http client is used or not. As this seems like a bug, I didn't try to reproduce that specific behavior in NH.
Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com
Waiting on:
Prerequisites to merging this
Fortiovisualization andistio/tools, but that actually are emitted in Fortio's json output:predicates, but not shown in visualization, not used in istio/tools)
RetCodesSizesandHeaderSizesin its json output are used inistio/toolsand missing in NH's output. However, they are only used to compute an error ratio (slightly different from how Fortio does that itself, and only precisely status 200 seems to count as succes), as well as compute an average response payload size for output in the csv transform.In this PR we add simple tracking for the sizes (min/mean/max/stdev), and not full blown histogram tracking of sizes. It is worth nothing that Fortio seems to report different size values depending:
[1]
Sizesand body size forHeaderSizes. It's worth noting that it seems like Fortio may internally switch to stdclient when using https.