diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index acf2e2f90f..f950dd49a8 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -569,8 +569,8 @@ export class MongoDBInstrumentation extends InstrumentationBase { if (host && port) { span.setAttributes({ - [SemanticAttributes.NET_HOST_NAME]: host, - [SemanticAttributes.NET_HOST_PORT]: port, + [SemanticAttributes.NET_PEER_NAME]: host, + [SemanticAttributes.NET_PEER_PORT]: port, }); } if (!commandObj) return; diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts index 45229d8789..3a663957f6 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts @@ -510,11 +510,11 @@ describe('MongoDBInstrumentation', () => { (err, address) => { if (err) return done(err); assert.strictEqual( - mongoSpan.attributes[SemanticAttributes.NET_HOST_NAME], + mongoSpan.attributes[SemanticAttributes.NET_PEER_NAME], address ); assert.strictEqual( - mongoSpan.attributes[SemanticAttributes.NET_HOST_PORT], + mongoSpan.attributes[SemanticAttributes.NET_PEER_PORT], process.env.MONGODB_PORT || '27017' ); done(); diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/utils.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/utils.ts index b63d60e57c..fde0af56d8 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/utils.ts @@ -84,7 +84,7 @@ export function assertSpans( 'mongodb' ); assert.strictEqual( - mongoSpan.attributes[SemanticAttributes.NET_HOST_NAME], + mongoSpan.attributes[SemanticAttributes.NET_PEER_NAME], process.env.MONGODB_HOST || DEFAULT_MONGO_HOST ); assert.strictEqual(mongoSpan.status.code, SpanStatusCode.UNSET);