mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-03 02:21:44 +00:00
test(mcp): assert documented bucket boundaries land in the Prom scrape
The existing bucket tests pinned the exported JS constants; the views[] wiring in MeterProvider could be deleted and they would still pass. This test boots a real exporter, makes one observation, and asserts every documented boundary appears as an le= label on the bucket lines.
This commit is contained in:
parent
6b37e6e228
commit
f13bd3c4c6
1 changed files with 24 additions and 0 deletions
|
|
@ -256,4 +256,28 @@ describe('bucket boundary contract', () => {
|
|||
it('publishes the documented result-size buckets verbatim', () => {
|
||||
expect(RESULT_BYTES_BUCKETS).toEqual([512, 2048, 8192, 32768, 131072, 524288, 2097152]);
|
||||
});
|
||||
|
||||
it('exposes the documented bucket boundaries in the Prometheus scrape', async () => {
|
||||
process.env['GITNEXUS_OTEL_METRICS'] = 'on';
|
||||
await withRandomPort(async () => {
|
||||
const init = await initMetrics();
|
||||
await observe(
|
||||
'context',
|
||||
async () => ({ content: [{ type: 'text', text: 'x' }] }),
|
||||
(r) => Buffer.byteLength(r.content[0]!.text, 'utf8'),
|
||||
() => false,
|
||||
);
|
||||
const text = await fetch(`http://127.0.0.1:${init.port}/metrics`).then((r) => r.text());
|
||||
for (const b of DURATION_BUCKETS_SECONDS) {
|
||||
expect(text).toMatch(
|
||||
new RegExp(`gitnexus_mcp_tool_request_duration_seconds_bucket\\{[^}]*le="${b}"\\}`),
|
||||
);
|
||||
}
|
||||
for (const b of RESULT_BYTES_BUCKETS) {
|
||||
expect(text).toMatch(
|
||||
new RegExp(`gitnexus_mcp_tool_result_bytes_bucket\\{[^}]*le="${b}"\\}`),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue