Florian Thelliez
06/22/2022, 2:31 PMFlorian Thelliez
06/22/2022, 3:30 PMAustin
06/22/2022, 8:58 PMtype PrismaJsonMetrics = Awaited<ReturnType<typeof prisma.$metrics.json>>
I have a little trouble understand what the diffing on histograms is for, I wouldn’t mind a clarification on what is done in this example.In the docs page you linked, we make this note:
Note: You must provide counter metrics to StatsD as a series of values that are incremented or decremented from a previous retrieval of the metrics. However, Prisma counter metrics return absolute values. Therefore, you must convert your counter metrics to a series of incremented and decremented values and send them to StatsD as gauge data. In the code example below, we convert counter metrics into incremented and decremented gauge data inSo, we do the diffing in order to convert the metrics JSON into the correct format for StatsD. Let me know if I can clarify anything further!.diffHistograms
Florian Thelliez
06/23/2022, 7:26 AMyou might be able to extract them using TypeScript’s utility types:I did at first but I had to copy the types eventually to manage to remove all the `any`s in your example since I retrieving the type of arrays elements can be tricky and was taking me way too long. In my case getting Datadog to scrape the metrics would be the better solution but I have issues that are non-prisma related which make this approach a lot easier to implement to test those metrics.
Florian Thelliez
06/23/2022, 7:27 AM> we convert counter metrics into incremented and decremented gauge data inI understood, though it’s a bit hard to understand exactly how it’s done at first 😅.diffHistograms
Florian Thelliez
06/23/2022, 7:28 AMAustin
06/23/2022, 2:44 PMFlorian Thelliez
06/23/2022, 3:13 PMAlexandr Bordun
06/29/2022, 2:51 PMconst otelSDK = new NodeSDK({
metricExporter: new PrometheusExporter({ port: 8081, endpoint: '/metrics' }),
metricInterval: 5000,
// spanProcessor: new BatchSpanProcessor(new JaegerExporter()),
contextManager: new AsyncLocalStorageContextManager(),
textMapPropagator: new CompositePropagator({
propagators: [
new JaegerPropagator(),
new W3CTraceContextPropagator(),
new W3CBaggagePropagator(),
new B3Propagator(),
new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })
]
}),
instrumentations: [
new AmqplibInstrumentation(),
new DnsInstrumentation(),
new ExpressInstrumentation(),
new GraphQLInstrumentation(),
new HttpInstrumentation(),
new IORedisInstrumentation(),
new NestInstrumentation(),
new NetInstrumentation(),
new PgInstrumentation(),
new PinoInstrumentation()
]
});
export default otelSDK;
what’s the correct way of re-exporting Prisma metrics in this setup?Matt Mueller (Prisma Client PM)
Matt Mueller (Prisma Client PM)
// Send the current state of metrics every minute
setInterval(() => {
prisma.$metrics().then(metrics => {
otel.sendMetrics(metrics) // not sure how sending metrics works in otel
})
}, 60000)
Florian Thelliez
07/01/2022, 3:30 PMFlorian Thelliez
07/01/2022, 3:30 PMFlorian Thelliez
07/01/2022, 3:30 PMAlexandr Bordun
07/01/2022, 3:38 PMotel.sendMetrics()
that’s one thing I have problems with, the rest is not a problem.
@Florian Thelliez I do have a collector, and metrics are exposed for Prometheus already (by exposing other app metrics)
I just need to find a way to stitch these metrics with prisma’sMatt Mueller (Prisma Client PM)
the problem is that prisma.metrics returns a set of pregenerated counters/gauges/etc (or even the generated output), so it works rather as a standalone otel instance (which in most of the cases - won’t be true, there will be some other app metrics)I would have thought the opposite. That prisma metrics aren't a standalone otel instance. However you send your app metrics is how you send your prisma metrics.