-
Notifications
You must be signed in to change notification settings - Fork 421
Open
Labels
Description
Spec PR 766 clarifies that agents must record Open Telemetry's "status" value as agent attributes on recorded spans.
- https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk-node.node.ReadableSpan.html#status
- https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk-node._opentelemetry_api.SpanStatus.html
- https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_sdk-node._opentelemetry_api.SpanStatusCode.html
When the span ends, we must update the agent attributes:
let code
switch (span.status.code) {
case 0: { code = 'unset'; break; }
case 1: { code = 'ok'; break; }
case 2: { code = 'error'; break; }
}
segment.addAttribute('status.code', code)
if (code === 'error') {
segment.addAttribute('status.description', span.status.message)
}node-newrelic/lib/otel/traces/span-processor.js
Lines 51 to 72 in ae0074b
| onEnd(span) { | |
| if (span[otelSynthesis] && span[otelSynthesis].segment) { | |
| const { segment, transaction, rule } = span[otelSynthesis] | |
| const { instrumentationScope } = span | |
| // We always attach the instrumentation scope data as agent attributes | |
| // if the OTEL span has them set. | |
| // See https://opentelemetry.io/docs/specs/otel/common/mapping-to-non-otlp/#instrumentationscope | |
| if (typeof instrumentationScope.name === 'string') { | |
| segment.addAttribute('otel.scope.name', instrumentationScope.name) | |
| segment.addAttribute('otel.library.name', instrumentationScope.name) | |
| } | |
| if (typeof instrumentationScope.version === 'string') { | |
| segment.addAttribute('otel.scope.version', instrumentationScope.version) | |
| segment.addAttribute('otel.library.version', instrumentationScope.version) | |
| } | |
| this.updateDuration(segment, span) | |
| this.handleError({ segment, transaction, span }) | |
| this.reconcileAttributes({ segment, span, transaction, rule }) | |
| delete span[otelSynthesis] | |
| } |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage Needed