7
7
8
8
import com .amazonaws .util .EC2MetadataUtils ;
9
9
import com .codahale .metrics .Meter ;
10
- import com .codahale .metrics .MetricFilter ;
11
10
import com .codahale .metrics .MetricRegistry ;
12
11
import com .codahale .metrics .Timer ;
13
- import com .codahale .metrics .graphite .GraphiteReporter ;
14
12
import com .codahale .metrics .jvm .CachedThreadStatesGaugeSet ;
15
13
import com .codahale .metrics .jvm .GarbageCollectorMetricSet ;
16
14
import com .codahale .metrics .jvm .MemoryUsageGaugeSet ;
17
15
import com .codahale .metrics .logback .InstrumentedAppender ;
18
16
19
17
import ch .qos .logback .classic .LoggerContext ;
20
- import okhttp3 .OkHttpClient ;
21
18
22
19
// {{start:metrics}}
23
20
public class Metrics {
@@ -37,24 +34,8 @@ public class Metrics {
37
34
metrics .start ();
38
35
root .addAppender (metrics );
39
36
40
-
41
- // Graphite reporter to Grafana Cloud
42
- OkHttpClient client = new OkHttpClient .Builder ()
43
- //.addNetworkInterceptor(HttpClient.getLoggingInterceptor())
44
- .build ();
45
-
46
- String graphiteHost = Configs .properties ().getString ("metrics.graphite.host" );
47
- String grafanaApiKey = Configs .properties ().getString ("metrics.grafana.api_key" );
48
- final GraphiteHttpSender graphite = new GraphiteHttpSender (client , graphiteHost , grafanaApiKey );
49
- final GraphiteReporter reporter = GraphiteReporter .forRegistry (registry )
50
- .prefixedWith (metricPrefix ("stubbornjava" ))
51
- .convertRatesTo (TimeUnit .MINUTES )
52
- .convertDurationsTo (TimeUnit .MILLISECONDS )
53
- .filter (MetricFilter .ALL )
54
- .build (graphite );
55
- reporter .start (10 , TimeUnit .SECONDS );
56
-
57
37
// Register reporters here.
38
+ MetricsReporters .startReporters (registry );
58
39
}
59
40
60
41
public static MetricRegistry registry () {
@@ -69,7 +50,7 @@ public static Meter meter(String first, String... keys) {
69
50
return registry .meter (MetricRegistry .name (first , keys ));
70
51
}
71
52
72
- private static String metricPrefix (String app ) {
53
+ static String metricPrefix (String app ) {
73
54
Env env = Env .get ();
74
55
String host = env == Env .LOCAL ? "localhost" : getHost ();
75
56
String prefix = MetricRegistry .name (app , env .getName (), host );
0 commit comments