File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
stubbornjava-common/src/main/java/com/stubbornjava/common Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import java .util .concurrent .TimeUnit ;
4
4
5
+ import org .slf4j .Logger ;
6
+ import org .slf4j .LoggerFactory ;
7
+
5
8
import com .codahale .metrics .MetricFilter ;
6
9
import com .codahale .metrics .MetricRegistry ;
7
10
import com .codahale .metrics .graphite .GraphiteReporter ;
10
13
11
14
// {{start:reporters}}
12
15
class MetricsReporters {
16
+ private static final Logger log = LoggerFactory .getLogger (MetricsReporters .class );
13
17
14
18
public static void startReporters (MetricRegistry registry ) {
15
19
// Graphite reporter to Grafana Cloud
16
20
OkHttpClient client = new OkHttpClient .Builder ()
17
21
//.addNetworkInterceptor(HttpClient.getLoggingInterceptor())
18
22
.build ();
19
23
24
+ if (!Configs .properties ().hasPath ("metrics.graphite.host" )
25
+ || !Configs .properties ().hasPath ("metrics.grafana.api_key" )) {
26
+ log .info ("Missing metrics reporter key or host skipping" );
27
+ return ;
28
+ }
29
+
20
30
String graphiteHost = Configs .properties ().getString ("metrics.graphite.host" );
21
31
String grafanaApiKey = Configs .properties ().getString ("metrics.grafana.api_key" );
22
32
final GraphiteHttpSender graphite = new GraphiteHttpSender (client , graphiteHost , grafanaApiKey );
You can’t perform that action at this time.
0 commit comments