I'm using micrometer to publish several different metrics to Datadog; among these there is the number of items processed by several different batch jobs which can be pretty sparse.
Some batch jobs have different intervals, some others are triggered by external events so they don't have a fixed interval at all.
However, my micrometer configuration has a step
of 30s, which I don't want to change, as suggested in this question, because I have denser metrics that need to be tracked every 30s.
This means that every 30s, unless a batch job has just run, my application is publishing a zero for each batch job metric, polluting them.
I've been trying to handle this on Datadog by using its rollup function, but i don't know the rollup interval beforehand because the interval may be variable for jobs triggered by external events.
Another solution i'm considering is to extend the DataDogMeterRegistry
to have it clear all metrics right after publishing, so that it will only publish metrics that registered in the latest 30s interval, but I was wondering if there was a clearer way to prevent micrometer from sending zeroes for sparse metrics.