From 88e4978a770383a4c88317fbe94d28fdb437d264 Mon Sep 17 00:00:00 2001 From: Hector Hernandez Guzman Date: Thu, 2 Jan 2020 12:10:31 -0800 Subject: [PATCH 1/3] Updating peer attribute names --- .../src/opentelemetry/ext/pymongo/__init__.py | 4 ++-- .../tests/test_pymongo_integration.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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..dae6cf41adc 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.hostname", 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..44d23d1d56c 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.hostname"], "test.com") + self.assertEqual(span.attributes["net.peer.port"], "1234") self.assertEqual( span.attributes["db.mongo.operation_id"], "operation_id" ) From 27b02e140cae0fe3d33d2ec2c56d920b45afe586 Mon Sep 17 00:00:00 2001 From: Hector Hernandez Guzman Date: Thu, 2 Jan 2020 12:13:57 -0800 Subject: [PATCH 2/3] Updating host name --- .../src/opentelemetry/ext/pymongo/__init__.py | 2 +- ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 dae6cf41adc..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,7 +57,7 @@ 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("net.peer.hostname", event.connection_id[0]) + 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 diff --git a/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py b/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py index 44d23d1d56c..6c99e09e711 100644 --- a/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py +++ b/ext/opentelemetry-ext-pymongo/tests/test_pymongo_integration.py @@ -54,7 +54,7 @@ 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["net.peer.hostname"], "test.com") + 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" From c07d9c24d902a9937dcc69f7e13e28166cf80cb5 Mon Sep 17 00:00:00 2001 From: Hector Hernandez Guzman Date: Mon, 6 Jan 2020 10:11:11 -0800 Subject: [PATCH 3/3] Updating wsgi attributes --- .../src/opentelemetry/ext/wsgi/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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) :]