File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
main/java/com/datadoghq/datadog_lambda_java
test/java/com/datadoghq/datadog_lambda_java Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 33import com .timgroup .statsd .NonBlockingStatsDClientBuilder ;
44import com .timgroup .statsd .StatsDClient ;
55
6+ import java .util .stream .Collectors ;
7+
68abstract class MetricWriter {
79 private static MetricWriter IMPL ;
810 public static synchronized MetricWriter getMetricWriterImpl (){
@@ -59,14 +61,17 @@ public ExtensionMetricWriter() {
5961 @ Override
6062 public void write (CustomMetric cm ){
6163 if (null != client ) {
62- StringBuilder tagsSb = new StringBuilder () ;
64+ String tags = "" ;
6365 if (cm .getTags () != null ) {
64- cm .getTags ().forEach ((k , val ) ->
65- tagsSb .append (k .toLowerCase ())
66- .append (":" )
67- .append (val .toString ().toLowerCase ()));
66+ tags = cm
67+ .getTags ()
68+ .entrySet ()
69+ .stream ()
70+ .map (
71+ entry -> entry .getKey ().toLowerCase () + ":" + entry .getValue ().toString ().toLowerCase ()
72+ ).collect (Collectors .joining ("," ));
6873 }
69- client .distribution (cm .getName (), cm .getValue (), tagsSb . toString () );
74+ client .distribution (cm .getName (), cm .getValue (), tags );
7075 } else {
7176 DDLogger .getLoggerImpl ().error ("Could not write the metric because the client is null" );
7277 }
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public void run() {
9090 if (null == text [0 ] || text [0 ].equals ("notYetReceived" )) {
9191 Thread .sleep (1000 );
9292 } else {
93- assertTrue (text [0 ].startsWith ("foo:24.3|d|#firsttag:firsttagvaluesecondtag :100.34" ));
93+ assertTrue (text [0 ].startsWith ("foo:24.3|d|#firsttag:firsttagvalue,secondtag :100.34" ));
9494 break ;
9595 }
9696 }
You can’t perform that action at this time.
0 commit comments