Skip to content

Commit 2317adc

Browse files
authored
HTTP transition for wsgi (#2425)
1 parent 7656bdb commit 2317adc

File tree

11 files changed

+852
-246
lines changed

11 files changed

+852
-246
lines changed

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9-
- `opentelemetry-sdk-extension-aws` Register AWS resource detectors under the
10-
`opentelemetry_resource_detector` entry point
11-
([#2382](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2382))
129

1310
### Breaking changes
1411

@@ -21,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2118

2219
### Added
2320

21+
- `opentelemetry-sdk-extension-aws` Register AWS resource detectors under the
22+
`opentelemetry_resource_detector` entry point
23+
([#2382](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2382))
24+
- `opentelemetry-instrumentation-wsgi` Implement new semantic convention opt-in with stable http semantic conventions
25+
([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425))
2426
- `opentelemetry-instrumentation-threading` Initial release for threading
2527
([#2253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2253))
2628

@@ -29,6 +31,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2931
- `opentelemetry-instrumentation-grpc` AioClientInterceptor should propagate with a Metadata object
3032
([#2363](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2363))
3133

34+
### Added
35+
36+
- `opentelemetry-sdk-extension-aws` Register AWS resource detectors under the `opentelemetry_resource_detector` entry point
37+
([#2382](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2382))
38+
- `opentelemetry-instrumentation-wsgi` Implement new semantic convention opt-in with stable http semantic conventions
39+
([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425))
40+
- `opentelemetry-instrumentation-threading` Initial release for threading
41+
([#2253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2253))
42+
3243
## Version 1.24.0/0.45b0 (2024-03-28)
3344

3445
### Added

instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
from unittest.mock import Mock, patch
1717

1818
import pytest
19-
from falcon import __version__ as _falcon_verison
19+
from falcon import __version__ as _falcon_version
2020
from falcon import testing
2121
from packaging import version as package_version
2222

2323
from opentelemetry import trace
24+
from opentelemetry.instrumentation._semconv import (
25+
_server_active_requests_count_attrs_old,
26+
_server_duration_attrs_old,
27+
)
2428
from opentelemetry.instrumentation.falcon import FalconInstrumentor
2529
from opentelemetry.instrumentation.propagators import (
2630
TraceResponsePropagator,
2731
get_global_response_propagator,
2832
set_global_response_propagator,
2933
)
30-
from opentelemetry.instrumentation.wsgi import (
31-
_active_requests_count_attrs,
32-
_duration_attrs,
33-
)
3434
from opentelemetry.sdk.metrics.export import (
3535
HistogramDataPoint,
3636
NumberDataPoint,
@@ -53,8 +53,8 @@
5353
"http.server.duration",
5454
]
5555
_recommended_attrs = {
56-
"http.server.active_requests": _active_requests_count_attrs,
57-
"http.server.duration": _duration_attrs,
56+
"http.server.active_requests": _server_active_requests_count_attrs_old,
57+
"http.server.duration": _server_duration_attrs_old,
5858
}
5959

6060

@@ -125,7 +125,7 @@ def _test_method(self, method):
125125
SpanAttributes.NET_HOST_PORT: 80,
126126
SpanAttributes.HTTP_HOST: "falconframework.org",
127127
SpanAttributes.HTTP_TARGET: "/",
128-
SpanAttributes.NET_PEER_PORT: "65133",
128+
SpanAttributes.NET_PEER_PORT: 65133,
129129
SpanAttributes.HTTP_FLAVOR: "1.1",
130130
"falcon.resource": "HelloWorldResource",
131131
SpanAttributes.HTTP_STATUS_CODE: 201,
@@ -156,7 +156,7 @@ def test_404(self):
156156
SpanAttributes.NET_HOST_PORT: 80,
157157
SpanAttributes.HTTP_HOST: "falconframework.org",
158158
SpanAttributes.HTTP_TARGET: "/",
159-
SpanAttributes.NET_PEER_PORT: "65133",
159+
SpanAttributes.NET_PEER_PORT: 65133,
160160
SpanAttributes.HTTP_FLAVOR: "1.1",
161161
SpanAttributes.HTTP_STATUS_CODE: 404,
162162
},
@@ -193,7 +193,7 @@ def test_500(self):
193193
SpanAttributes.NET_HOST_PORT: 80,
194194
SpanAttributes.HTTP_HOST: "falconframework.org",
195195
SpanAttributes.HTTP_TARGET: "/",
196-
SpanAttributes.NET_PEER_PORT: "65133",
196+
SpanAttributes.NET_PEER_PORT: 65133,
197197
SpanAttributes.HTTP_FLAVOR: "1.1",
198198
SpanAttributes.HTTP_STATUS_CODE: 500,
199199
},
@@ -226,7 +226,7 @@ def test_url_template(self):
226226
SpanAttributes.NET_HOST_PORT: 80,
227227
SpanAttributes.HTTP_HOST: "falconframework.org",
228228
SpanAttributes.HTTP_TARGET: "/",
229-
SpanAttributes.NET_PEER_PORT: "65133",
229+
SpanAttributes.NET_PEER_PORT: 65133,
230230
SpanAttributes.HTTP_FLAVOR: "1.1",
231231
"falcon.resource": "UserResource",
232232
SpanAttributes.HTTP_STATUS_CODE: 200,
@@ -336,6 +336,7 @@ def test_falcon_metric_values(self):
336336
"http.flavor": "1.1",
337337
"http.server_name": "falconframework.org",
338338
"net.host.port": 80,
339+
"net.host.name": "falconframework.org",
339340
"http.status_code": 404,
340341
}
341342
expected_requests_count_attributes = {
@@ -344,6 +345,8 @@ def test_falcon_metric_values(self):
344345
"http.scheme": "http",
345346
"http.flavor": "1.1",
346347
"http.server_name": "falconframework.org",
348+
"net.host.name": "falconframework.org",
349+
"net.host.port": 80,
347350
}
348351
start = default_timer()
349352
self.client().simulate_get("/hello/756")
@@ -523,7 +526,7 @@ def test_custom_request_header_not_added_in_internal_span(self):
523526
self.assertNotIn(key, span.attributes)
524527

525528
@pytest.mark.skipif(
526-
condition=package_version.parse(_falcon_verison)
529+
condition=package_version.parse(_falcon_version)
527530
< package_version.parse("2.0.0"),
528531
reason="falcon<2 does not implement custom response headers",
529532
)
@@ -558,7 +561,7 @@ def test_custom_response_header_added_in_server_span(self):
558561
self.assertNotIn(key, span.attributes)
559562

560563
@pytest.mark.skipif(
561-
condition=package_version.parse(_falcon_verison)
564+
condition=package_version.parse(_falcon_version)
562565
< package_version.parse("2.0.0"),
563566
reason="falcon<2 does not implement custom response headers",
564567
)

instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
from flask import Flask, request
1919

2020
from opentelemetry import trace
21+
from opentelemetry.instrumentation._semconv import (
22+
_server_active_requests_count_attrs_old,
23+
_server_duration_attrs_old,
24+
)
2125
from opentelemetry.instrumentation.flask import FlaskInstrumentor
2226
from opentelemetry.instrumentation.propagators import (
2327
TraceResponsePropagator,
2428
get_global_response_propagator,
2529
set_global_response_propagator,
2630
)
27-
from opentelemetry.instrumentation.wsgi import (
28-
OpenTelemetryMiddleware,
29-
_active_requests_count_attrs,
30-
_duration_attrs,
31-
)
31+
from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware
3232
from opentelemetry.sdk.metrics.export import (
3333
HistogramDataPoint,
3434
NumberDataPoint,
@@ -54,6 +54,7 @@ def expected_attributes(override_attributes):
5454
SpanAttributes.HTTP_SERVER_NAME: "localhost",
5555
SpanAttributes.HTTP_SCHEME: "http",
5656
SpanAttributes.NET_HOST_PORT: 80,
57+
SpanAttributes.NET_HOST_NAME: "localhost",
5758
SpanAttributes.HTTP_HOST: "localhost",
5859
SpanAttributes.HTTP_TARGET: "/",
5960
SpanAttributes.HTTP_FLAVOR: "1.1",
@@ -69,8 +70,8 @@ def expected_attributes(override_attributes):
6970
"http.server.duration",
7071
]
7172
_recommended_attrs = {
72-
"http.server.active_requests": _active_requests_count_attrs,
73-
"http.server.duration": _duration_attrs,
73+
"http.server.active_requests": _server_active_requests_count_attrs_old,
74+
"http.server.duration": _server_duration_attrs_old,
7475
}
7576

7677

@@ -358,13 +359,16 @@ def test_basic_metric_success(self):
358359
"http.server_name": "localhost",
359360
"net.host.port": 80,
360361
"http.status_code": 200,
362+
"net.host.name": "localhost",
361363
}
362364
expected_requests_count_attributes = {
363365
"http.method": "GET",
364366
"http.host": "localhost",
365367
"http.scheme": "http",
366368
"http.flavor": "1.1",
367369
"http.server_name": "localhost",
370+
"net.host.name": "localhost",
371+
"net.host.port": 80,
368372
}
369373
self._assert_basic_metric(
370374
expected_duration_attributes,
@@ -374,20 +378,23 @@ def test_basic_metric_success(self):
374378
def test_basic_metric_nonstandard_http_method_success(self):
375379
self.client.open("/hello/756", method="NONSTANDARD")
376380
expected_duration_attributes = {
377-
"http.method": "UNKNOWN",
381+
"http.method": "_OTHER",
378382
"http.host": "localhost",
379383
"http.scheme": "http",
380384
"http.flavor": "1.1",
381385
"http.server_name": "localhost",
382386
"net.host.port": 80,
383387
"http.status_code": 405,
388+
"net.host.name": "localhost",
384389
}
385390
expected_requests_count_attributes = {
386-
"http.method": "UNKNOWN",
391+
"http.method": "_OTHER",
387392
"http.host": "localhost",
388393
"http.scheme": "http",
389394
"http.flavor": "1.1",
390395
"http.server_name": "localhost",
396+
"net.host.name": "localhost",
397+
"net.host.port": 80,
391398
}
392399
self._assert_basic_metric(
393400
expected_duration_attributes,
@@ -410,13 +417,16 @@ def test_basic_metric_nonstandard_http_method_allowed_success(self):
410417
"http.server_name": "localhost",
411418
"net.host.port": 80,
412419
"http.status_code": 405,
420+
"net.host.name": "localhost",
413421
}
414422
expected_requests_count_attributes = {
415423
"http.method": "NONSTANDARD",
416424
"http.host": "localhost",
417425
"http.scheme": "http",
418426
"http.flavor": "1.1",
419427
"http.server_name": "localhost",
428+
"net.host.name": "localhost",
429+
"net.host.port": 80,
420430
}
421431
self._assert_basic_metric(
422432
expected_duration_attributes,

instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
from pyramid.config import Configurator
1919

2020
from opentelemetry import trace
21+
from opentelemetry.instrumentation._semconv import (
22+
_server_active_requests_count_attrs_old,
23+
_server_duration_attrs_old,
24+
)
2125
from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
2226
from opentelemetry.sdk.metrics.export import (
2327
HistogramDataPoint,
@@ -31,8 +35,6 @@
3135
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS,
3236
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
3337
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
34-
_active_requests_count_attrs,
35-
_duration_attrs,
3638
)
3739

3840
# pylint: disable=import-error
@@ -43,8 +45,8 @@
4345
"http.server.duration",
4446
]
4547
_recommended_attrs = {
46-
"http.server.active_requests": _active_requests_count_attrs,
47-
"http.server.duration": _duration_attrs,
48+
"http.server.active_requests": _server_active_requests_count_attrs_old,
49+
"http.server.duration": _server_duration_attrs_old,
4850
}
4951

5052

@@ -213,13 +215,16 @@ def test_basic_metric_success(self):
213215
"http.server_name": "localhost",
214216
"net.host.port": 80,
215217
"http.status_code": 200,
218+
"net.host.name": "localhost",
216219
}
217220
expected_requests_count_attributes = {
218221
"http.method": "GET",
219222
"http.host": "localhost",
220223
"http.scheme": "http",
221224
"http.flavor": "1.1",
222225
"http.server_name": "localhost",
226+
"net.host.name": "localhost",
227+
"net.host.port": 80,
223228
}
224229
metrics_list = self.memory_metrics_reader.get_metrics_data()
225230
for metric in (

instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def expected_attributes(override_attributes):
3737
SpanAttributes.HTTP_SERVER_NAME: "localhost",
3838
SpanAttributes.HTTP_SCHEME: "http",
3939
SpanAttributes.NET_HOST_PORT: 80,
40+
SpanAttributes.NET_HOST_NAME: "localhost",
4041
SpanAttributes.HTTP_HOST: "localhost",
4142
SpanAttributes.HTTP_TARGET: "/",
4243
SpanAttributes.HTTP_FLAVOR: "1.1",

0 commit comments

Comments
 (0)