open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.77k stars 810 forks source link

make OTLPExporterError less cryptic by including the response body #5201

Closed glenjamin closed 3 days ago

glenjamin commented 4 days ago

Is your feature request related to a problem? Please describe.

While configuring telemetry using the OTLP format, I received the following error:

Error in reporter OTLPExporterError: Bad Request
    at IncomingMessage.<anonymous> (.../node_modules/@opentelemetry/otlp-exporter-base/src/platform/node/http-transport-utils.ts:75:23)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: undefined,
  code: 400
}

This wasn't very helpful, but I opened up the node_modules source and included responseData.toString(), and then instead I got this output

Error in reporter OTLPExporterError: Bad Request
    at IncomingMessage.<anonymous> (/Users/glen/Development/Geckoboard/polecat/shakespeare/node_modules/@opentelemetry/otlp-exporter-base/src/platform/node/http-transport-utils.ts:75:23)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: '{"error":"invalid OTLP endpoint - should you be sending to /v1/traces?, see API docs https://docs.honeycomb.io/"}\n',
  code: 400
}

Describe the solution you'd like

I'd like the exporter error to include any available context about what the error might be - but especially the response body from the remote host

Describe alternatives you've considered

My alternative was enabling debug logging at various levels, but this wasn't especially helpful as everything is encrypted.

Additional context

n/a

pichlermarc commented 4 days ago

Hi @glenjamin - thanks for reaching out. That's a great idea, let's do it 🙌 I opened #5204 to address this.