immobiliare / fastify-metrics

πŸ“Š Fastify plugin that integrates metrics collection and dispatch to statsd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignore routes without an id

dnlup opened this issue Β· comments

commented
Ignore routes without an id

What happens if I don't pass an ID, but I use inside the route sendGaugeMetric, do we need to metric it or not? I think in this case, we can don't decorate the request/reply with the methods.

commented

πŸ€” that's a good point. I think maybe we could either:

  • handle this internally using the same strategy:
    • use an util function to check if the route should be skipped and use it manually in each method that send a metric
    • centralise this check somehow, maybe with a proxy approach or something that allows us to call those methods with the check baked in
  • decorate req and reply with a boolean that says if the route should be ignored and let the user handle it

I need to think about it a little more, do you have something else in mind?

The problem is that the label function, in this case, has no id. Then if I allow using the function, I will enable the user to send a metric without an ID. From my view we have these possibilities:

  • Make sendMetrics nope functions, but I don't like it.
  • do sendMetrics throw
    WDYT?

Another point is that because we make ID required, can we evaluate the possibility of making it more visible?

commented

The problem is that the label function, in this case, has no id.

πŸ€” The label function should be able to access the routeId from <request|reply>.context.config.metrics.routeId or options.config.metrics.routeId. Does that solves the problem for you?

sendMetrics should not throw, it would be against the concept of ignoring a route.

commented

Another point is that because we make ID required, can we evaluate the possibility of making it more visible?

What do you mean by "more visible"?

πŸŽ‰ This issue has been resolved in version 2.0.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€