Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for custom metrics #10

Closed
allevo opened this issue Jul 8, 2020 · 3 comments
Closed

Docs for custom metrics #10

allevo opened this issue Jul 8, 2020 · 3 comments

Comments

@allevo
Copy link

allevo commented Jul 8, 2020

Hi, thanks for your amazing repo!

I would like to gather some custom metrics but I didn't find some tests that describe this kind of feature. Is it possible to add a custom gauge to prom-client. If yes, how?

I can send you a PR if needed.

@SkeLLLa
Copy link
Owner

SkeLLLa commented Jul 8, 2020

Yes, it's possible. Plugin expose client which is standard instance of prom-client. So you can use it just as usual prom-client. Try it out fastify.metrics.client. If it works, then we can add more detailed docs.

Actually there are few docs in https://github.com/SkeLLLa/fastify-metrics/blob/master/docs/interfaces/_fastify_.fastifyinstance.md#metrics, but it requires to go deeper to discover what's in there.

@wyozi
Copy link

wyozi commented Apr 19, 2021

Custom metrics seem to just work when you create them using the FastifyInstance client.

const socketGauge = new fastify.metrics.client.Gauge({
  name: 'notification_sockets_open',
  help: 'Number of notification websockets open',
  collect() {
    this.set(sockets.length)
  }
})

@petef19
Copy link

petef19 commented Sep 30, 2021

comment deleted. false alarm.

SkeLLLa added a commit that referenced this issue Jul 3, 2022
fastify v4 support

 major refactor

 new config

BREAKING CHANGE: new configuration (incompatible with all previous versions)

Closes #44, #41, #10
SkeLLLa added a commit that referenced this issue Jul 3, 2022
fastify v4 support

 major refactor

 new config

BREAKING CHANGE: new configuration (incompatible with all previous versions)

Closes #44, #41, #10
@SkeLLLa SkeLLLa closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants