2026 · Software Engineer

APM for self-hosted Next.js

Initialize tracing before the application starts, then send server traces through a Datadog agent sidecar.

Fortum Observability and delivery Fortum Sweden (opens in a new tab)
  • Next.js
  • Datadog
  • Docker
  • Azure CLI

How it fits together

RUM in the browser. APM on the server.

Explore the architecture, then open a decision below.

  • Browser

    RUM integration

    Capture the customer’s browser experience.

    Design reasoning

    RUM was the straightforward part. It does not by itself provide server-side application tracing.

  • Startup order

    Tracer before Next.js

    Load tracing before the application starts.

    Design reasoning

    Initialization order matters: the tracer needs to instrument the application’s dependencies before they are loaded.

  • Server telemetry

    An agent sidecar

    Send traces from the application to the Datadog agent.

    Design reasoning

    The self-hosted application needed an agent connection. A sidecar container supplied that part of the tracing path.

  • Delivery

    Deploy both containers

    Configure the sidecar through Azure CLI in CI/CD.

    Design reasoning

    In this setup, the existing deployment path did not create the sidecar. Infrastructure and delivery changes were part of the integration.

Simplified architecture and design considerations. Internal endpoints, access policies and deployment details are omitted.

My contribution

Integrated Next.js instrumentation and the Datadog agent sidecar, including the infrastructure and CI/CD changes needed to deploy them.

Result

Browser monitoring through RUM and server-side APM through the application tracer and agent.

What made this interesting

Installing a browser SDK was only the first step. Server-side APM required the right startup order, a reachable agent, and a deployment that brought both containers together.

Technical context: Datadog tracing for Node.js.