LogDrop
Backend TracingNode.js

Bundled Applications

What a bundler hides from the LogDrop Node.js agent, and how to keep your libraries traced.

The agent traces a library when your service loads it from node_modules. A bundler (esbuild, webpack, ncc and similar) copies the libraries into one output file, so that never happens and most spans are lost. Keep the libraries outside the bundle and the agent traces them again.

What is lost

A bundled service still sends traces, but they lose detail:

Still traced in a bundleLost in a bundle
Incoming and outgoing HTTP (http, https, fetch), custom spansRoute names (GET instead of GET /orders/:id), and the database, Redis, RabbitMQ and Kafka spans

When the agent sees HTTP requests but none of the libraries it traces, it prints one warning:

[logdrop-agent] WARN HTTP requests are traced, but the application looks bundled: …

A Docker image is not a bundle: an image with your code and its node_modules is traced fully.

Fix it in your build

Ship node_modules with the service (npm ci --omit=dev) and use one of these:

  1. Do not bundle the server. Compile TypeScript with tsc and run the output next to node_modules.
  2. Keep packages outside the bundle. Your own code is still bundled:
    • esbuild: esbuild src/server.ts --bundle --platform=node --packages=external --outfile=dist/server.js
    • webpack: externals: [require('webpack-node-externals')()] with target: 'node'
    • ncc: ncc build src/server.js -e express -e pg …
  3. Keep only the traced packages outside: express, fastify, koa, @koa/router, graphql, @grpc/grpc-js, pg, mysql, mysql2, tedious, mongodb, ioredis, redis, amqplib and kafkajs. Mark them as external in your bundler and install them in the image.

Restart the service. The warning is gone, and route names and dependency spans appear in the next traces.

On this page