Closed mattnworb closed 3 years ago
I think this behavior has existed since c9cc31273ff62dd3f126d02adb0cb490f4fe2097
https://github.com/spotify/semantic-metrics/pull/102 Thanks @mattnworb :)
Fix in semantic metrics 1.1.7.
Will roll this out to apollo with some warnings shortly.
I am using
FastForwardReporter
v1.1.1 via Apollo's metrics module (https://github.com/spotify/apollo/blob/1.x/modules/metrics/src/main/java/com/spotify/apollo/metrics/MetricsModule.java), which builds a reporter with prefix ofMetricId.build("apollo")
(plus some tags).If I run ffwd locally to see what metrics are sent by a locally-running service to ffwd, I see that some metrics are sent with
key=apollo
and some are sent withkey=apollo.apollo
, and I think the latter is caused by logic in FastForwardReporter itself.Note that the same
what
is reported underkey=apollo
andkey=apollo.apollo
, while the application code does not set any key at all for this MetricId.I think I know what causes this:
On each tick when
report(..)
is called, it will iterate over all gauges, counters, histograms, meters, timers, etc:https://github.com/spotify/semantic-metrics/blob/2bee9e7f8e80779e7a7cfaa463a56a91dfffe2c1/ffwd-reporter/src/main/java/com/spotify/metrics/ffwd/FastForwardReporter.java#L239
reportMetered(MetricId, Meter)
will overwrite theMetricId
argument in order to prependthis.prefix
to the suppliedMetricId
, and then translate theMetricId
into acom.spotify.ffwd.Metric
instance: https://github.com/spotify/semantic-metrics/blob/2bee9e7f8e80779e7a7cfaa463a56a91dfffe2c1/ffwd-reporter/src/main/java/com/spotify/metrics/ffwd/FastForwardReporter.java#L299-L309since a Meter is also a Counter, the last line of
reportMetered(MetricId, Meter)
callsreportCounter(MetricId, Meter)
, but with the overwritten MetricId (which hadthis.prefix
prepended onto it), which repeats the same prepend operation before translating theMetricId
into acom.spotify.ffwd.Metric
instance:https://github.com/spotify/semantic-metrics/blob/2bee9e7f8e80779e7a7cfaa463a56a91dfffe2c1/ffwd-reporter/src/main/java/com/spotify/metrics/ffwd/FastForwardReporter.java#L277-L283
This will result in the
FastForwardReporter
'sprefix
field being prepended twice into the metric's ID. ~reportTimer
has the same behavior~ (update: I was wrong on this).An easy fix here would be for
reportMeter
andreportTimer
to pass the originalMetricId
, not the overwritten one, intoreportCounter
.