Metrics plugin prometheus metrics for your GraphQL Eventbus. To use it, you must have installed prom-client
required as a npm peer dependency.
npm i graphql-eventbus-metrics-plugin
# Peer dependency
npm i prom-client
import { MetricsPlugin } from 'graphql-eventbus-metrics-plugin'
const myBus = new MyBus({
...,
plugins: [MetricsPlugin()]
})
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.