Metrics for graphql eventbus
npm install graphql-eventbus-metrics-pluginMetrics plugin prometheus metrics for your GraphQL Eventbus. To use it, you must have installed prom-client required as a npm peer dependency.
``bash`
npm i graphql-eventbus-metrics-pluginPeer dependency
npm i prom-client
`typescript`
import { MetricsPlugin } from 'graphql-eventbus-metrics-plugin'
const myBus = new MyBus({
...,
plugins: [MetricsPlugin()]
})
`typescript title="router.ts"
import { register } from "prom-client";
import * as express from "express";
const app = express();
app.get("/metrics", async (_, res) => {
res.set("Content-Type", register.contentType);
res.send(await register.metrics());
});
`
This plugins exposes the follwing metrics:
The number of messages published without error
The number of messages published that have encountered errors.
The number of messages published that have encountered errors.
The number of messages consumed that encountered an error
The time to consume a message successfully
The time to consume a message successfully since it was first published. We track this metrics using publishedAt field in the GraphQLEventbusMetadata`.
The time it takes to publish a message in ms.