Skip to content

Commit 8c6b0d0

Browse files
authored
fix: resolved infrastructure and endpoint correlation for otel spans (#2159)
refs https://jsw.ibm.com/browse/INSTA-64287 refs https://jsw.ibm.com/browse/INSTA-794
1 parent 8ffe906 commit 8c6b0d0

File tree

2 files changed

+18
-0
lines changed
  • packages
    • collector/test/tracing/opentelemetry
    • core/src/tracing/opentelemetry-instrumentations

2 files changed

+18
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ mochaSuiteFn('opentelemetry tests', function () {
118118
dataProperty: 'tags',
119119
extraTests: span => {
120120
expect(span.data.tags.name).to.eql('request handler - /test');
121+
expect(span.data.operation).to.equal('restify');
121122
expect(span.data.tags['restify.version']).to.eql('11.1.0');
122123
expect(span.data.tags['restify.type']).to.eql('request_handler');
123124
expect(span.data.tags['restify.method']).to.eql('get');
@@ -330,6 +331,7 @@ mochaSuiteFn('opentelemetry tests', function () {
330331
dataProperty: 'tags',
331332
extraTests: span => {
332333
expect(span.data.tags.name).to.eql('fs readFileSync');
334+
expect(span.data.operation).to.eql('fs');
333335
checkTelemetryResourceAttrs(span);
334336
}
335337
});
@@ -464,6 +466,7 @@ mochaSuiteFn('opentelemetry tests', function () {
464466
pid: String(serverControls.getPid()),
465467
dataProperty: 'tags',
466468
extraTests: span => {
469+
expect(span.data.operation).to.equal('socket.io');
467470
expect(span.data.tags.name).to.contain('receive');
468471
expect(span.data.tags['messaging.system']).to.eql('socket.io');
469472
expect(span.data.tags['messaging.destination']).to.eql('ON test_reply');
@@ -613,6 +616,8 @@ mochaSuiteFn('opentelemetry tests', function () {
613616
extraTests: span => {
614617
const queryType = endpoint === '/packages/batch' ? 'execSqlBatch' : 'execSql';
615618
expect(span.data.tags.name).to.eql(`${queryType} azure-nodejs-test`);
619+
620+
expect(span.data.operation).to.equal('tedious');
616621
expect(span.data.tags['db.system']).to.eql('mssql');
617622
expect(span.data.tags['db.name']).to.eql('azure-nodejs-test');
618623
expect(span.data.tags['db.user']).to.eql('admin@instana@nodejs-team-db-server');
@@ -748,6 +753,7 @@ mochaSuiteFn('opentelemetry tests', function () {
748753
pid: String(controls.getPid()),
749754
dataProperty: 'tags',
750755
extraTests: span => {
756+
expect(span.data.operation).to.equal('oracledb');
751757
expect(span.data.tags.name).to.eql('oracledb.Connection.execute');
752758
expect(span.data.tags['db.system.name']).to.eql('oracle.db');
753759
expect(span.data.tags['server.address']).to.eql('localhost');
@@ -1016,6 +1022,7 @@ mochaSuiteFn('opentelemetry tests', function () {
10161022
});
10171023

10181024
function checkTelemetryResourceAttrs(span) {
1025+
expect(span.data.resource['service.name']).to.not.exist;
10191026
expect(span.data.resource['telemetry.sdk.language']).to.eql('nodejs');
10201027
expect(span.data.resource['telemetry.sdk.name']).to.eql('opentelemetry');
10211028
expect(span.data.resource['telemetry.sdk.version']).to.match(/1\.\d+\.\d/);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,22 @@ module.exports.init = (_config, cls) => {
7373

7474
try {
7575
cls.ns.runAndReturn(() => {
76+
// NOTE: 'service.name' is "unknown" - probably because we don't setup otel completely.
77+
// The removal fixes incorrect infrastructure correlation.
78+
delete otelSpan.resource.attributes['service.name'];
79+
7680
const instanaSpan = cls.startSpan({
7781
spanName: 'otel',
7882
kind: kind
7983
});
84+
85+
// opentelemetry/instrumentation-fs -> we only want the name behind instrumentation-
86+
const operation = targetInstrumentionName.split('-').pop();
87+
8088
instanaSpan.data = {
89+
// span.data.operation is mapped to endpoint for otel span plugin in BE. We need to set the endpoint otherwise
90+
// the ui will show unspecified
91+
operation,
8192
tags: Object.assign({ name: otelSpan.name }, otelSpan.attributes),
8293
resource: otelSpan.resource.attributes
8394
};

0 commit comments

Comments
 (0)