protected void sendMetric ( MetricBuilder metricBuilder ) throws ReportingException { try { HttpClient client = new HttpClient ( "http://" + this . server + ":" + this . port ) ; Response response = client . pushMetrics ( metricBuilder ) ; //check if response is ok if ( response . getStatusCode ( ) / 100 != 2 ) { LOGGER . error ( "Kairos DB reported error. Status code: " + response . getStatusCode ( ) ) ; LOGGER . error ( "Error message: " + response . getErrors ( ) ) ; throw new ReportingException ( ) ; } else { LOGGER . debug ( "Kairos DB returned OK. Status code: " + response . getStatusCode ( ) ) ; } client . shutdown ( ) ; } catch ( MalformedURLException | URISyntaxException e ) { throw new ConfigurationException ( e ) ; } catch ( IOException e ) { LOGGER . error ( "Could not request KairosDB." , e ) ; throw new ReportingException ( e ) ; } }
Sends a metric to the kairos server .