diff --git a/ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py b/ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py index 8c49892e0f3..3c95a306156 100644 --- a/ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py +++ b/ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py @@ -57,8 +57,8 @@ def started(self, event: monitoring.CommandStartedEvent): span.set_attribute("db.instance", event.database_name) span.set_attribute("db.statement", statement) if event.connection_id is not None: - span.set_attribute("peer.hostname", event.connection_id[0]) - span.set_attribute("peer.port", event.connection_id[1]) + span.set_attribute("net.peer.name", event.connection_id[0]) + span.set_attribute("net.peer.port", event.connection_id[1]) # pymongo specific, not specified by spec span.set_attribute("db.mongo.operation_id", event.operation_id) diff --git a/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py b/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py index 95f0ae3413a..6c99e09e711 100644 --- a/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py +++ b/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py @@ -54,8 +54,8 @@ def test_started(self): self.assertEqual(span.attributes["db.type"], "mongodb") self.assertEqual(span.attributes["db.instance"], "database_name") self.assertEqual(span.attributes["db.statement"], "command_name find") - self.assertEqual(span.attributes["peer.hostname"], "test.com") - self.assertEqual(span.attributes["peer.port"], "1234") + self.assertEqual(span.attributes["net.peer.name"], "test.com") + self.assertEqual(span.attributes["net.peer.port"], "1234") self.assertEqual( span.attributes["db.mongo.operation_id"], "operation_id" ) diff --git a/ext/opentelemetry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py b/ext/opentelemetry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py index 6581662d598..e6751f34ced 100644 --- a/ext/opentelemetry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py +++ b/ext/opentelemetry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py @@ -103,14 +103,12 @@ def collect_request_attributes(environ): remote_addr = environ.get("REMOTE_ADDR") if remote_addr: - result[ - "peer.ipv6" if ":" in remote_addr else "peer.ipv4" - ] = remote_addr + result["net.peer.ip"] = remote_addr remote_host = environ.get("REMOTE_HOST") if remote_host and remote_host != remote_addr: - result["peer.hostname"] = remote_host + result["net.peer.name"] = remote_host - setifnotnone(result, "peer.port", environ.get("REMOTE_PORT")) + setifnotnone(result, "net.peer.port", environ.get("REMOTE_PORT")) flavor = environ.get("SERVER_PROTOCOL", "") if flavor.upper().startswith(_HTTP_VERSION_PREFIX): flavor = flavor[len(_HTTP_VERSION_PREFIX) :]