fastify / fastify/help

@fastify/otel: Ignoring or disabling a path does not affect sub-spans

Open
#1,101 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

Description

## 💬 Question here

Hi,

I have a health endpoint that is often called and I want to disable all tracing for the endpoint and any sub-spans that may occor. I've tried using the `ignorePaths` and route config (`config { otel: false }`), and they do disable the endpoint in question, but any sub-spans are still registered, e.g. `@opentelemetry/instrumentation-http` and DB calls are still traced and are reported as root-spans. This creates more spam than just enabling the endpoint. I can't imagine this is the inteded way it should work, what am I doing wrong?

I tried using a parent based sampler but that has no affect.

```typescript
export const fastifyOtelInstrumentation = new FastifyOtelInstrumentation({
registerOnInitialization: true,
ignorePaths: (opts) => {
return opts.url.startsWith('/healthz');
},
});

sdk = new NodeSDK({
sampler: new ParentBasedSampler({
root: new AlwaysOnSampler(),
}),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fastify': {
enabled: false,
},
}),
],
})
sdk.start()
```

## Your Environment

- *node version*: 22.16
- *fastify version*: 5.3.3
- *fastify/otel version*: 0.9.1
- *os*: Linux

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.