diff --git a/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/GraphiteSeriesDataServlet.java b/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/GraphiteSeriesDataServlet.java index c6a4d009..b86670ef 100644 --- a/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/GraphiteSeriesDataServlet.java +++ b/carbonj.service/src/main/java/com/demandware/carbonj/service/engine/GraphiteSeriesDataServlet.java @@ -97,6 +97,13 @@ protected void doGet( HttpServletRequest req, HttpServletResponse res ) { res.setContentType( "application/json" ); } + else if ( protobuf ) + { + LOG.info( "carbonapi request: found protobuf request" ); + res.setContentType( "application/protobuf" ); + target = req.getParameter( "query" ); + LOG.info( "carbonapi request: query: " + target + " --- blacklist: " + queryBlacklist ); + } else { res.setContentType( "application/pickle" ); @@ -144,9 +151,11 @@ protected void doGet( HttpServletRequest req, HttpServletResponse res ) } else if ( protobuf ) { + LOG.info( "carbonapi request: processing request" ); List seriesList = store.fetchSeriesData( new Query( target, Integer.parseInt( from ), Integer.parseInt( until ), now, System.currentTimeMillis() ) ); + LOG.info( "carbonapi request: formatting response" ); OutputStream output = res.getOutputStream(); List metricsSeriesList = new ArrayList(); @@ -155,7 +164,9 @@ else if ( protobuf ) List valuesList = new ArrayList(); for ( Double value : series.values ) { - valuesList.add( MetricsResponse.Value.newBuilder().setValue( value ).build() ); + + valuesList.add( + MetricsResponse.Value.newBuilder().setValue( value == null ? (double) 0 : value ).build() ); } MetricsResponse.Series metricsSeries = MetricsResponse.Series.newBuilder().setName( series.name ).setStart( series.start ) @@ -167,15 +178,22 @@ else if ( protobuf ) MetricsResponse.SeriesList response = MetricsResponse.SeriesList.newBuilder().addAllSeriesList( metricsSeriesList ).build(); + LOG.info( "carbonapi request: done formatting response" ); + try { + LOG.info( "carbonapi request: writing response" ); response.writeTo( output ); } + catch ( Exception e ) + { + LOG.error( "carbonapi request: error writing response", e.getMessage() ); + } finally { output.close(); } - } + } else { ResponseStream seriesStream = new GraphitePickler( false, res.getOutputStream() ); diff --git a/gradle.properties b/gradle.properties index 5bebe806..31d5cb34 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=1.1.29 +version=pmoineau.W-13680300.carbonj-protobuf.v1.1.29-SNAPSHOT org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=2048m org.gradle.daemon=true ccGradlePluginVersion = 3.0.3