Rename "host.port" attribute to "net.host.port" (#242)

This commit is contained in:
Sergei Malafeev 2020-12-11 23:55:11 +08:00 committed by GitHub
parent a7aa662fe5
commit 11a06db3d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 14 deletions

View File

@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1374](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/233)) ([#1374](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/233))
- `opentelemetry-instrumentation-grpc` Comply with updated spec, rework tests - `opentelemetry-instrumentation-grpc` Comply with updated spec, rework tests
([#236](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/236)) ([#236](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/236))
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-falcon`, `opentelemetry-instrumentation-flask`, `opentelemetry-instrumentation-pyramid`, `opentelemetry-instrumentation-wsgi` Renamed `host.port` attribute to `net.host.port`
([#242](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/242))
## [0.16b1](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b1) - 2020-11-26 ## [0.16b1](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b1) - 2020-11-26

View File

@ -75,7 +75,7 @@ def collect_request_attributes(scope):
"component": scope["type"], "component": scope["type"],
"http.scheme": scope.get("scheme"), "http.scheme": scope.get("scheme"),
"http.host": server_host, "http.host": server_host,
"host.port": port, "net.host.port": port,
"http.flavor": scope.get("http_version"), "http.flavor": scope.get("http_version"),
"http.target": scope.get("path"), "http.target": scope.get("path"),
"http.url": http_url, "http.url": http_url,

View File

@ -137,7 +137,7 @@ class TestAsgiApplication(AsgiTestBase):
"component": "http", "component": "http",
"http.method": "GET", "http.method": "GET",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "127.0.0.1", "http.host": "127.0.0.1",
"http.flavor": "1.0", "http.flavor": "1.0",
"http.target": "/", "http.target": "/",
@ -218,7 +218,7 @@ class TestAsgiApplication(AsgiTestBase):
expected[3]["attributes"].update( expected[3]["attributes"].update(
{ {
"http.host": "0.0.0.0", "http.host": "0.0.0.0",
"host.port": 80, "net.host.port": 80,
"http.url": "http://0.0.0.0/", "http.url": "http://0.0.0.0/",
} }
) )
@ -326,7 +326,7 @@ class TestAsgiAttributes(unittest.TestCase):
"http.host": "127.0.0.1", "http.host": "127.0.0.1",
"http.target": "/", "http.target": "/",
"http.url": "http://127.0.0.1/?foo=bar", "http.url": "http://127.0.0.1/?foo=bar",
"host.port": 80, "net.host.port": 80,
"http.scheme": "http", "http.scheme": "http",
"http.server_name": "test", "http.server_name": "test",
"http.flavor": "1.0", "http.flavor": "1.0",

View File

@ -99,7 +99,7 @@ class TestFalconInstrumentation(TestBase):
"http.method": method, "http.method": method,
"http.server_name": "falconframework.org", "http.server_name": "falconframework.org",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "falconframework.org", "http.host": "falconframework.org",
"http.target": "/", "http.target": "/",
"net.peer.ip": "127.0.0.1", "net.peer.ip": "127.0.0.1",
@ -126,7 +126,7 @@ class TestFalconInstrumentation(TestBase):
"http.method": "GET", "http.method": "GET",
"http.server_name": "falconframework.org", "http.server_name": "falconframework.org",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "falconframework.org", "http.host": "falconframework.org",
"http.target": "/", "http.target": "/",
"net.peer.ip": "127.0.0.1", "net.peer.ip": "127.0.0.1",
@ -159,7 +159,7 @@ class TestFalconInstrumentation(TestBase):
"http.method": "GET", "http.method": "GET",
"http.server_name": "falconframework.org", "http.server_name": "falconframework.org",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "falconframework.org", "http.host": "falconframework.org",
"http.target": "/", "http.target": "/",
"net.peer.ip": "127.0.0.1", "net.peer.ip": "127.0.0.1",

View File

@ -32,7 +32,7 @@ def expected_attributes(override_attributes):
"http.method": "GET", "http.method": "GET",
"http.server_name": "localhost", "http.server_name": "localhost",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "localhost", "http.host": "localhost",
"http.target": "/", "http.target": "/",
"http.flavor": "1.1", "http.flavor": "1.1",

View File

@ -32,7 +32,7 @@ def expected_attributes(override_attributes):
"http.method": "GET", "http.method": "GET",
"http.server_name": "localhost", "http.server_name": "localhost",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "localhost", "http.host": "localhost",
"http.target": "/", "http.target": "/",
"http.flavor": "1.1", "http.flavor": "1.1",

View File

@ -112,7 +112,7 @@ def collect_request_attributes(environ):
host_port = environ.get("SERVER_PORT") host_port = environ.get("SERVER_PORT")
if host_port is not None: if host_port is not None:
result.update({"host.port": int(host_port)}) result.update({"net.host.port": int(host_port)})
setifnotnone(result, "http.host", environ.get("HTTP_HOST")) setifnotnone(result, "http.host", environ.get("HTTP_HOST"))
target = environ.get("RAW_URI") target = environ.get("RAW_URI")

View File

@ -109,7 +109,7 @@ class TestWsgiApplication(WsgiTestBase):
"component": "http", "component": "http",
"http.server_name": "127.0.0.1", "http.server_name": "127.0.0.1",
"http.scheme": "http", "http.scheme": "http",
"host.port": 80, "net.host.port": 80,
"http.host": "127.0.0.1", "http.host": "127.0.0.1",
"http.flavor": "1.0", "http.flavor": "1.0",
"http.url": "http://127.0.0.1/", "http.url": "http://127.0.0.1/",
@ -219,7 +219,7 @@ class TestWsgiAttributes(unittest.TestCase):
"http.method": "GET", "http.method": "GET",
"http.host": "127.0.0.1", "http.host": "127.0.0.1",
"http.url": "http://127.0.0.1/?foo=bar", "http.url": "http://127.0.0.1/?foo=bar",
"host.port": 80, "net.host.port": 80,
"http.scheme": "http", "http.scheme": "http",
"http.server_name": "127.0.0.1", "http.server_name": "127.0.0.1",
"http.flavor": "1.0", "http.flavor": "1.0",
@ -230,7 +230,8 @@ class TestWsgiAttributes(unittest.TestCase):
parts = urlsplit(expected_url) parts = urlsplit(expected_url)
expected = { expected = {
"http.scheme": parts.scheme, "http.scheme": parts.scheme,
"host.port": parts.port or (80 if parts.scheme == "http" else 443), "net.host.port": parts.port
or (80 if parts.scheme == "http" else 443),
"http.server_name": parts.hostname, # Not true in the general case, but for all tests. "http.server_name": parts.hostname, # Not true in the general case, but for all tests.
} }
if raw: if raw:
@ -296,7 +297,7 @@ class TestWsgiAttributes(unittest.TestCase):
expected = { expected = {
"http.host": "127.0.0.1:8080", "http.host": "127.0.0.1:8080",
"http.url": "http://127.0.0.1:8080/", "http.url": "http://127.0.0.1:8080/",
"host.port": 80, "net.host.port": 80,
} }
self.assertGreaterEqual( self.assertGreaterEqual(
otel_wsgi.collect_request_attributes(self.environ).items(), otel_wsgi.collect_request_attributes(self.environ).items(),