open-telemetry / opentelemetry-js

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

Status code getting set as 1 even when http request is successful #2459

Closed gauravsaralMs closed 3 years ago

gauravsaralMs commented 3 years ago

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

"@opentelemetry/instrumentation-http": "^0.24.0"

What version of Node are you using?

12

Please provide the code you used to setup the OpenTelemetry SDK

N/A

What did you do?

normal web app which makes http request to other services

What did you expect to see?

no error in Span if the response from partner services are in 2xx range

What did you see instead?

error attribute getting set as true even if response from partner service is in 2xx range

Additional context

Sample Span where no error but status code is set as 1

[Node] {
[Node]   traceId: '689d8fa940819587925b4774fcc0cc5c',
[Node]   parentId: '9a982d0f13bf43fa',
[Node]   name: 'HTTPS GET',
[Node]   id: '43223d8905b3c585',
[Node]   kind: 2,
[Node]   timestamp: 1630990629548328,
[Node]   duration: 441776,
[Node]   attributes: {
[Node]     'http.url': 'https://api.github.com/repos/gauravsaralms/devops-tasks',
[Node]     'http.method': 'GET',
[Node]     'http.target': '/repos/gauravsaralms/devops-tasks',
[Node]     'net.peer.name': 'api.github.com',
[Node]     'http.user_agent': [ 'octokit.js/16.28.7 Node.js/12.18.4 (macOS; x64)' ],
[Node]     'net.peer.ip': '13.233.76.15',
[Node]     'net.peer.port': 443,
[Node]     'http.host': 'api.github.com:443',
[Node]     'http.status_code': 200,
[Node]     'http.status_text': 'OK',
[Node]     'http.flavor': '1.1',
[Node]     'net.transport': 'ip_tcp'
[Node]   },
[Node]   status: { code: 1 },
[Node]   events: []
[Node] }
gauravsaralMs commented 3 years ago

my bad looks like status: { code: 1 }, is actually successful.

gauravsaralMs commented 3 years ago

Just in case some one is running into similar issue with lightstep then try changing lightstep collection url from https://ingest.lightstep.com:443/api/v2/otel/trace to https://ingest.lightstep.com:443/traces/otlp/v0.6

Ref: https://docs.lightstep.com/docs/satellite-release-notes#2021-01-26_23-02-36z

New versioned endpoint for OTLP/HTTP v0.6 at /traces/otlp/v0.6. This endpoint properly handles status code changes introduced in OTLP v0.6.