1414import okhttp3 .OkHttpClient ;
1515import okhttp3 .Request ;
1616import okhttp3 .RequestBody ;
17- import okhttp3 .logging .HttpLoggingInterceptor ;
18- import okhttp3 .logging .HttpLoggingInterceptor .Level ;
1917
2018// {{start:sender}}
2119/**
2624 *
2725 */
2826class GraphiteHttpSender implements GraphiteSender {
29- private static final Logger log = LoggerFactory .getLogger (GraphiteHttpSender .class );
27+ @ SuppressWarnings ("unused" )
28+ private static final Logger log = LoggerFactory .getLogger (GraphiteHttpSender .class );
3029
3130 private final OkHttpClient client ;
3231 private final String host ;
@@ -58,9 +57,9 @@ public void send(String name, String value, long timestamp) throws IOException {
5857 public void flush () throws IOException {
5958 Request request = new Request .Builder ()
6059 .url (host + "/metrics" )
61- .post (RequestBody .create (MediaType . parse ( "application/json" ), Json .serializer ().toByteArray (metrics )))
60+ .post (RequestBody .Companion . create (Json .serializer ().toByteArray (metrics ), MediaType . Companion . parse ( "application/json" )))
6261 .build ();
63- String response = Retry .retryUntilSuccessfulWithBackoff (() -> client .newCall (request ).execute ());
62+ Retry .retryUntilSuccessfulWithBackoff (() -> client .newCall (request ).execute ());
6463 metrics .clear ();
6564 }
6665
@@ -76,14 +75,6 @@ public int getFailures() {
7675 return 0 ;
7776 }
7877
79- private static final HttpLoggingInterceptor getLogger (Level level ) {
80- HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor ((msg ) -> {
81- log .debug (msg );
82- });
83- loggingInterceptor .setLevel (level );
84- return loggingInterceptor ;
85- }
86-
8778 private static final class GraphiteMetric {
8879 private final String name ;
8980 private final int interval ;
@@ -100,16 +91,20 @@ public GraphiteMetric(@JsonProperty("name") String name,
10091 this .time = time ;
10192 }
10293
103- public String getName () {
94+ @ SuppressWarnings ("unused" )
95+ public String getName () {
10496 return name ;
10597 }
106- public int getInterval () {
98+ @ SuppressWarnings ("unused" )
99+ public int getInterval () {
107100 return interval ;
108101 }
109- public double getValue () {
102+ @ SuppressWarnings ("unused" )
103+ public double getValue () {
110104 return value ;
111105 }
112- public long getTime () {
106+ @ SuppressWarnings ("unused" )
107+ public long getTime () {
113108 return time ;
114109 }
115110 }
0 commit comments