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 3
3
import com .timgroup .statsd .NonBlockingStatsDClientBuilder ;
4
4
import com .timgroup .statsd .StatsDClient ;
5
5
6
+ import java .util .stream .Collectors ;
7
+
6
8
abstract class MetricWriter {
7
9
private static MetricWriter IMPL ;
8
10
public static synchronized MetricWriter getMetricWriterImpl (){
@@ -59,14 +61,17 @@ public ExtensionMetricWriter() {
59
61
@ Override
60
62
public void write (CustomMetric cm ){
61
63
if (null != client ) {
62
- StringBuilder tagsSb = new StringBuilder () ;
64
+ String tags = "" ;
63
65
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 ("," ));
68
73
}
69
- client .distribution (cm .getName (), cm .getValue (), tagsSb . toString () );
74
+ client .distribution (cm .getName (), cm .getValue (), tags );
70
75
} else {
71
76
DDLogger .getLoggerImpl ().error ("Could not write the metric because the client is null" );
72
77
}
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public void run() {
90
90
if (null == text [0 ] || text [0 ].equals ("notYetReceived" )) {
91
91
Thread .sleep (1000 );
92
92
} 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" ));
94
94
break ;
95
95
}
96
96
}
You can’t perform that action at this time.
0 commit comments