OpenTelemetry Node.js zero-code instrumentation

How to trace Node.js services with the auto-instrumentations-node package, configure them through environment variables, and recognize where zero-code tracing stops and manual code is needed.

On this page

What OpenTelemetry Node.js zero-code instrumentation gives your team

If your organization runs Node.js services across many repositories and needs distributed traces without rewriting each application, zero-code instrumentation is the starting point. It uses the @opentelemetry/api and @opentelemetry/auto-instrumentations-node packages to capture telemetry from popular libraries such as HTTP clients and servers, and it is configured through environment variables rather than application code. For a platform team, that means one repeatable change to startup configuration can be applied across services, with application owners keeping their code as it is.

Two choices sit outside the instrumentation itself, and they should be made separately. OpenTelemetry is not an observability backend: it generates and exports telemetry, while storage and visualization are handled by other tools. The Collector is a separate component that receives, processes and forwards that data, and it can run beside services or as a central gateway. Services can export directly to a backend, but routing through a Collector lets you change backends, apply redaction and manage credentials without redeploying every Node.js service.

Before rollout, confirm the package versions your services will use against the current OpenTelemetry JavaScript zero-code documentation, and list which libraries your services depend on so you can check they are covered. Decide where the environment variables will live (container images, Kubernetes manifests or a process manager), who owns that configuration, and how a team will verify that spans are arriving. Zero-code coverage varies by library, so the inventory is what tells you where manual spans will still be needed.

Which configuration options fit which Node.js deployment

This table compares the main environment variable settings for Node.js zero-code instrumentation and shows whether each one suits a single service owned by one team or a fleet governed by a platform team. Read each row as a decision: the right column tells you whether to set the value in the service's own deployment or to standardize it through a shared template. The main takeaway is that identity settings belong to each service, while endpoint, protocol and instrumentation choices are usually best centralized.

SettingSingle serviceManaged fleet
Service name (OTEL_SERVICE_NAME)Set directly in the service's deployment manifest or environment file so the service is identifiable in traces.Required per service and derived from the catalog or deployment name in a template, so names stay unique and consistent.
Exporter endpoint (OTEL_EXPORTER_OTLP_ENDPOINT)Point to a Collector reachable from the host, or to a backend during evaluation.Set once in a shared platform default that points to your Collector gateway, so no team hardcodes a backend address.
Exporter protocol (OTEL_EXPORTER_OTLP_PROTOCOL)Match the protocol the chosen Collector receiver expects, confirmed against your Collector configuration.Standardize one protocol across the fleet and document it in the platform baseline, with exceptions reviewed case by case.
Resource attributes (OTEL_RESOURCE_ATTRIBUTES)Add environment, version and team values that describe this one service.Enforce required keys such as environment and owner through a shared template, and reject services that omit them.
Resource detectors (OTEL_NODE_RESOURCE_DETECTORS)Enable the detectors that match the host, container or cloud platform the service runs on.Set per platform class, for example Kubernetes or a specific cloud, so detector output is consistent across similar workloads.
Enabling or disabling instrumentations (OTEL_NODE_ENABLED_INSTRUMENTATIONS, OTEL_NODE_DISABLED_INSTRUMENTATIONS)Tune for one application, for example disabling a noisy library the team does not need to trace.Define a baseline list in the platform template and allow teams to request changes, so overhead and data volume stay predictable.
Who changes the valueThe owning team, in its own repository and deployment pipeline.The platform team, through shared templates, admission policies or Helm values, with owners able to override within agreed limits.
Review evidenceA short check that traces arrive with the expected service name and attributes after each deploy.A reviewable configuration baseline and sample traces per service, which makes drift visible to the platform team.

How resource detectors add context to Node.js traces

Resource detectors attach facts about where a Node.js service runs to every span it emits. Each detector you enable adds attributes, and each attribute is data that leaves the host, so the choice of detectors is both a debugging decision and a privacy decision.

Host and process attributes

Host detectors record values such as the machine name, architecture and operating system, while process detectors record the runtime version and process identifiers. These attributes separate spans from different pods or hosts running the same code. Check whether host names follow a naming scheme that reveals customer, region or internal project names before you export them. Confirm the attribute names your backend expects, since they follow OpenTelemetry resource conventions.

Container metadata for orchestrated workloads

Container detectors read identifiers from the container runtime so traces can be matched to a specific container instance after a restart or rollout. On Kubernetes, this context is usually paired with attributes added by the cluster collector, so decide which layer owns each attribute to avoid duplicates. Confirm with your platform team which container runtime and cgroup layout your nodes use, because detection depends on it.

Cloud provider metadata

Cloud detectors query the platform's metadata service for values such as the account, region, zone and instance or service identifier. These values make it easy to filter traces by deployment location, but they also expose cloud account and network details to every backend that receives the data. Confirm which metadata endpoints your platform exposes, whether the service can reach them from the Node.js process, and whether your network policy allows those calls.

Privacy review before enabling detectors

Treat every detected attribute as exported data. Review each attribute against your data classification policy, including host names, IP-derived values, account identifiers and instance tags that may contain owner names. Record which detectors are enabled, which attributes they produce and who approved them, so the review can be repeated after a platform change. Use the Collector's redaction processor where an attribute must be removed before storage, as recommended in OpenTelemetry's security guidance.

Collector security practices

Confirm the detectors for your platform

Detector availability depends on where the service runs, including bare metal, virtual machines, containers, serverless runtimes and managed Node.js platforms. Ask each platform team which metadata sources they provide and which detectors the Node.js packages support for that environment. Test the setup in a non-production environment and inspect the resulting span attributes before enabling detectors in production. Record the confirmed list in your runbook so new services inherit the same decisions.

JavaScript zero-code docs

Setting up zero-code tracing for a Node.js service

This sequence takes a Node.js service from no telemetry to verified traces for an HTTP request and a database call, with the instrumentation loaded at startup and configured through environment variables rather than application code changes.

  1. Confirm the runtime and dependencies

    The engineer responsible for the service checks the Node.js version the service runs on against the requirements listed in the OpenTelemetry JavaScript zero-code documentation, and confirms which client libraries the service uses, such as its HTTP framework and database driver. Record the versions in the change ticket. This step is done when the team can name every library that should produce spans and has confirmed the runtime is supported.

  2. Install the API and auto-instrumentation packages

    Add @opentelemetry/api and @opentelemetry/auto-instrumentations-node to the service's dependencies with the package manager the team already uses, and commit the lockfile change. Installing them as normal dependencies keeps the same versions in every environment. This step is done when the lockfile lists both packages and a clean install in CI succeeds.

  3. Load the instrumentation at process start

    Start the service with the auto-instrumentation registered before application code loads, typically through the Node.js --require or --import option in the start command or container entrypoint, so that the libraries are patched when they are first imported. Check the current loading option in the official documentation for your Node.js version. This step is done when the service starts without errors and logs no instrumentation warnings about modules loaded too early.

  4. Set the service name and resource attributes

    Set OTEL_SERVICE_NAME to a stable name that matches your service catalog, and set OTEL_RESOURCE_ATTRIBUTES for values such as deployment environment and version. Resource detectors can add host and container attributes, so decide which detectors your environment should enable and confirm the names against the zero-code documentation. This step is done when a test request produces spans whose resource section shows the expected service name and environment.

  5. Configure the exporter endpoint and protocol

    Set OTEL_EXPORTER_OTLP_ENDPOINT to the address of a Collector agent or gateway, and choose the protocol the Collector receiver expects through OTEL_EXPORTER_OTLP_PROTOCOL. For a first test, a local Collector or a disposable test backend is enough. Keep credentials out of the service's source tree and inject them from your secrets store. This step is done when the service starts and the exporter reports no connection errors in its logs.

  6. Verify spans for an HTTP request

    Send one request to an HTTP route of the service and find the resulting server span in the test backend or the Collector debug output. Check that the span name, status code and route information look correct and that the span belongs to the service name you set. If no span appears, check that the exporter endpoint is reachable from the process and that the instrumentation loaded before the framework. This step is done when one request yields a server span with the expected service name.

  7. Verify spans for a database call

    Trigger a read or write that goes through the service's database driver, and confirm a client span appears as a child of the HTTP server span from the previous step. The shared trace ID is the evidence that context propagated across the operation. Confirm the database span does not contain query parameter values or other sensitive data, and adjust instrumentation settings or add redaction in the Collector if it does. This step is done when both spans share one trace and the attributes pass review.

  8. Record the setup and confirm what is not covered

    Save the environment variables, start command and exporter settings in the service repository or deployment manifests, and note which libraries produced spans and which did not. Zero-code coverage depends on the libraries the package supports, so any custom framework or uncommon driver needs a manual span plan. This step is done when a second engineer can reproduce the setup from the repository and the coverage gaps are written down.

How telemetry flows from a Node.js process to your backend

Telemetry starts in the Node.js process, where the auto-instrumentation hooks into supported libraries and the OpenTelemetry API records spans, configured entirely through environment variables. The SDK exports data over OTLP either directly to your backend or to a Collector running as an agent beside the service or as a gateway shared by many services. The trust boundary sits between the application host and the Collector, so check what leaves the host, which endpoints accept it, and whether resource detectors add host or cloud attributes you did not intend to send.

Telemetry leaves the Node.js host over OTLP, optionally through Collector agents and gateways.

Security and operational risks of zero-code Node.js tracing

Zero-code tracing wraps libraries without changes to application code, so it captures whatever those libraries pass into spans. The risks cluster in four places: the data spans carry, the credentials used to export them, the Collector that receives them, and the pipeline that tells you when data is lost.

Sensitive data in span attributes

Auto-instrumented HTTP, database and client libraries record attributes such as URLs, query text and request metadata by default. A URL may contain a token, an email address or a record identifier, and database spans can include SQL with literal values. Before rollout, review a sample of exported spans from each instrumented library and list which attributes carry user or regulated data. Confirm which instrumentation options in the Node.js packages can turn off specific attributes, and test each change against the Node.js zero-code docs.

Node.js zero-code docs

Scrubbing with the redaction processor

The Collector redaction processor can remove attributes that match a list of keys or patterns before data leaves your pipeline. It is a second line of defense, not a replacement for limiting what the agent captures, because data already exported to a backend may be stored. Write redaction rules from the attribute review, keep them in version control, and test them with sample payloads. Confirm the processor's current configuration keys in the Collector release you deploy.

Collector security practices

Exporter credentials outside source

The OTLP exporter often needs an API key or bearer token for the backend. Set these through environment variables injected by your secrets manager or orchestrator, not in .env files committed to repositories or in container images. Limit each credential to ingest only, rotate it on a schedule you set, and confirm whether your backend supports separate keys per service so one leak does not expose every pipeline. Collector authenticator extensions, such as oauth2client, can add credentials to exporter requests instead of placing them in each service.

Collector bind address and network exposure

Services send telemetry to a Collector, usually on a local agent port or a gateway address. Since Collector v0.110.0, server components bind to localhost by default rather than 0.0.0.0, but a gateway that must accept traffic from other hosts still needs an explicit listen address. Restrict that address to the service network, enable TLS and authentication on receivers, and confirm that no management or debug endpoint is reachable from outside the cluster or host group.

Build the Collector with needed components

The contrib distribution includes many receivers, processors and exporters that a Node.js pipeline does not use. OpenTelemetry guidance recommends building only the components you need with the Collector Builder, which reduces the code that runs inside your network. Record the component list in the build manifest, confirm the release artifacts and checksums you verify, and plan a rebuild each time you upgrade the Collector.

Monitoring exporter failures and drops

Exporters can fail silently when a backend rejects data, a token expires, or a queue fills. Node.js applications may keep running while spans are discarded. Monitor the Collector's own telemetry for refused, failed and dropped data counts, alert on sustained growth, and check the SDK's span export failures in application logs. Test the failure path before production by stopping the Collector during a load test and confirming what your team sees.

Questions teams ask before rolling out Node.js zero-code tracing

What drives the cost of rolling out Node.js zero-code tracing?

The main drivers are the number of Node.js services, how many of them run on different frameworks and deployment targets, how many custom spans and attributes the business needs, how the Collector is designed, and how much testing the rollout requires. Each service needs its startup configuration changed and verified, so a handful of services is a small task while a large fleet with mixed hosting is a program. Ask any partner to price these items separately: service inventory, Collector design, custom instrumentation, environment variable standardization, and test and rollback work. Those are the one-time costs. Ongoing costs are upgrades of the auto-instrumentation packages and the Collector, and the backend capacity that receives the data.

How long does it take to see the first Node.js traces?

A single service can often produce first traces once the package is installed, the startup flag is added, and the exporter endpoint is reachable, so the first traces depend mostly on access and environment rather than on code. The longer part is making traces useful across the fleet: agreeing on service names, resource attributes, sampling defaults and which libraries to suppress. Your timeline also depends on how quickly your platform team can provide a Collector endpoint and a backend to view the data. Ask for the first-trace milestone and the fleet-wide milestone to be written separately in the scope.

What does the work need from our platform and application teams?

Platform teams need to provide a reachable OpenTelemetry Collector or backend endpoint, network rules between the services and that endpoint, a way to set environment variables in each deployment, and a place to store any collector credentials. Application teams need to confirm service names, how each service starts (for example, the start command or container entry point), which dependencies they rely on, and who signs off on a change in production. Without these owners named early, first traces often stall on access requests rather than on instrumentation.

Can an internal team roll out Node.js zero-code tracing without a partner?

Yes, a team that already runs Node.js services and a Kubernetes or VM deployment pipeline can usually start zero-code tracing on its own, because the setup is package and environment variable configuration. Internal teams tend to need outside help when they must design the Collector topology, standardize resource attributes across many repositories, verify that sensitive data is not captured, or prove the rollout to a security or compliance review. Decide which of those tasks you will own before you start. A partner can also review the plan so your team does not discover coverage gaps after rollout.

What breaks most often in a zero-code Node.js rollout?

The most common failures are startup order problems, where the instrumentation loads after the libraries it needs, unsupported or outdated library versions that produce no spans, and exporter endpoints that services cannot reach from their network. Noisy spans from health checks or high-volume libraries can also inflate data volume and cost. Verify each service in a non-production environment by checking that expected spans and resource attributes arrive, then confirm that the instrumentation does not change application behavior under load.

Does zero-code tracing capture sensitive data, and how do we control it?

Automatic instrumentation can record request paths, query text, headers or other attributes that may contain personal or regulated data, so review the defaults before production. Disable or configure the instrumentations that capture more than you need, and use the redaction processor in the Collector to remove sensitive attributes before export. OpenTelemetry's security guidance also recommends storing Collector configuration securely and encrypting and authenticating its endpoints. Ask any partner to show which attributes each library produces in your environment before you approve the rollout.

Will zero-code tracing cover every part of our Node.js application?

No. Zero-code instrumentation captures telemetry from supported libraries and frameworks, such as common HTTP and database clients, but business operations, custom queues, and domain-specific attributes need manual spans. Check the supported library list for your exact versions, because coverage varies by library. Plan a staged approach that starts with zero-code tracing at service edges and adds manual spans where your teams need them. Confirm the supported library list against the official zero-code documentation before you commit to a coverage target.

How DeployOpen scopes and delivers Node.js instrumentation

DeployOpen delivers Node.js zero-code instrumentation as a fixed-scope engagement, with scope, deliverables and timelines agreed in writing before work starts. The work happens inside your own infrastructure, whether that is your cloud accounts, data centers or an air-gapped network, so your team keeps control of the Node.js hosts, container images, environment files and any Collector endpoints that receive the telemetry. The written scope should name which services are in the first wave, which runtimes and Node.js versions they use, where they are deployed and which backend receives the data.

The engagement usually starts with an inventory of services. For each one, the inventory records the Node.js version, the frameworks and client libraries in use (the packages the auto-instrumentations-node bundle covers and the ones it does not), how the process starts, and whether it already runs another APM agent or preload script. That inventory decides the setup work: which environment variables such as OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT are set, how resource detectors are enabled, and which instrumentations are turned off. Verification then compares traces from a staging run against the inventory, checking for missing spans, duplicate spans and sensitive values in attributes before anything is promoted to production.

Handover covers the configuration as code, a runbook for your operators, and a record of the limits found during testing, such as libraries that produce no spans. Optional retainers can cover Node.js and package upgrades, instrumentation updates when frameworks change, and support for new services. Before you request a quote, confirm with your team which environments are in scope, who approves production changes, and who owns the backend that receives the data, since these decisions drive most of the effort.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.