appsignal / appsignal-nodejs

🟩 AppSignal for Node.js
https://www.appsignal.com/nodejs/
MIT License
28 stars 9 forks source link

Nextjs integration - trace outgoing HTTP requests #1076

Closed kostas-pblworks closed 2 months ago

kostas-pblworks commented 2 months ago

I'm trying to trace outgoing HTTP requests so I've modified the appsignal.cjs file with the following:

import { Appsignal } from '@appsignal/nodejs'
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'

new Appsignal({
  name: 'XXXX',
  disableDefaultInstrumentations: [
    '@opentelemetry/instrumentation-http',
  ],
  additionalInstrumentations: [
    new HttpInstrumentation({
      ignoreIncomingRequestHook: () => true,
    }),
  ],
  pushApiKey: 'XXXX',
})

but this will stop the tracing altogether like throwing and shallowing the error.

How can I enable tracing only outgoing HTTP requests? (Side question: how can I enable debuging for the client?)

unflxw commented 2 months ago

Hi @kostas-pblworks!

Unfortunately, due to the need to disable @opentelemetry/instrumentation-http in order for the Next.js instrumentation to function properly, it is not possible to instrument HTTP outgoing requests from a Next.js instrumentation.

If using fetch, those requests should be instrumented, as they are sent through a different instrumentation (either via @opentelemetry/instrumentation-undici or through the Next.js instrumentation itself)