@@ -30,40 +30,40 @@ protected static void submitClientDurationMetric(final ApiHttpRequest request, f
3030 final double durationInMillis , final ApiHttpResponse <byte []> response ) throws ApiException {
3131 final String name = PREFIX + "." + CLIENT_DURATION ;
3232 final MetricIntakeType type = MetricIntakeType .UNSPECIFIED ;
33- submitMetricWithHttpTags (name , durationInMillis , type , request , apiInstance , response );
33+ submitMetricWithHttpTags (name , durationInMillis , type , "ms" , request , apiInstance , response );
3434 }
3535
3636 protected static void submitErrorRequestsMetric (final ApiHttpRequest request , final MetricsApi apiInstance ,
3737 final ApiHttpResponse <byte []> response ) throws ApiException {
3838 final String name = PREFIX + "." + CLIENT_REQUEST_ERROR ;
3939 final MetricIntakeType count = MetricIntakeType .COUNT ;
40- submitMetricWithHttpTags (name , 1.0 , count , request , apiInstance , response );
40+ submitMetricWithHttpTags (name , 1.0 , count , "count" , request , apiInstance , response );
4141 }
4242
4343 protected static void submitTotalRequestsMetric (final ApiHttpRequest request , final MetricsApi apiInstance ,
4444 final ApiHttpResponse <byte []> response ) throws ApiException {
4545 final String name = PREFIX + "." + CLIENT_REQUEST_TOTAL ;
4646 final MetricIntakeType count = MetricIntakeType .COUNT ;
47- submitMetricWithHttpTags (name , 1.0 , count , request , apiInstance , response );
47+ submitMetricWithHttpTags (name , 1.0 , count , "count" , request , apiInstance , response );
4848 }
4949
5050 private static void submitMetricWithHttpTags (final String name , final double value , final MetricIntakeType type ,
51- final ApiHttpRequest request , final MetricsApi apiInstance , final ApiHttpResponse < byte []> response )
52- throws ApiException {
51+ final String unit , final ApiHttpRequest request , final MetricsApi apiInstance ,
52+ final ApiHttpResponse < byte []> response ) throws ApiException {
5353 final List <String > tags = Arrays .asList (format ("%s:%s" , HTTP_RESPONSE_STATUS_CODE , response .getStatusCode ()),
5454 format ("%s:%s" , HTTP_REQUEST_METHOD , request .getMethod ().name ()),
5555 format ("%s:%s" , SERVER_ADDRESS , request .getUri ().getHost ()));
5656 if (request .getUri ().getPort () > 0 ) {
5757 tags .add (format ("%s:%s" , SERVER_PORT , request .getUri ().getPort ()));
5858 }
59- submitMetric (apiInstance , name , value , type , tags );
59+ submitMetric (apiInstance , name , value , type , unit , tags );
6060 }
6161
6262 protected static void submitJsonSerializationMetric (final MetricsApi apiInstance , final double durationInMillis ,
6363 final String responseBodyType ) {
6464 try {
6565 submitMetric (apiInstance , PREFIX + "." + JSON_SERIALIZATION , durationInMillis , MetricIntakeType .UNSPECIFIED ,
66- Arrays .asList (format ("%s:%s" , RESPONSE_BODY_TYPE , responseBodyType )));
66+ "ms" , Arrays .asList (format ("%s:%s" , RESPONSE_BODY_TYPE , responseBodyType )));
6767 }
6868 catch (ApiException exception ) {
6969 logger .warn ("Failed to submit commercetools json serialization metric" , exception );
@@ -74,17 +74,18 @@ protected static void submitJsonDeserializationMetric(final MetricsApi apiInstan
7474 final String requestBodyType ) {
7575 try {
7676 submitMetric (apiInstance , PREFIX + "." + JSON_DESERIALIZATION , durationInMillis ,
77- MetricIntakeType .UNSPECIFIED , Arrays .asList (format ("%s:%s" , REQUEST_BODY_TYPE , requestBodyType )));
77+ MetricIntakeType .UNSPECIFIED , "ms" , Arrays .asList (format ("%s:%s" , REQUEST_BODY_TYPE , requestBodyType )));
7878 }
7979 catch (ApiException exception ) {
8080 logger .warn ("Failed to submit commercetools json deserialization metric" , exception );
8181 }
8282 }
8383
8484 private static void submitMetric (final MetricsApi apiInstance , final String name , final double value ,
85- final MetricIntakeType type , final List <String > tags ) throws ApiException {
85+ final MetricIntakeType type , final String unit , final List <String > tags ) throws ApiException {
8686 MetricPayload totalMetric = new MetricPayload ().series (Collections .singletonList (new MetricSeries ().metric (name )
8787 .type (type )
88+ .unit (unit )
8889 .points (Collections .singletonList (
8990 new MetricPoint ().timestamp (OffsetDateTime .now ().toInstant ().getEpochSecond ()).value (value )))
9091 .tags (tags )));
0 commit comments