elastic / elastic/apm-agent-nodejs

Otel bridge transaction not picking correct transaction.result

Open
#4,389 0 comments 0 reactions 0 assignees View on GitHub
community triage
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

When using custom Otel instrumentation we're setting span.setStatus as
```
span.setStatus({
code: 2,
});
```
since code 2 is for error in transaction result it should be failure but transaction.result is always coming as success.

Upon further debugging looks like in [here](https://github.com/elastic/apm-agent-nodejs/blob/df03f05388a8c8d2c46e0fc871c2e079886c3fb6/lib/opentelemetry-bridge/OTelSpan.js#L137) `otelSpanStatus` is expecting number.

And as per docs in opentelemetry (and also in their interface), we are expecting to send object with key as `code`
https://opentelemetry.io/docs/languages/js/instrumentation/#recording-exceptions

Attaching screenshots of a Request having 500 status code but in transaction.result it was still success
Image
Image

NOTE: We're using elastic as backend and open-telemetry-bridge enabled

We've added this as a patch for now

```
const statusCodeStartNumber = res.statusCode.toString().charAt(0);
span._span._agent.currentTransaction._result = `HTTP ${statusCodeStartNumber}xx`;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.