blob: d9ab020bcb8e5fa2dad60b213cde9783760c8d73 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.handler.threadpool;
import com.yahoo.jdisc.Metric;
import java.util.Map;
/**
* @author bjorncs
*/
class ThreadPoolMetric {
private static final String THREAD_POOL_NAME_DIMENSION = "threadpool";
private final Metric metric;
private final Metric.Context defaultContext;
private final String threadPoolName;
ThreadPoolMetric(Metric metric, String threadPoolName) {
this.metric = metric;
this.threadPoolName = threadPoolName;
this.defaultContext = metric.createContext(Map.of(THREAD_POOL_NAME_DIMENSION, threadPoolName));
}
void reportRejectRequest() { metric.add("serverRejectedRequests", 1L, defaultContext); }
void reportThreadPoolSize(long size) { metric.set("serverThreadPoolSize", size, defaultContext); }
void reportActiveThreads(long threads) { metric.set("serverActiveThreads", threads, defaultContext); }
void reportUnhandledException(Throwable t) {
Metric.Context ctx = metric.createContext(Map.of(
THREAD_POOL_NAME_DIMENSION, threadPoolName,
"exception", t.getClass().getSimpleName()));
metric.set("jdisc.thread_pool.unhandled_exceptions", 1L, ctx);
}
}
|