@envelop/prometheus
Advanced tools
Comparing version 10.0.0-alpha-20240429150713-f648c855 to 10.0.0-alpha-20240503114356-10955cdf
{ | ||
"name": "@envelop/prometheus", | ||
"version": "10.0.0-alpha-20240429150713-f648c855", | ||
"version": "10.0.0-alpha-20240503114356-10955cdf", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
@@ -98,3 +98,3 @@ ## `@envelop/prometheus` | ||
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql' | ||
import { Histogram } from 'prom-client' | ||
import { Histogram, register as registry } from 'prom-client' | ||
import { envelop, useEngine } from '@envelop/core' | ||
@@ -127,1 +127,22 @@ import { createHistogram, usePrometheus } from '@envelop/prometheus' | ||
``` | ||
## Caveats | ||
Due to Prometheus client API limitations, if this plugin is initialized multiple times, only the | ||
metrics configuration of the first initialization will be applied. | ||
If necessary, use a different registry instance for each plugin instance, or clear the registry | ||
before plugin initialization. | ||
```ts | ||
function usePrometheusWithRegistry() { | ||
const registry = new Registry() | ||
return usePrometheus({ | ||
registry, | ||
... | ||
}) | ||
} | ||
``` | ||
Keep in mind that this implies potential data loss in pull mode if some data is produced between | ||
last pull and the re-initialization of the plugin. |
70296
147