Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 49 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions packages/collector/test/tracing/opentelemetry/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,10 @@ mochaSuiteFn('opentelemetry tests', function () {
dataProperty: 'tags',
extraTests: span => {
expect(span.data.tags.name).to.eql('fs readFileSync');
checkTelemetryResourceAttrs(span);

// This test uses a global OpenTelemetry SDK instance, which still uses sdk version v1.
// Its nice to keep it like that to proof that v1 and v2 work fine with our integration.
checkTelemetryResourceAttrs(span, /1\.\d+\.\d/);
}
});

Expand All @@ -928,7 +931,7 @@ mochaSuiteFn('opentelemetry tests', function () {
dataProperty: 'tags',
extraTests: span => {
expect(span.data.tags.name).to.eql('fs statSync');
checkTelemetryResourceAttrs(span);
checkTelemetryResourceAttrs(span, /1\.\d+\.\d/);
}
});
})
Expand Down Expand Up @@ -995,8 +998,8 @@ mochaSuiteFn('opentelemetry tests', function () {
expect(response.otelspan.name).to.eql('explicit-otel-operation');
expect(response.otelspan._spanContext).to.have.property('traceId');
expect(response.otelspan._spanContext).to.have.property('spanId');
expect(response.otelspan.instrumentationLibrary).to.be.an('object');
expect(response.otelspan.instrumentationLibrary.name).to.eql('otel-sdk-app-tracer');
expect(response.otelspan.instrumentationScope).to.be.an('object');
expect(response.otelspan.instrumentationScope.name).to.eql('otel-sdk-app-tracer');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why this is not instrumentationLibrary 🤔

})
.then(() => delay(DELAY_TIMEOUT_IN_MS))
.then(() =>
Expand All @@ -1021,11 +1024,11 @@ mochaSuiteFn('opentelemetry tests', function () {
});
});

function checkTelemetryResourceAttrs(span) {
function checkTelemetryResourceAttrs(span, otelSdkVersion = /2\.\d+\.\d/) {
expect(span.data.resource['service.name']).to.not.exist;
expect(span.data.resource['telemetry.sdk.language']).to.eql('nodejs');
expect(span.data.resource['telemetry.sdk.name']).to.eql('opentelemetry');
expect(span.data.resource['telemetry.sdk.version']).to.match(/1\.\d+\.\d/);
expect(span.data.resource['telemetry.sdk.version']).to.match(otelSdkVersion);
}

function verifyHttpExit(spans, parentSpan) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@opentelemetry/instrumentation-restify": "0.53.0",
"@opentelemetry/instrumentation-socket.io": "0.54.0",
"@opentelemetry/instrumentation-tedious": "0.27.0",
"@opentelemetry/sdk-trace-base": "1.25.0",
"@opentelemetry/sdk-trace-base": "2.2.0",
"cls-bluebird": "^2.1.0",
"import-in-the-middle": "2.0.0",
"lru-cache": "^10.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ module.exports.init = () => {
instrumentation.enable();
}
};
exports.transform = otelSpan => {
// NOTE: This assignment is necessary to display the database name in the UI.
// In the backend, for OpenTelemetry, the service name is based on the OpenTelemetry span attribute service.name.
if (otelSpan.attributes && 'db.name' in otelSpan.attributes) {
otelSpan.resource._attributes['service.name'] = otelSpan.attributes['db.name'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otelSpan.resource._attributes no longer exists in v2.
I tested tedious manually. Works fine. I am not sure why we had to add this earlier, but seems like we don't need this anymore.

Copy link
Contributor

@aryamohanan aryamohanan Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agree. This is something not needed as we already fixed the issue in wrap.js
Nice cleanup.

}
return otelSpan;
};

module.exports.getKind = () => {
const kind = constants.EXIT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@
});

const transformToInstanaSpan = otelSpan => {
if (!otelSpan || !otelSpan.instrumentationLibrary) {
// TODO: remove instrumentationLibrary in next major release

Check warning on line 43 in packages/core/src/tracing/opentelemetry-instrumentations/wrap.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=instana_nodejs&issues=AZroUeZWtvsEPbN_t1kg&open=AZroUeZWtvsEPbN_t1kg&pullRequest=2196
// instrumentationScope was introduced in OpenTelemetry v2
if (!otelSpan || (!otelSpan.instrumentationScope && !otelSpan.instrumentationLibrary)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See open-telemetry/opentelemetry-js@97bc632

Leaving both names for now.

return;
}

const targetInstrumentionName =
otelSpan.instrumentationScope?.name || otelSpan.instrumentationLibrary?.name || null;

if (!targetInstrumentionName) {
return;
}

const targetInstrumentionName = otelSpan.instrumentationLibrary.name;
let kind = constants.EXIT;

if (instrumentations[targetInstrumentionName] && instrumentations[targetInstrumentionName].module) {
Expand Down