SkeLLLa / fastify-metrics

Prometheus metrics exporter for Fastify
https://savelife.in.ua/en/donate-en/
MIT License
96 stars 33 forks source link

Add hook names #94

Open kibertoad opened 9 months ago

kibertoad commented 9 months ago

This provides readable names for hook invocations in stacktraces and observability tools like New Relic.

kibertoad commented 9 months ago

@SkeLLLa None of the CI errors seem to relate to changes in the PR. Do builds work on main OK?

kibertoad commented 9 months ago

Update: https://github.com/SkeLLLa/fastify-metrics/pull/95 is passing, so this is something that I broke. Will check.

SkeLLLa commented 9 months ago

Yeah, failing check look weird. Maybe there's some this binding is lost during the transition from arrow functions to plain functions.

Maybe as workaround you could try just named arrow functions like const onSomething = () => { ... }

kibertoad commented 9 months ago

sure, if current version doesn't work, will use named arrow functions!

kibertoad commented 9 months ago

@SkeLLLa problem with const namedArrowFunction is that this approach requires making quite a few FastifyMetrics fields/methods to become public :-/. Wonder if there even exists a good solution here.