Skip to content

Commit 637603a

Browse files
committed
chore: fixes
1 parent f9e2a23 commit 637603a

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

  • packages
    • collector/test/tracing/opentelemetry
    • core/src/tracing/opentelemetry-instrumentations

packages/collector/test/tracing/opentelemetry/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ mochaSuiteFn('opentelemetry tests', function () {
10181018
function checkTelemetryResourceAttrs(span) {
10191019
expect(span.data.resource['telemetry.sdk.language']).to.eql('nodejs');
10201020
expect(span.data.resource['telemetry.sdk.name']).to.eql('opentelemetry');
1021-
expect(span.data.resource['telemetry.sdk.version']).to.match(/1\.\d+\.\d/);
1021+
expect(span.data.resource['telemetry.sdk.version']).to.match(/2\.\d+\.\d/);
10221022
}
10231023

10241024
function verifyHttpExit(spans, parentSpan) {

packages/core/src/tracing/opentelemetry-instrumentations/wrap.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ module.exports.init = (_config, cls) => {
4040
});
4141

4242
const transformToInstanaSpan = otelSpan => {
43-
if (!otelSpan || !otelSpan.instrumentationLibrary) {
43+
// TODO: remove instrumentationLibrary in next major release
44+
// instrumentationScope was introduced in OpenTelemetry v2
45+
if (!otelSpan || (!otelSpan.instrumentationScope && !otelSpan.instrumentationLibrary)) {
46+
return;
47+
}
48+
49+
const targetInstrumentionName =
50+
otelSpan.instrumentationScope?.name || otelSpan.instrumentationLibrary?.name || null;
51+
52+
if (!targetInstrumentionName) {
4453
return;
4554
}
4655

47-
const targetInstrumentionName = otelSpan.instrumentationLibrary.name;
4856
let kind = constants.EXIT;
4957

5058
if (instrumentations[targetInstrumentionName] && instrumentations[targetInstrumentionName].module) {
@@ -73,11 +81,22 @@ module.exports.init = (_config, cls) => {
7381

7482
try {
7583
cls.ns.runAndReturn(() => {
84+
// NOTE: 'service.name' is "unknown" - probably because we don't setup otel completely.
85+
// The removal fixes incorrect infrastructure correlation.
86+
delete otelSpan.resource.attributes['service.name'];
87+
7688
const instanaSpan = cls.startSpan({
7789
spanName: 'otel',
7890
kind: kind
7991
});
92+
93+
// opentelemetry/instrumentation-fs -> we only want the name behind instrumentation-
94+
const operation = targetInstrumentionName.split('-').pop();
95+
8096
instanaSpan.data = {
97+
// span.data.operation is mapped to endpoint for otel span plugin in BE. We need to set the endpoint otherwise
98+
// the ui will show unspecified
99+
operation,
81100
tags: Object.assign({ name: otelSpan.name }, otelSpan.attributes),
82101
resource: otelSpan.resource.attributes
83102
};

0 commit comments

Comments
 (0)