Sending no data point in registerMetric callback

I'm migrating an app from New Relic, and I'm trying to use registerMetric to give me a custom metric. The metric I'm recording is a duration average, so I'm collecting durations and a count of durations so that when the callback passed to registerMetric is called I can send the average as a response and reset the accumulators. Seems straightforward, but what should I return to indicate that there is no data available for a sampling window (when my divisor is 0). I tried returning null, but then the validation logic for registerMetric said that the function must return a number.

Is there a way to signal "no data" for a custom metric, or am I doomed to have ugly data like 0's?

@apoco Thanks for the question. Unfortunately, no, the Node.js APM agent's registerMetric handling doesn't provide a way to say "there is no value for this period" for a metric. Returning null or undefined from the registered callback results in the agent still sending an empty value for that metric, which gets translated to the zero numeric (because registerMetric supports only Gauge metric types) value, i.e. 0.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.