Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1e20aef
basic histogram rendering with divs.
jmarantz Mar 29, 2023
d2055ee
use a darker red
jmarantz Mar 30, 2023
f01ca9c
revert bazelversion
jmarantz Mar 30, 2023
e7b4409
render detailed histograms
jmarantz Apr 1, 2023
76f8abe
remove typo
jmarantz Apr 1, 2023
5b5b37d
a few tweaks to detailed mode; just printing the percentils on the sa…
jmarantz Apr 3, 2023
cd70f5c
optional limit to the number of returned detailed bucket.
jmarantz Apr 4, 2023
e63d18a
Write the percentile values properly
jmarantz Apr 12, 2023
e691dfe
unit tests work again.
jmarantz Apr 12, 2023
bff1839
render buckets and percentiles together.
jmarantz Apr 12, 2023
f1f9ef2
basic rendering of histogram with percentile overlays. still lots of …
jmarantz Apr 13, 2023
6039d57
explicit positioning of labels, percentiles, and buckets
jmarantz Apr 13, 2023
e7b9d5a
tweaks
jmarantz Apr 13, 2023
e4251ed
more graphics tweaks
jmarantz Apr 13, 2023
b11bb91
less obnoxious colors.
jmarantz Apr 13, 2023
df5a14f
minor visual tweaks and note some TODOs.
jmarantz Apr 13, 2023
afa6020
code cleanup
jmarantz Apr 13, 2023
e9ea2cb
proportional positioning of percentile bars.
jmarantz Apr 13, 2023
8a77bd7
remove commentned-out blocks; tweak graphics a little more
jmarantz Apr 13, 2023
3f32624
minor positioning tweak to kind of center the histogram bar over the …
jmarantz Apr 13, 2023
739329a
split out /stats/html-active into its own endpoint as it has fewer pa…
jmarantz Apr 18, 2023
86bca7d
remove dead JS for alternate histogram modes.
jmarantz Apr 18, 2023
3a52479
improved navigation w/o changing document.
jmarantz Apr 18, 2023
05fbc32
clean up navigation a little
jmarantz Apr 19, 2023
fc227a3
render histograms in static html page also, with some JSON and JS hel…
jmarantz Apr 23, 2023
58f3d8d
fix active stats logic. lazily add percentiles div only if we are
jmarantz Apr 24, 2023
54512da
Figure out the relative path for the js fetch based on the current path.
jmarantz Apr 24, 2023
c3e4679
Merge branch 'main' into admin-stats-histograms
jmarantz Apr 24, 2023
4c80b1c
Split out a function to render a single histogram to enable rendering…
jmarantz Apr 24, 2023
c620775
get change-counts for histograms.
jmarantz Apr 25, 2023
1077cdc
Add detailed interval buckets to the json as 'intervals' and rename '…
jmarantz Apr 26, 2023
815d70c
basic drawing of intervals.
jmarantz Apr 26, 2023
395b7a2
Merge branch 'main' into admin-stats-histograms
jmarantz Apr 29, 2023
c222c1a
Merge branch 'main' into admin-stats-histograms
jmarantz Apr 29, 2023
2adecdc
format
jmarantz Apr 29, 2023
51ec0a7
name-change
jmarantz Apr 29, 2023
38413ac
test cleanup
jmarantz May 1, 2023
3fa9843
Merge branch 'main' into admin-stats-histograms
jmarantz May 1, 2023
e425fb5
typo
jmarantz May 1, 2023
9ed0fa1
Merge branch 'main' into admin-stats-histograms
jmarantz May 1, 2023
d9242d6
Fix active-html following resolution of merge conflicts with prom spe…
jmarantz May 1, 2023
bad9bcf
format
jmarantz May 1, 2023
e78f095
remove commented-out code
jmarantz May 1, 2023
0687c48
fix typo
jmarantz May 1, 2023
bac31b3
fix compile error with html disabled.
jmarantz May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions envoy/stats/histogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ class ParentHistogram : public Histogram {
* Returns the bucket summary representation.
*/
virtual std::string bucketSummary() const PURE;

struct Bucket {
double value_{0};
uint64_t count_{0};
};

virtual std::vector<Bucket> detailedTotalBuckets(uint32_t max_buckets = 0) const PURE;
virtual std::vector<Bucket> detailedIntervalBuckets(uint32_t max_buckets = 0) const PURE;
};

using ParentHistogramSharedPtr = RefcountPtr<ParentHistogram>;
Expand Down
2 changes: 0 additions & 2 deletions source/common/stats/histogram_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class HistogramStatisticsImpl final : public HistogramStatistics, NonCopyable {
const histogram_t* histogram_ptr, Histogram::Unit unit = Histogram::Unit::Unspecified,
ConstSupportedBuckets& supported_buckets = HistogramSettingsImpl::defaultBuckets());

static ConstSupportedBuckets& defaultSupportedBuckets();

void refresh(const histogram_t* new_histogram_ptr);

// HistogramStatistics
Expand Down
48 changes: 48 additions & 0 deletions source/common/stats/thread_local_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,54 @@ std::string ParentHistogramImpl::bucketSummary() const {
}
}

std::vector<Stats::ParentHistogram::Bucket>
ParentHistogramImpl::detailedTotalBuckets(uint32_t max_buckets) const {
return detailedlBucketsHelper(max_buckets, *cumulative_histogram_);
}

std::vector<Stats::ParentHistogram::Bucket>
ParentHistogramImpl::detailedIntervalBuckets(uint32_t max_buckets) const {
return detailedlBucketsHelper(max_buckets, *interval_histogram_);
}

std::vector<Stats::ParentHistogram::Bucket>
ParentHistogramImpl::detailedlBucketsHelper(uint32_t max_buckets, const histogram_t& histogram) {
const uint32_t num_src_buckets = hist_num_buckets(&histogram);
if (max_buckets == 0) {
max_buckets = num_src_buckets;
}
const uint32_t num_buckets = std::min(max_buckets, num_src_buckets);
uint32_t num_src_buckets_per_bucket = 1;
uint32_t remainder = 0;
if (num_src_buckets > num_buckets) {
num_src_buckets_per_bucket = num_src_buckets / num_buckets;
remainder = num_src_buckets - num_buckets * num_src_buckets_per_bucket;
ASSERT(remainder < num_buckets);
}

std::vector<Stats::ParentHistogram::Bucket> buckets(num_buckets);
uint32_t src = 0;
for (uint32_t dest = 0; dest < num_buckets; ++dest) {
ParentHistogram::Bucket& bucket = buckets[dest];
uint32_t merges = num_src_buckets_per_bucket;
if (remainder > 0) {
++merges;
--remainder;
}
for (uint32_t i = 0; i < merges; ++i, ++src) {
ASSERT(src < num_src_buckets);
double value;
uint64_t count;
/*int ret = */ hist_bucket_idx(&histogram, src, &value, &count);
bucket.count_ += count;
bucket.value_ += value;
}
bucket.value_ /= merges;
}
ASSERT(src == num_src_buckets);
return buckets;
}

void ParentHistogramImpl::addTlsHistogram(const TlsHistogramSharedPtr& hist_ptr) {
Thread::LockGuard lock(merge_lock_);
tls_histograms_.emplace_back(hist_ptr);
Expand Down
4 changes: 4 additions & 0 deletions source/common/stats/thread_local_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class ParentHistogramImpl : public MetricImpl<ParentHistogram> {
}
std::string quantileSummary() const override;
std::string bucketSummary() const override;
std::vector<Bucket> detailedTotalBuckets(uint32_t max_buckets) const override;
std::vector<Bucket> detailedIntervalBuckets(uint32_t max_buckets) const override;

// Stats::Metric
SymbolTable& symbolTable() override;
Expand All @@ -121,6 +123,8 @@ class ParentHistogramImpl : public MetricImpl<ParentHistogram> {

private:
bool usedLockHeld() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(merge_lock_);
static std::vector<Stats::ParentHistogram::Bucket>
detailedlBucketsHelper(uint32_t max_buckets, const histogram_t& histogram);

Histogram::Unit unit_;
ThreadLocalStoreImpl& thread_local_store_;
Expand Down
3 changes: 2 additions & 1 deletion source/server/admin/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server,
MAKE_ADMIN_HANDLER(server_info_handler_.handlerServerInfo), false, false),
makeHandler("/ready", "print server state, return 200 if LIVE, otherwise return 503",
MAKE_ADMIN_HANDLER(server_info_handler_.handlerReady), false, false),
stats_handler_.statsHandler(false /* not active mode */),
stats_handler_.statsHandler("/stats", false /* not active mode */),
stats_handler_.statsHandler("/stats/html-active", true),
stats_handler_.prometheusStatsHandler(),
makeHandler("/stats/recentlookups", "Show recent stat-name lookups",
MAKE_ADMIN_HANDLER(stats_handler_.handlerStatsRecentLookups), false, false),
Expand Down
2 changes: 1 addition & 1 deletion source/server/admin/admin_html.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Server {
Http::Code AdminImpl::handlerAdminHome(Http::ResponseHeaderMap& response_headers,
Buffer::Instance& response, AdminStream&) {
AdminHtmlUtil::renderHead(response_headers, response);
AdminHtmlUtil::renderTableBegin(response);
AdminHtmlUtil::renderTableBegin(response, "Command");

// Prefix order is used during searching, but for printing do them in alpha order.
OptRef<const Http::Utility::QueryParams> no_query_params;
Expand Down
15 changes: 9 additions & 6 deletions source/server/admin/admin_html_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const char AdminHtmlTableBegin[] = R"(
<table class='home-table'>
<thead>
<tr>
<th class='home-data'>Command</th>
<th class='home-data'>@NAME_COLUMN@</th>
<th class='home-data'>Description</th>
</tr>
</thead>
Expand Down Expand Up @@ -58,6 +58,7 @@ class BuiltinResourceProvider : public AdminHtmlUtil::ResourceProvider {
map_["admin_head_start.html"] = AdminHtmlStart;
map_["admin.css"] = AdminCss;
map_["active_stats.js"] = AdminActiveStatsJs;
map_["histograms.js"] = HistogramsJs;
map_["active_params.html"] = AdminActiveParamsHtml;
}

Expand Down Expand Up @@ -111,8 +112,8 @@ void AdminHtmlUtil::renderHead(Http::ResponseHeaderMap& response_headers,
response.add("</head>\n<body>\n");
}

void AdminHtmlUtil::renderTableBegin(Buffer::Instance& response) {
response.add(AdminHtmlTableBegin);
void AdminHtmlUtil::renderTableBegin(Buffer::Instance& response, absl::string_view name_column) {
response.add(absl::StrReplaceAll(AdminHtmlTableBegin, {{"@NAME_COLUMN@", name_column}}));
}

void AdminHtmlUtil::renderTableEnd(Buffer::Instance& response) { response.add(AdminHtmlTableEnd); }
Expand Down Expand Up @@ -201,9 +202,11 @@ void AdminHtmlUtil::renderEndpointTableRow(Buffer::Instance& response,
// rather than an anchor tag. This should discourage crawlers that find the /
// page from accidentally mutating all the server state by GETting all the hrefs.
const char* method = handler.mutates_server_state_ ? "post" : "get";
if (submit_on_change) {
response.addFragments({"\n<tr><td><form action='", path, "' method='", method, "' id='", path,
"' class='home-form'></form></td><td></td></tr>\n"});
if (submit_on_change || active) {
response.addFragments({"\n<tr><td><form ",
active ? "onsubmit='return onSubmit()'"
: absl::StrCat("action='", path, "' method='", method, "'"),
" id='", path, "' class='home-form'></form></td><td></td></tr>\n"});
} else {
response.addFragments({"\n<tr class='vert-space'><td></td><td></td></tr>\n<tr", row_class,
">\n <td class='home-data'>"});
Expand Down
2 changes: 1 addition & 1 deletion source/server/admin/admin_html_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AdminHtmlUtil {
* Renders the beginning of the help-table into the response buffer provided
* in the constructor.
*/
static void renderTableBegin(Buffer::Instance&);
static void renderTableBegin(Buffer::Instance&, absl::string_view name_column);

/**
* Renders the end of the help-table into the response buffer provided in the
Expand Down
3 changes: 2 additions & 1 deletion source/server/admin/html/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ genrule(
"admin.css",
"active_params.html",
"active_stats.js",
"histograms.js",
],
outs = ["admin_html_gen.h"],
cmd = "./$(location :generate_admin_html.sh) \
$(location admin_head_start.html) $(location admin.css) $(location active_stats.js) \
$(location active_params.html) > $@",
$(location active_params.html) $(location histograms.js) > $@",
tools = [":generate_admin_html.sh"],
)

Expand Down
6 changes: 4 additions & 2 deletions source/server/admin/html/active_params.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<tr class='gray'>
<td class='option'><input type='text' name='max-display-count' id='active-max-display-count' value=50 /></td>
<td class='option'><input type='text' name='max-display-count' id='active-max-display-count'
value=50 onblur='updateParams()' /></td>
<td class='home-data'><label for='active-max-display-count'>Maximum number of stats to display</label></td>
</tr>
<tr class='gray'>
<td class='option'><input type='text' name='update-interval' id='active-update-interval' value=5 /></td>
<td class='option'><input type='text' name='update-interval' id='active-update-interval'
value=5 onblur='updateParams()' /></td>
<td class='home-data'><label for='active-update-interval'>Number of seconds between each update</label></td>
</tr>
Loading