Add username to shell latency metric and have it go to nan when shell is not connected
This commit is contained in:
1 parent
4d0a9ab56e
commit
8fe151bdb9
4 files changed
+15
-6
No files matched your search
@@ -8,7 +8,7 @@ ShellLatencyServer::ShellLatencyServer(bts::api::ServiceContext& ctx, metrics::M
|
||||
ShellLatencyServiceBase(ctx),
|
||||
_counter(0),
|
||||
_pub(make_clock_stateful_publisher()),
|
||||
_timer(utils::DispatcherTimer(d, 2500, [=]() { tick(); })),
|
||||
_timer(utils::DispatcherTimer(d, 1000, [=]() { tick(); })),
|
||||
_mc(mc),
|
||||
_metrics()
|
||||
{
|
||||
@@ -39,10 +39,13 @@ void ShellLatencyServer::report(
|
||||
auto key = request.host_name() + "-" + request.version();
|
||||
auto iter = _metrics.find(key);
|
||||
std::shared_ptr<AutoResetMetric> metric;
|
||||
auto delta = (utils::TimeStamp::now() - utils::TimeStamp(request.timestamp())).milliseconds();
|
||||
// report at least 1ms because the metric will not report anything if it's 0
|
||||
auto delta = std::max(1l, (utils::TimeStamp::now() - utils::TimeStamp(request.timestamp())).milliseconds());
|
||||
if (iter == _metrics.end()) {
|
||||
// create metric
|
||||
auto metric = std::make_shared<AutoResetMetric>("spark_shell_latency", std::vector<Label>({{"shell",key}}));
|
||||
auto metric =
|
||||
std::make_shared<AutoResetMetric>("spark_shell_latency",
|
||||
std::vector<Label>({{"shell",key}, {"user", request.user()}}));
|
||||
_metrics.insert(std::make_pair(key, metric));
|
||||
metric->max(delta);
|
||||
_mc.publish(metric);
|
||||
|
||||
Reference in new issue
Block a user