Skip to content

Commit 60337bc

Browse files
committed
name
1 parent c440866 commit 60337bc

File tree

4 files changed

+32
-32
lines changed
  • instrumentation
  • opentelemetry-instrumentation/src/opentelemetry/instrumentation

4 files changed

+32
-32
lines changed

instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
_filter_semconv_duration_attrs,
6969
_get_schema_url,
7070
_OpenTelemetrySemanticConventionStability,
71-
_OpenTelemetryStabilityMode,
71+
_HTTPStabilityMode,
7272
_OpenTelemetryStabilitySignalType,
7373
_report_new,
7474
_report_old,
@@ -119,7 +119,7 @@ def _instrument(
119119
request_hook: _RequestHookT = None,
120120
response_hook: _ResponseHookT = None,
121121
excluded_urls: ExcludeList = None,
122-
sem_conv_opt_in_mode: _OpenTelemetryStabilityMode = _OpenTelemetryStabilityMode.DEFAULT,
122+
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
123123
):
124124
"""Enables tracing of all requests calls that go through
125125
:code:`requests.session.Session.request` (this includes
@@ -290,7 +290,7 @@ def get_or_create_headers():
290290
metric_labels,
291291
_client_duration_attrs_old,
292292
_client_duration_attrs_new,
293-
_OpenTelemetryStabilityMode.DEFAULT
293+
_HTTPStabilityMode.DEFAULT
294294
)
295295
duration_histogram_old.record(
296296
max(round(elapsed_time * 1000), 0),
@@ -301,7 +301,7 @@ def get_or_create_headers():
301301
metric_labels,
302302
_client_duration_attrs_old,
303303
_client_duration_attrs_new,
304-
_OpenTelemetryStabilityMode.HTTP
304+
_HTTPStabilityMode.HTTP
305305
)
306306
duration_histogram_new.record(
307307
elapsed_time, attributes=duration_attrs_new

instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he
217217
_OpenTelemetrySemanticConventionStability,
218218
_OpenTelemetryStabilitySignalType,
219219
_METRIC_ATTRIBUTES_SERVER_DURATION_NAME,
220-
_OpenTelemetryStabilityMode,
220+
_HTTPStabilityMode,
221221
_SPAN_ATTRIBUTES_ERROR_TYPE,
222222
_get_schema_url,
223223
_filter_semconv_active_request_count_attr,
@@ -305,7 +305,7 @@ def setifnotnone(dic, key, value):
305305

306306
def collect_request_attributes(
307307
environ,
308-
sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT,
308+
sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT,
309309
):
310310
"""Collects HTTP request attributes from the PEP3333-conforming
311311
WSGI environ and returns a dictionary to be used as span creation attributes.
@@ -446,7 +446,7 @@ def _parse_status_code(resp_status):
446446
return None
447447

448448

449-
def _parse_active_request_count_attrs(req_attrs, sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT):
449+
def _parse_active_request_count_attrs(req_attrs, sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT):
450450
return _filter_semconv_active_request_count_attr(
451451
req_attrs,
452452
_server_active_requests_count_attrs_old,
@@ -455,7 +455,7 @@ def _parse_active_request_count_attrs(req_attrs, sem_conv_opt_in_mode = _OpenTel
455455
)
456456

457457

458-
def _parse_duration_attrs(req_attrs, sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT):
458+
def _parse_duration_attrs(req_attrs, sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT):
459459
return _filter_semconv_duration_attrs(
460460
req_attrs,
461461
_server_duration_attrs_old,
@@ -469,7 +469,7 @@ def add_response_attributes(
469469
start_response_status,
470470
response_headers,
471471
duration_attrs = None,
472-
sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT,
472+
sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT,
473473
): # pylint: disable=unused-argument
474474
"""Adds HTTP response attributes to span using the arguments
475475
passed to a PEP3333-conforming start_response callable.
@@ -648,18 +648,18 @@ def __call__(self, environ, start_response):
648648
if span.is_recording():
649649
if _report_new(self._sem_conv_opt_in_mode):
650650
span.set_attribute(_SPAN_ATTRIBUTES_ERROR_TYPE, type(ex).__qualname__ )
651-
span.set_status(Status(StatusCode.ERROR, str(ex)))
651+
span.set_status(Status(StatusCode.ERROR, str(ex)))
652652
span.end()
653653
if token is not None:
654654
context.detach(token)
655655
raise
656656
finally:
657657
duration_s = default_timer() - start
658658
if self.duration_histogram_old:
659-
duration_attrs_old = _parse_duration_attrs(req_attrs, _OpenTelemetryStabilityMode.DEFAULT)
659+
duration_attrs_old = _parse_duration_attrs(req_attrs, _HTTPStabilityMode.DEFAULT)
660660
self.duration_histogram_old.record(max(round(duration_s * 1000), 0), duration_attrs_old)
661661
if self.duration_histogram_new:
662-
duration_attrs_new = _parse_duration_attrs(req_attrs, _OpenTelemetryStabilityMode.HTTP)
662+
duration_attrs_new = _parse_duration_attrs(req_attrs, _HTTPStabilityMode.HTTP)
663663
self.duration_histogram_new.record(max(round(duration_s * 1000), 0), duration_attrs_new)
664664
self.active_requests_counter.add(-1, active_requests_count_attrs)
665665

instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_server_duration_attrs_old,
2727
_OTEL_SEMCONV_STABILITY_OPT_IN_KEY,
2828
_OpenTelemetrySemanticConventionStability,
29-
_OpenTelemetryStabilityMode,
29+
_HTTPStabilityMode,
3030
)
3131
from opentelemetry.sdk.metrics.export import (
3232
HistogramDataPoint,
@@ -496,7 +496,7 @@ def test_request_attributes_new_semconv(self):
496496

497497
attrs = otel_wsgi.collect_request_attributes(
498498
self.environ,
499-
_OpenTelemetryStabilityMode.HTTP,
499+
_HTTPStabilityMode.HTTP,
500500
)
501501
self.assertDictEqual(
502502
attrs,
@@ -654,7 +654,7 @@ def test_request_attributes_with_full_request_uri(self):
654654
self.assertGreaterEqual(
655655
otel_wsgi.collect_request_attributes(
656656
self.environ,
657-
_OpenTelemetryStabilityMode.HTTP,
657+
_HTTPStabilityMode.HTTP,
658658
).items(),
659659
expected_new.items(),
660660
)
@@ -670,7 +670,7 @@ def test_http_user_agent_attribute(self):
670670
self.assertGreaterEqual(
671671
otel_wsgi.collect_request_attributes(
672672
self.environ,
673-
_OpenTelemetryStabilityMode.HTTP,
673+
_HTTPStabilityMode.HTTP,
674674
).items(),
675675
expected_new.items(),
676676
)
@@ -681,7 +681,7 @@ def test_response_attributes(self):
681681
self.span,
682682
"404 Not Found",
683683
{},
684-
sem_conv_opt_in_mode=_OpenTelemetryStabilityMode.HTTP,
684+
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP,
685685
)
686686
expected = (mock.call(SpanAttributes.HTTP_STATUS_CODE, 404),)
687687
expected_new = (mock.call(SpanAttributes.HTTP_RESPONSE_STATUS_CODE, 404),)

opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class _OpenTelemetryStabilitySignalType:
9191
HTTP = "http"
9292

9393

94-
class _OpenTelemetryStabilityMode(Enum):
94+
class _HTTPStabilityMode(Enum):
9595
# http - emit the new, stable HTTP and networking conventions ONLY
9696
HTTP = "http"
9797
# http/dup - emit both the old and the stable HTTP and networking conventions
@@ -101,11 +101,11 @@ class _OpenTelemetryStabilityMode(Enum):
101101

102102

103103
def _report_new(mode):
104-
return mode.name != _OpenTelemetryStabilityMode.DEFAULT.name
104+
return mode.name != _HTTPStabilityMode.DEFAULT.name
105105

106106

107107
def _report_old(mode):
108-
return mode.name != _OpenTelemetryStabilityMode.HTTP.name
108+
return mode.name != _HTTPStabilityMode.HTTP.name
109109

110110

111111
class _OpenTelemetrySemanticConventionStability:
@@ -123,17 +123,17 @@ def _initialize(cls):
123123
opt_in_list = []
124124
if opt_in:
125125
opt_in_list = [s.strip() for s in opt_in.split(",")]
126-
http_opt_in = _OpenTelemetryStabilityMode.DEFAULT
126+
http_opt_in = _HTTPStabilityMode.DEFAULT
127127
if opt_in_list:
128128
# Process http opt-in
129129
# http/dup takes priority over http
130130
if (
131-
_OpenTelemetryStabilityMode.HTTP_DUP.value
131+
_HTTPStabilityMode.HTTP_DUP.value
132132
in opt_in_list
133133
):
134-
http_opt_in = _OpenTelemetryStabilityMode.HTTP_DUP
135-
elif _OpenTelemetryStabilityMode.HTTP.value in opt_in_list:
136-
http_opt_in = _OpenTelemetryStabilityMode.HTTP
134+
http_opt_in = _HTTPStabilityMode.HTTP_DUP
135+
elif _HTTPStabilityMode.HTTP.value in opt_in_list:
136+
http_opt_in = _HTTPStabilityMode.HTTP
137137
_OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[
138138
_OpenTelemetryStabilitySignalType.HTTP
139139
] = http_opt_in
@@ -144,23 +144,23 @@ def _initialize(cls):
144144
def _get_opentelemetry_stability_opt_in_mode(
145145
cls,
146146
signal_type: _OpenTelemetryStabilitySignalType,
147-
) -> _OpenTelemetryStabilityMode:
147+
) -> _HTTPStabilityMode:
148148
return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get(
149-
signal_type, _OpenTelemetryStabilityMode.DEFAULT
149+
signal_type, _HTTPStabilityMode.DEFAULT
150150
)
151151

152152

153153
def _filter_semconv_duration_attrs(
154154
attrs,
155155
old_attrs,
156156
new_attrs,
157-
sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT,
157+
sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT,
158158
):
159159
filtered_attrs = {}
160160
# duration is two different metrics depending on sem_conv_opt_in_mode, so no DUP attributes
161161
allowed_attributes = (
162162
new_attrs
163-
if sem_conv_opt_in_mode == _OpenTelemetryStabilityMode.HTTP
163+
if sem_conv_opt_in_mode == _HTTPStabilityMode.HTTP
164164
else old_attrs
165165
)
166166
for key, val in attrs.items():
@@ -173,7 +173,7 @@ def _filter_semconv_active_request_count_attr(
173173
attrs,
174174
old_attrs,
175175
new_attrs,
176-
sem_conv_opt_in_mode = _OpenTelemetryStabilityMode.DEFAULT,
176+
sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT,
177177
):
178178
filtered_attrs = {}
179179
if _report_old(sem_conv_opt_in_mode):
@@ -364,7 +364,7 @@ def _set_status(span, metrics_attributes, status_code_str, status_code, sem_conv
364364

365365

366366
# Get schema version based off of opt-in mode
367-
def _get_schema_url(mode: _OpenTelemetryStabilityMode) -> str:
368-
if mode is _OpenTelemetryStabilityMode.DEFAULT:
367+
def _get_schema_url(mode: _HTTPStabilityMode) -> str:
368+
if mode is _HTTPStabilityMode.DEFAULT:
369369
return "https://opentelemetry.io/schemas/1.11.0"
370370
return SpanAttributes.SCHEMA_URL

0 commit comments

Comments
 (0)