63
63
* aggregation layer as a first-class metric type.
64
64
*
65
65
* Except for the differences described above this parser supports both the
66
- * traditional and Data Dog variants of the statsd protocol as defined here:
66
+ * traditional, Data Dog, and Influx variants of the statsd protocol as defined here:
67
67
*
68
68
* https://github.com/b/statsd_spec
69
69
* https://docs.datadoghq.com/guides/dogstatsd/
70
+ * https://github.com/influxdata/telegraf/tree/master/plugins/inputs/statsd#influx-statsd
70
71
*
71
72
* @author Ville Koskela (ville dot koskela at inscopemetrics dot com)
72
73
*/
@@ -164,7 +165,7 @@ private Number parseValue(
164
165
// See: https://github.com/findbugsproject/findbugs/issues/79
165
166
private ImmutableMap <String , String > parseTags (@ Nullable final String tagsAsString ) {
166
167
if (null != tagsAsString ) {
167
- return ImmutableMap .copyOf (Splitter . on ( ',' ). withKeyValueSeparator ( ':' ) .split (tagsAsString ));
168
+ return ImmutableMap .copyOf (TAG_SPLITTER .split (tagsAsString ));
168
169
}
169
170
return ImmutableMap .of ();
170
171
}
@@ -173,7 +174,7 @@ private ImmutableMap<String, String> parseTags(@Nullable final String tagsAsStri
173
174
// See: https://github.com/findbugsproject/findbugs/issues/79
174
175
private ImmutableMap <String , String > parseInfluxStyleTags (@ Nullable final String tagsAsString ) {
175
176
if (null != tagsAsString ) {
176
- return ImmutableMap .copyOf (Splitter . on ( ',' ). withKeyValueSeparator ( '=' ) .split (tagsAsString ));
177
+ return ImmutableMap .copyOf (INFLUX_STYLE_TAGS_SPLITTER .split (tagsAsString ));
177
178
}
178
179
return ImmutableMap .of ();
179
180
}
@@ -250,6 +251,8 @@ public StatsdToRecordParser() {
250
251
private static final ThreadLocal <NumberFormat > NUMBER_FORMAT = ThreadLocal .withInitial (NumberFormat ::getInstance );
251
252
private static final Pattern STATSD_PATTERN = Pattern .compile (
252
253
"^(?<NAME>[^:@|,]+)(,(?<INFLUXTAGS>[^:@|]+))?:(?<VALUE>[^|]+)\\ |(?<TYPE>[^|]+)(\\ |@(?<SAMPLERATE>[^|]+))?(\\ |#(?<TAGS>.+))?$" );
254
+ private static final Splitter .MapSplitter INFLUX_STYLE_TAGS_SPLITTER = Splitter .on (',' ).withKeyValueSeparator ('=' );
255
+ private static final Splitter .MapSplitter TAG_SPLITTER = Splitter .on (',' ).withKeyValueSeparator (':' );
253
256
254
257
private enum StatsdType {
255
258
COUNTER ("c" , MetricType .COUNTER , null ),
0 commit comments