#instrumentation.ts + middleware.ts => produces __import_unsupported error

3 messages · Page 1 of 1 (latest)

static stump
#

I'm trying to add instrumentation to 2 of my nextjs apps. Both these apps live in the same mono-repo and are pretty similar expect that one has a middleware.ts

The app without a middleware worked as expected when adding instrumentation.
The app that has a middleware fails with __import_unsupported (see full error in the attached file). If I remove the middleware the error does not occur anymore.

My instrumentation.ts:

// import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { NodeSDK } from '@opentelemetry/sdk-node'
import { BatchSpanProcessor, ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'

const sdk = new NodeSDK({
  resource: new Resource({
    [ATTR_SERVICE_NAME]: 'publication-web',
  }),
  spanProcessor: new BatchSpanProcessor(
    // new OTLPTraceExporter({ url: `http://${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces` }),
    new ConsoleSpanExporter(),
  ),
})
sdk.start()

Am I missing something? What should I do to make this work?

PS: I'm deploying this app in a docker container, so I don't use edge.

silent ravenBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

static stump