Skip to content

Comments

fix (docs): Laminar observability - add note on next.config (#6248)#6350

Merged
lgrammel merged 1 commit intov5from
lg/WiG9fJlm
May 16, 2025
Merged

fix (docs): Laminar observability - add note on next.config (#6248)#6350
lgrammel merged 1 commit intov5from
lg/WiG9fJlm

Conversation

@lgrammel
Copy link
Collaborator

Background

Like many other OpenTelemetry instrumentations, Laminar depends on @opentelemetry/instrumentation, which, in turn, depends on require-in-the-middle and import-in-the-middle. Importing and initializing Laminar inside Next.js instrumentation.ts file causes Next.js to try resolving these two packages, but fails, and results in:

  • Laminar not being able to send traces. This is because unlike many other instrumentation libraries, Laminar is not intrusive and does not set its tracer provider globally (so that others, e.g. @vercel/otel can set theirs).
  • Error messages (see below)

We have tried many different things to debug, including bundling Laminar differently, shipping those two packages within Laminar as noExternal, adding a separate entrypoint in our package for Next.js, but nothing seems to have worked.

The only thing that's worked was adding @lmnr-ai/lmnr in serverExternalPackages in
next.config.

Summary

Add a subsection within the Next.js section that describes

## Background

Like many other OpenTelemetry instrumentations, Laminar depends on
`@opentelemetry/instrumentation`, which, in turn, depends on
`require-in-the-middle` and `import-in-the-middle`. Importing and
initializing Laminar inside Next.js `instrumentation.ts` file causes
Next.js to try resolving these two packages, but fails, and results in:

- Laminar not being able to send traces. This is because unlike many
other instrumentation libraries, Laminar is not intrusive and does not
set its tracer provider globally (so that others, e.g. `@vercel/otel`
can set theirs).
- Error messages (see below)

We have tried many different things to debug, including bundling Laminar
differently, shipping those two packages within Laminar as `noExternal`,
adding a separate entrypoint in our package for Next.js, but nothing
seems to have worked.

The only thing that's worked was adding `@lmnr-ai/lmnr` in
`serverExternalPackages` in
[next.config](https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages).

## Summary

Add a subsection within the Next.js section that describes
@lgrammel lgrammel merged commit ce44353 into v5 May 16, 2025
9 checks passed
@lgrammel lgrammel deleted the lg/WiG9fJlm branch May 16, 2025 06:08
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