Skip to content

Commit f814128

Browse files
Update TraceAttributes to semconv to 1.22.0 (#204)
* Replace HTTP_FLAVOR with NETWORK_PROTOCOL_VERSION * Set SemConv version * Update deprecated attributes * Update NETWORK_PEER_ADDRESS
1 parent c59bb0e commit f814128

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ext-json": "*",
1414
"mongodb/mongodb": "^1.15",
1515
"open-telemetry/api": "^1.0.0beta12",
16-
"open-telemetry/sem-conv": "^1"
16+
"open-telemetry/sem-conv": "^1.22"
1717
},
1818
"require-dev": {
1919
"friendsofphp/php-cs-fixer": "^3",

src/MongoDBInstrumentationSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public function commandStarted(CommandStartedEvent $event): void
6161
->setAttribute(TraceAttributes::DB_NAME, $databaseName)
6262
->setAttribute(TraceAttributes::DB_CONNECTION_STRING, $connectionString)
6363
->setAttribute(TraceAttributes::DB_OPERATION, $commandName)
64-
->setAttribute(TraceAttributes::NET_PEER_NAME, $isSocket ? null : $host)
65-
->setAttribute(TraceAttributes::NET_PEER_PORT, $isSocket ? null : $port)
66-
->setAttribute(TraceAttributes::NET_TRANSPORT, $isSocket ? 'unix' : 'tcp')
64+
->setAttribute(TraceAttributes::SERVER_ADDRESS, $isSocket ? null : $host)
65+
->setAttribute(TraceAttributes::SERVER_PORT, $isSocket ? null : $port)
66+
->setAttribute(TraceAttributes::NETWORK_TRANSPORT, $isSocket ? 'unix' : 'tcp')
6767
->setAttribute(TraceAttributes::DB_STATEMENT, ($this->commandSerializer)($command))
6868
->setAttribute(TraceAttributes::DB_MONGODB_COLLECTION, $collectionName)
6969
->setAttribute(MongoDBTraceAttributes::DB_MONGODB_MASTER, $info['ismaster'] ?? null)

tests/Integration/MongoDBInstrumentationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function test_mongodb_find_one(): void
6868
self::assertSame('mongodb://127.0.0.1:27017/db', $attributes->get(TraceAttributes::DB_CONNECTION_STRING));
6969
self::assertSame('find', $attributes->get(TraceAttributes::DB_OPERATION));
7070
self::assertSame(self::COLLECTION_NAME, $attributes->get(TraceAttributes::DB_MONGODB_COLLECTION));
71-
self::assertSame('127.0.0.1', $attributes->get(TraceAttributes::NET_PEER_NAME));
72-
self::assertSame(27017, $attributes->get(TraceAttributes::NET_PEER_PORT));
73-
self::assertSame('tcp', $attributes->get(TraceAttributes::NET_TRANSPORT));
71+
self::assertSame('127.0.0.1', $attributes->get(TraceAttributes::SERVER_ADDRESS));
72+
self::assertSame(27017, $attributes->get(TraceAttributes::SERVER_PORT));
73+
self::assertSame('tcp', $attributes->get(TraceAttributes::NETWORK_TRANSPORT));
7474
self::assertTrue($attributes->get(MongoDBTraceAttributes::DB_MONGODB_MASTER));
7575
self::assertFalse($attributes->get(MongoDBTraceAttributes::DB_MONGODB_READ_ONLY));
7676
self::assertIsNumeric($attributes->get(MongoDBTraceAttributes::DB_MONGODB_CONNECTION_ID));

0 commit comments

Comments
 (0)