Skip to content

Conversation

c-ehrlich
Copy link
Collaborator

@c-ehrlich c-ehrlich commented Oct 1, 2025

Background

We got feedback from some users that in some frameworks such as Next.js they get scary-looking messages during build: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

This is caused by @opentelemetry/sdk-node.

The mitigation suggested here does not work unfortunately as sdk-node is built different from libraries like sentry

This leaves two possible mitigations:

  1. ignore in next config
const nextConfig = {
  webpack: (config, { isServer }) => {
    if (isServer) {
      config.ignoreWarnings = [
        ...(config.ignoreWarnings || []),
        {
          module: /require-in-the-middle/,
          message: /Critical dependency/,
        },
      ];
    }
    return config;
  },
};
  1. use a different instrumentation setup
// see the changes made in this PR

Changes in this PR

Move everything to version 2

Trace (before)

CleanShot 2025-10-01 at 21 23 30@2x

Trace (after)

CleanShot 2025-10-01 at 21 30 37@2x

@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 11:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the OpenTelemetry setup to avoid critical dependency warnings in Next.js builds by replacing @opentelemetry/sdk-node with a direct NodeTracerProvider implementation.

  • Removes @opentelemetry/sdk-node dependency from all packages and examples
  • Refactors instrumentation setup to use NodeTracerProvider directly instead of NodeSDK
  • Updates documentation to reflect the new OpenTelemetry setup approach

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/ai/package.json Removes sdk-node dependency
examples/example-instrumentation-nextjs-v5/src/instrumentation.node.ts Refactors from NodeSDK to NodeTracerProvider setup
examples/example-instrumentation-nextjs-v5/package.json Removes sdk-node dependency
examples/example-instrumentation-nextjs-v5/README.md Updates documentation reference from NodeSDK to OpenTelemetry tracer
examples/example-instrumentation-nextjs-v4/src/instrumentation.node.ts Refactors from NodeSDK to NodeTracerProvider setup
examples/example-instrumentation-nextjs-v4/package.json Removes sdk-node and require-in-the-middle dependencies
examples/example-instrumentation-nextjs-v4/README.md Updates documentation reference from NodeSDK to OpenTelemetry tracer
examples/example-instrumentation-express/README.md Updates documentation reference from NodeSDK to OpenTelemetry tracer
examples/example-evals-nextjs/src/instrumentation.node.ts Refactors from NodeSDK to NodeTracerProvider setup
examples/example-evals-nextjs/package.json Removes sdk-node dependency
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

pkg-pr-new bot commented Oct 1, 2025

Open in StackBlitz

npm i https://pkg.pr.new/axiomhq/ai/axiom@94

commit: 2595c73

Copy link
Collaborator

@thesollyz thesollyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@c-ehrlich c-ehrlich merged commit 5b4ae1f into main Oct 1, 2025
7 checks passed
@c-ehrlich c-ehrlich deleted the update-otel-setup branch October 1, 2025 14:31
c-ehrlich added a commit that referenced this pull request Oct 3, 2025
* remove NodeSDK from instrumentation setups

* uninstall NodeSDK

* update docs

* better tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants