traceloop / openllmetry-js

Sister project to OpenLLMetry, but in Typescript. Open-source observability for your LLM application, based on OpenTelemetry
https://www.traceloop.com/openllmetry
Apache License 2.0
259 stars 25 forks source link

Bug: TRACELOOP_HEADERS is not setting Authorization headers for default OTLP Exporter #434

Closed aericjw closed 2 weeks ago

aericjw commented 2 weeks ago

I'm attempting to export OTLP Traces to Dynatrace via the TRACELOOP_HEADERS environment variable that contains my API token.

I've tried setting the environment variable with TypeScript code, and the export command in bash/zsh, it didn't work either way.

Through my debugging, I found the OTLPTraceExporter that gets created by default doesn't use the value of the TRACELOOP_HEADERS at all, it uses the defaults which cause a 401 error and fails to export any traces

Error Message:

{"stack":"OTLPExporterError: Unauthorized\n at IncomingMessage.<anonymous> (/Users/aeric.walls/Offline/Code/test-llm/node_modules/@opentelemetry/otlp-exporter-base/src/platform/node/util.ts:131:27)\n at IncomingMessage.emit (node:events:531:35)\n at IncomingMessage.emit (node:domain:488:12)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)","message":"Unauthorized","name":"OTLPExporterError","data":"\b\u0010\u0012GAuthorization header contains unsupported authorization scheme 'Bearer'","code":"401"}

OTLPTraceExporter during execution: image

Environment Variable

TRACELOOP_HEADERS=Authorization=Api-Token%20d<Dynatrace-API-Token-Here>

Is there some other setup I'm missing? To my understanding I just need the base URL and headers set as environment variables, then during traceloop.initialize(), it would create an OTLPTraceExporter with my URL and Headers.

nirga commented 2 weeks ago

Thanks for reporting @aericjw! Will look into this ASAP and fix it! Sorry about that