SigNoz Cloud - This page is relevant for SigNoz Cloud editions.
Self-Host - This page is relevant for self-hosted SigNoz editions.

Exclude HTTP endpoints in Node.js

By default, OpenTelemetry automatically instruments all incoming and outgoing HTTP requests. However, endpoints like health checks (/health), readiness probes, or metrics (/metrics) can generate a lot of noise in your traces.

This guide shows you how to filter out these requests by configuring the HttpInstrumentation hook so they don't produce spans.

Prerequisites

Configure HttpInstrumentation

The HttpInstrumentation class allows you to define an ignoreIncomingRequestHook. This hook is a function that receives the request object (req). If it returns true, the request is ignored and no span is created.

⚠️ Warning

In case you're using zero-code instrumentation, HTTP endpoints cannot be configured through environment variables. You'll need to switch to programmatic instrumentation by creating an instrumentation.js file as shown below and loading it with node -r ./instrumentation.js app.js. See Node.js OpenTelemetry Instrumentation for the complete setup guide.

If you are using getNodeAutoInstrumentations, pass the configuration to the @opentelemetry/instrumentation-http key. The getNodeAutoInstrumentations helper allows you to configure specific instrumentations by name.

instrumentation.js
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { NodeSDK } = require('@opentelemetry/sdk-node');
// ... other imports

const sdk = new NodeSDK({
  // ... other config
  instrumentations: [
    getNodeAutoInstrumentations({
      '@opentelemetry/instrumentation-http': {
        ignoreIncomingRequestHook(req) {
            // Exclude common health check paths
            const excludedPaths = [
                /^\/health/, 
                /^\/ready/, 
                /^\/metrics/
            ];
            return excludedPaths.some(pattern => pattern.test(req.url));
        },
      },
    }),
  ],
});

sdk.start();

Validate

  1. Run your application with the new configuration:
    node -r ./instrumentation.js app.js
    
  2. Generate traffic to the excluded endpoints (e.g., curl http://localhost:3000/health).
  3. Generate traffic to included endpoints (e.g., curl http://localhost:3000/api/users).
  4. Go to the Traces tab in SigNoz.
  5. Verify that you only see traces for the included endpoints.
Sample trace output showing HTTP endpoints except health checks
Sample traces after excluding health checks

Troubleshooting

Still seeing traces for excluded endpoints?

  • Check Regex/Conditions: req.url includes the path and query string (e.g., /health?id=1). Avoid using strict equality (===) for partial matches; use .startsWith() or regex instead. Log req.url to debug.
  • Instrumentation Order: If using manual instrumentation, ensure HttpInstrumentation is initialized and passed to the SDK.
  • Multiple Instrumentations: If you use both auto-instrumentations and manual instances, they might conflict. Prefer one method.

Enable debug logging

Set OTEL_LOG_LEVEL=debug to see if the instrumentation is initialized and if spans are being created/dropped.

Next Steps

Get Help

If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack.

If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.

Last updated: March 26, 2026

Edit on GitHub