vercel / otel

OTEL tracing for Vercel
https://vercel.com/docs/observability/otel-overview
40 stars 9 forks source link

Issue with Handling Incoming traceparent Header (NEXT_OTEL_VERBOSE=1) #107

Open rudebono opened 4 months ago

rudebono commented 4 months ago

Hello, I have a question regarding the use of vercel/otel.

After setting the traceparent header in the browser and sending a request to Next.js, I expect multiple spans to be created based on the same trace ID. However, this is not happening as expected. Instead of using the trace ID from the traceparent header I set, a new trace ID generated by Next.js is being used.

Is there any additional configuration required to create spans based on the traceparent header sent from the browser? Or is this functionality not supported by vercel/otel?

I am using the following:

node: v18.20.3

next.config.mjs

const nextConfig = {
    experimental: {
        instrumentationHook: true
    }
};

export default nextConfig;

instrumentation.ts

import { registerOTel } from '@vercel/otel'

export function register() {
  registerOTel({ serviceName: 'next-app' })
}

.env.development

NEXT_OTEL_VERBOSE = 1
OTEL_EXPORTER_OTLP_ENDPOINT = https://<CUSTOM_DOMAIN>

Header

{ "traceparent": "00-6d2eac29c9283ece795b4fbaa2d57225-bad4e819c34d2cdb-01" }
스크린샷 2024-07-22 오전 12 38 07

Result All requests were successfully created with random Trace IDs. However, the Trace IDs were not the ones from the traceparent header as I expected.

스크린샷 2024-07-22 오전 12 50 20 스크린샷 2024-07-22 오전 12 39 51