-
Notifications
You must be signed in to change notification settings - Fork 352
Expand file tree
/
Copy pathDebuggerMetrics.java
More file actions
102 lines (82 loc) · 2.85 KB
/
Copy pathDebuggerMetrics.java
File metadata and controls
102 lines (82 loc) · 2.85 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.datadog.debugger.util;
import datadog.metrics.api.statsd.StatsDClient;
import datadog.metrics.impl.statsd.DDAgentStatsDClientManager;
import datadog.trace.api.Config;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/** implements a StatsD client for internal debugger agent metrics */
public class DebuggerMetrics implements StatsDClient {
private static DebuggerMetrics INSTANCE = null;
private static final String STATSD_NAMESPACE_PREFIX = "datadog.debugger";
private final StatsDClient statsd;
private DebuggerMetrics(Config config) {
if (config.isDynamicInstrumentationMetricsEnabled()) {
statsd =
DDAgentStatsDClientManager.statsDClientManager()
.statsDClient(
config.getJmxFetchStatsdHost(),
config.getJmxFetchStatsdPort(),
config.getDogStatsDNamedPipe(),
STATSD_NAMESPACE_PREFIX,
new String[0]);
} else {
statsd = StatsDClient.NO_OP;
}
}
@SuppressFBWarnings(
value = {"USO_UNSAFE_METHOD_SYNCHRONIZATION", "USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION"},
justification = "Agent-internal singleton; neither Class object nor instance monitor escapes")
public static synchronized DebuggerMetrics getInstance(Config config) {
if (INSTANCE == null) {
INSTANCE = new DebuggerMetrics(config);
}
return INSTANCE;
}
@Override
public void incrementCounter(String metricName, String... tags) {
statsd.incrementCounter(metricName, tags);
}
@Override
public void count(String metricName, long delta, String... tags) {
statsd.count(metricName, delta, tags);
}
@Override
public void gauge(String metricName, long value, String... tags) {
statsd.gauge(metricName, value, tags);
}
@Override
public void gauge(String metricName, double value, String... tags) {
statsd.gauge(metricName, value, tags);
}
@Override
public void histogram(String metricName, long value, String... tags) {
statsd.histogram(metricName, value, tags);
}
@Override
public void histogram(String metricName, double value, String... tags) {
statsd.histogram(metricName, value, tags);
}
@Override
public void distribution(String metricName, long value, String... tags) {
statsd.distribution(metricName, value, tags);
}
@Override
public void distribution(String metricName, double value, String... tags) {
statsd.distribution(metricName, value, tags);
}
@Override
public void serviceCheck(String serviceCheckName, String status, String message, String... tags) {
statsd.serviceCheck(serviceCheckName, status, message, tags);
}
@Override
public void error(Exception error) {
statsd.error(error);
}
@Override
public int getErrorCount() {
return statsd.getErrorCount();
}
@Override
public void close() {
statsd.close();
}
}