Skip to content

Commit

Permalink
Rename "host.port" attribute to "net.host.port" (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Malafeev authored Dec 11, 2020
1 parent a7aa662 commit 11a06db
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
- `opentelemetry-instrumentation-grpc` Comply with updated spec, rework tests
([#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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def collect_request_attributes(scope):
"component": scope["type"],
"http.scheme": scope.get("scheme"),
"http.host": server_host,
"host.port": port,
"net.host.port": port,
"http.flavor": scope.get("http_version"),
"http.target": scope.get("path"),
"http.url": http_url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def validate_outputs(self, outputs, error=None, modifiers=None):
"component": "http",
"http.method": "GET",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "127.0.0.1",
"http.flavor": "1.0",
"http.target": "/",
Expand Down Expand Up @@ -218,7 +218,7 @@ def update_expected_server(expected):
expected[3]["attributes"].update(
{
"http.host": "0.0.0.0",
"host.port": 80,
"net.host.port": 80,
"http.url": "http://0.0.0.0/",
}
)
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_request_attributes(self):
"http.host": "127.0.0.1",
"http.target": "/",
"http.url": "http://127.0.0.1/?foo=bar",
"host.port": 80,
"net.host.port": 80,
"http.scheme": "http",
"http.server_name": "test",
"http.flavor": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _test_method(self, method):
"http.method": method,
"http.server_name": "falconframework.org",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "falconframework.org",
"http.target": "/",
"net.peer.ip": "127.0.0.1",
Expand All @@ -126,7 +126,7 @@ def test_404(self):
"http.method": "GET",
"http.server_name": "falconframework.org",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "falconframework.org",
"http.target": "/",
"net.peer.ip": "127.0.0.1",
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_500(self):
"http.method": "GET",
"http.server_name": "falconframework.org",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "falconframework.org",
"http.target": "/",
"net.peer.ip": "127.0.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def expected_attributes(override_attributes):
"http.method": "GET",
"http.server_name": "localhost",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "localhost",
"http.target": "/",
"http.flavor": "1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def expected_attributes(override_attributes):
"http.method": "GET",
"http.server_name": "localhost",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "localhost",
"http.target": "/",
"http.flavor": "1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def collect_request_attributes(environ):

host_port = environ.get("SERVER_PORT")
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"))
target = environ.get("RAW_URI")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def validate_response(
"component": "http",
"http.server_name": "127.0.0.1",
"http.scheme": "http",
"host.port": 80,
"net.host.port": 80,
"http.host": "127.0.0.1",
"http.flavor": "1.0",
"http.url": "http://127.0.0.1/",
Expand Down Expand Up @@ -219,7 +219,7 @@ def test_request_attributes(self):
"http.method": "GET",
"http.host": "127.0.0.1",
"http.url": "http://127.0.0.1/?foo=bar",
"host.port": 80,
"net.host.port": 80,
"http.scheme": "http",
"http.server_name": "127.0.0.1",
"http.flavor": "1.0",
Expand All @@ -230,7 +230,8 @@ def validate_url(self, expected_url, raw=False, has_host=True):
parts = urlsplit(expected_url)
expected = {
"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.
}
if raw:
Expand Down Expand Up @@ -296,7 +297,7 @@ def test_request_attributes_with_conflicting_nonstandard_port(self):
expected = {
"http.host": "127.0.0.1:8080",
"http.url": "http://127.0.0.1:8080/",
"host.port": 80,
"net.host.port": 80,
}
self.assertGreaterEqual(
otel_wsgi.collect_request_attributes(self.environ).items(),
Expand Down

0 comments on commit 11a06db

Please sign in to comment.