Skip to content

Commit

Permalink
fix(mongodb): use net.peer namespace for mongo host and port (open-te…
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored Oct 30, 2022
1 parent e72ea58 commit c63d2a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c63d2a4

Please sign in to comment.