vercel / otel

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

Adding user agent to root span #109

Open morley92 opened 3 months ago

morley92 commented 3 months ago

How possible would it be to add the user agent OTEL attribute to the root span? Ideally user_agent.original

I was hoping to achieve this by using the attributesFromHeaders function but this seems to have no effect, e.g:

attributesFromHeaders: {
  'user_agent.original': 'User-Agent'
}

Reading through the code it seems like user agent is added in certain circumstances but this doesn't appear be included in our spans - see https://github.com/vercel/otel/blob/879fdcbc3ba26437105c1f0ec9b72e1979d8b063/packages/otel/src/vercel-request-context/attributes.ts#L24

We're not hosting with Vercel if that helps.

Thanks