Skip to content

Commit 655f7e3

Browse files
committed
fix: suppress health check telemetry
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 3d07cc4 commit 655f7e3

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/telemetry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ async function initializeTelemetryRuntime(options: InitializeTelemetryOptions):
128128
const instrumentations: Instrumentation[] = [
129129
new HttpInstrumentation({
130130
ignoreIncomingRequestHook: (request) => {
131-
return requestPath(request.url) === "/metrics" && mcpHttpPath !== "/metrics";
131+
const path = requestPath(request.url);
132+
return (path === "/metrics" && mcpHttpPath !== "/metrics")
133+
|| (path === "/healthz" && mcpHttpPath !== "/healthz");
132134
},
133135
requestHook: (span, request) => {
134136
if (!mcpHttpPath || !isIncomingRequest(request) || requestPath(request.url) !== mcpHttpPath) {

test/otel-export.test.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ test("exports correlated MCP traces, metrics, and logs over OTLP/HTTP JSON", { t
2727
new URL(`http://127.0.0.1:${child.port}/redash-mcp`),
2828
);
2929

30+
const healthResponse = await fetch(`http://127.0.0.1:${child.port}/healthz`);
31+
assert.equal(healthResponse.status, 200);
32+
assert.equal(await healthResponse.text(), "ok");
33+
3034
await client.connect(transport);
3135
await client.callTool({
3236
name: "list_queries",
@@ -80,6 +84,12 @@ test("exports correlated MCP traces, metrics, and logs over OTLP/HTTP JSON", { t
8084
assert.ok(collector.payloads.logs.length > 0, "log exports should reach /v1/logs");
8185

8286
const spans = collector.payloads.traces.flatMap(flattenSpans);
87+
const healthSpans = spans.filter((span) => {
88+
const attributes = spanAttributes(span);
89+
return attributes["url.path"] === "/healthz"
90+
|| String(attributes["url.full"] ?? "").includes("/healthz");
91+
});
92+
assert.equal(healthSpans.length, 0, "health probes should not create HTTP spans");
8393
const toolSpan = spans.find((span) => span.name === "tools/call list_queries");
8494
assert.ok(toolSpan, "the list_queries MCP span should be exported");
8595
assert.equal(toolSpan.traceId, "11111111111111111111111111111111");

0 commit comments

Comments
 (0)