Skip to content

Commit 34b6188

Browse files
authored
Merge branch 'main' into fix/issue-3671
2 parents 8878698 + aa0579d commit 34b6188

File tree

2 files changed

+64
-47
lines changed

2 files changed

+64
-47
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,18 @@ Open a pull request against the main `opentelemetry-python-contrib` repo.
206206

207207
### How to Get PRs Reviewed
208208

209-
The maintainers and approvers of this repo are not experts in every instrumentation there is here.
210-
In fact each one of us knows enough about them to only review a few. Unfortunately it can be hard
209+
The maintainers and approvers of this repository are not experts in every instrumentation there is here.
210+
In fact, each one of us knows enough about them to only review a few. Unfortunately, it can be hard
211211
to find enough experts in every instrumentation to quickly review every instrumentation PR. The
212212
instrumentation experts are listed in `.github/component_owners.yml` with their corresponding files
213213
or directories that they own. The owners listed there will be notified when PRs that modify their
214214
files are opened.
215215

216216
If you are not getting reviews, please contact the respective owners directly.
217217

218+
> [!TIP]
219+
> Even if you’re new here, your review counts —and it’s valuable to the project. Feel free to jump into any open PR: check the docs, run the tests, ask questions, or give a +1 when things look good. The OpenTelemetry-Python community is intentionally flexible: anyone can review PRs and help them get merged. Every comment moves the project forward, so don’t hesitate if you have expertise to review a PR.
220+
218221
### How to Get PRs Merged
219222

220223
A PR is considered to be **ready to merge** when:

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

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
from enum import Enum
1818

1919
from opentelemetry.instrumentation.utils import http_status_to_status_code
20+
from opentelemetry.semconv._incubating.attributes.http_attributes import (
21+
HTTP_FLAVOR,
22+
HTTP_HOST,
23+
HTTP_METHOD,
24+
HTTP_SCHEME,
25+
HTTP_SERVER_NAME,
26+
HTTP_STATUS_CODE,
27+
HTTP_TARGET,
28+
HTTP_URL,
29+
HTTP_USER_AGENT,
30+
)
31+
from opentelemetry.semconv._incubating.attributes.net_attributes import (
32+
NET_HOST_NAME,
33+
NET_HOST_PORT,
34+
NET_PEER_IP,
35+
NET_PEER_NAME,
36+
NET_PEER_PORT,
37+
)
2038
from opentelemetry.semconv.attributes.client_attributes import (
2139
CLIENT_ADDRESS,
2240
CLIENT_PORT,
@@ -44,7 +62,7 @@
4462
from opentelemetry.semconv.attributes.user_agent_attributes import (
4563
USER_AGENT_ORIGINAL,
4664
)
47-
from opentelemetry.semconv.trace import SpanAttributes
65+
from opentelemetry.semconv.schemas import Schemas
4866
from opentelemetry.trace.status import Status, StatusCode
4967

5068
# Values defined in milliseconds
@@ -87,13 +105,13 @@
87105
# These lists represent attributes for metrics that are currently supported
88106

89107
_client_duration_attrs_old = [
90-
SpanAttributes.HTTP_STATUS_CODE,
91-
SpanAttributes.HTTP_HOST,
92-
SpanAttributes.NET_PEER_PORT,
93-
SpanAttributes.NET_PEER_NAME,
94-
SpanAttributes.HTTP_METHOD,
95-
SpanAttributes.HTTP_FLAVOR,
96-
SpanAttributes.HTTP_SCHEME,
108+
HTTP_STATUS_CODE,
109+
HTTP_HOST,
110+
HTTP_METHOD,
111+
HTTP_FLAVOR,
112+
HTTP_SCHEME,
113+
NET_PEER_PORT,
114+
NET_PEER_NAME,
97115
]
98116

99117
_client_duration_attrs_new = [
@@ -108,14 +126,14 @@
108126
]
109127

110128
_server_duration_attrs_old = [
111-
SpanAttributes.HTTP_METHOD,
112-
SpanAttributes.HTTP_HOST,
113-
SpanAttributes.HTTP_SCHEME,
114-
SpanAttributes.HTTP_STATUS_CODE,
115-
SpanAttributes.HTTP_FLAVOR,
116-
SpanAttributes.HTTP_SERVER_NAME,
117-
SpanAttributes.NET_HOST_NAME,
118-
SpanAttributes.NET_HOST_PORT,
129+
HTTP_METHOD,
130+
HTTP_HOST,
131+
HTTP_SCHEME,
132+
HTTP_STATUS_CODE,
133+
HTTP_FLAVOR,
134+
HTTP_SERVER_NAME,
135+
NET_HOST_NAME,
136+
NET_HOST_PORT,
119137
]
120138

121139
_server_duration_attrs_new = [
@@ -128,11 +146,11 @@
128146
]
129147

130148
_server_active_requests_count_attrs_old = [
131-
SpanAttributes.HTTP_METHOD,
132-
SpanAttributes.HTTP_HOST,
133-
SpanAttributes.HTTP_SCHEME,
134-
SpanAttributes.HTTP_FLAVOR,
135-
SpanAttributes.HTTP_SERVER_NAME,
149+
HTTP_METHOD,
150+
HTTP_HOST,
151+
HTTP_SCHEME,
152+
HTTP_FLAVOR,
153+
HTTP_SERVER_NAME,
136154
]
137155

138156
_server_active_requests_count_attrs_new = [
@@ -287,44 +305,42 @@ def _set_http_method(result, original, normalized, sem_conv_opt_in_mode):
287305
set_string_attribute(result, HTTP_REQUEST_METHOD_ORIGINAL, original)
288306

289307
if _report_old(sem_conv_opt_in_mode):
290-
set_string_attribute(result, SpanAttributes.HTTP_METHOD, normalized)
308+
set_string_attribute(result, HTTP_METHOD, normalized)
291309
if _report_new(sem_conv_opt_in_mode):
292310
set_string_attribute(result, HTTP_REQUEST_METHOD, normalized)
293311

294312

295313
def _set_http_status_code(result, code, sem_conv_opt_in_mode):
296314
if _report_old(sem_conv_opt_in_mode):
297-
set_int_attribute(result, SpanAttributes.HTTP_STATUS_CODE, code)
315+
set_int_attribute(result, HTTP_STATUS_CODE, code)
298316
if _report_new(sem_conv_opt_in_mode):
299317
set_int_attribute(result, HTTP_RESPONSE_STATUS_CODE, code)
300318

301319

302320
def _set_http_url(result, url, sem_conv_opt_in_mode):
303321
if _report_old(sem_conv_opt_in_mode):
304-
set_string_attribute(result, SpanAttributes.HTTP_URL, url)
322+
set_string_attribute(result, HTTP_URL, url)
305323
if _report_new(sem_conv_opt_in_mode):
306324
set_string_attribute(result, URL_FULL, url)
307325

308326

309327
def _set_http_scheme(result, scheme, sem_conv_opt_in_mode):
310328
if _report_old(sem_conv_opt_in_mode):
311-
set_string_attribute(result, SpanAttributes.HTTP_SCHEME, scheme)
329+
set_string_attribute(result, HTTP_SCHEME, scheme)
312330
if _report_new(sem_conv_opt_in_mode):
313331
set_string_attribute(result, URL_SCHEME, scheme)
314332

315333

316334
def _set_http_flavor_version(result, version, sem_conv_opt_in_mode):
317335
if _report_old(sem_conv_opt_in_mode):
318-
set_string_attribute(result, SpanAttributes.HTTP_FLAVOR, version)
336+
set_string_attribute(result, HTTP_FLAVOR, version)
319337
if _report_new(sem_conv_opt_in_mode):
320338
set_string_attribute(result, NETWORK_PROTOCOL_VERSION, version)
321339

322340

323341
def _set_http_user_agent(result, user_agent, sem_conv_opt_in_mode):
324342
if _report_old(sem_conv_opt_in_mode):
325-
set_string_attribute(
326-
result, SpanAttributes.HTTP_USER_AGENT, user_agent
327-
)
343+
set_string_attribute(result, HTTP_USER_AGENT, user_agent)
328344
if _report_new(sem_conv_opt_in_mode):
329345
set_string_attribute(result, USER_AGENT_ORIGINAL, user_agent)
330346

@@ -334,28 +350,28 @@ def _set_http_user_agent(result, user_agent, sem_conv_opt_in_mode):
334350

335351
def _set_http_host_client(result, host, sem_conv_opt_in_mode):
336352
if _report_old(sem_conv_opt_in_mode):
337-
set_string_attribute(result, SpanAttributes.HTTP_HOST, host)
353+
set_string_attribute(result, HTTP_HOST, host)
338354
if _report_new(sem_conv_opt_in_mode):
339355
set_string_attribute(result, SERVER_ADDRESS, host)
340356

341357

342358
def _set_http_net_peer_name_client(result, peer_name, sem_conv_opt_in_mode):
343359
if _report_old(sem_conv_opt_in_mode):
344-
set_string_attribute(result, SpanAttributes.NET_PEER_NAME, peer_name)
360+
set_string_attribute(result, NET_PEER_NAME, peer_name)
345361
if _report_new(sem_conv_opt_in_mode):
346362
set_string_attribute(result, SERVER_ADDRESS, peer_name)
347363

348364

349365
def _set_http_peer_port_client(result, port, sem_conv_opt_in_mode):
350366
if _report_old(sem_conv_opt_in_mode):
351-
set_int_attribute(result, SpanAttributes.NET_PEER_PORT, port)
367+
set_int_attribute(result, NET_PEER_PORT, port)
352368
if _report_new(sem_conv_opt_in_mode):
353369
set_int_attribute(result, SERVER_PORT, port)
354370

355371

356372
def _set_http_network_protocol_version(result, version, sem_conv_opt_in_mode):
357373
if _report_old(sem_conv_opt_in_mode):
358-
set_string_attribute(result, SpanAttributes.HTTP_FLAVOR, version)
374+
set_string_attribute(result, HTTP_FLAVOR, version)
359375
if _report_new(sem_conv_opt_in_mode):
360376
set_string_attribute(result, NETWORK_PROTOCOL_VERSION, version)
361377

@@ -365,21 +381,21 @@ def _set_http_network_protocol_version(result, version, sem_conv_opt_in_mode):
365381

366382
def _set_http_net_host(result, host, sem_conv_opt_in_mode):
367383
if _report_old(sem_conv_opt_in_mode):
368-
set_string_attribute(result, SpanAttributes.NET_HOST_NAME, host)
384+
set_string_attribute(result, NET_HOST_NAME, host)
369385
if _report_new(sem_conv_opt_in_mode):
370386
set_string_attribute(result, SERVER_ADDRESS, host)
371387

372388

373389
def _set_http_net_host_port(result, port, sem_conv_opt_in_mode):
374390
if _report_old(sem_conv_opt_in_mode):
375-
set_int_attribute(result, SpanAttributes.NET_HOST_PORT, port)
391+
set_int_attribute(result, NET_HOST_PORT, port)
376392
if _report_new(sem_conv_opt_in_mode):
377393
set_int_attribute(result, SERVER_PORT, port)
378394

379395

380396
def _set_http_target(result, target, path, query, sem_conv_opt_in_mode):
381397
if _report_old(sem_conv_opt_in_mode):
382-
set_string_attribute(result, SpanAttributes.HTTP_TARGET, target)
398+
set_string_attribute(result, HTTP_TARGET, target)
383399
if _report_new(sem_conv_opt_in_mode):
384400
if path:
385401
set_string_attribute(result, URL_PATH, path)
@@ -389,7 +405,7 @@ def _set_http_target(result, target, path, query, sem_conv_opt_in_mode):
389405

390406
def _set_http_host_server(result, host, sem_conv_opt_in_mode):
391407
if _report_old(sem_conv_opt_in_mode):
392-
set_string_attribute(result, SpanAttributes.HTTP_HOST, host)
408+
set_string_attribute(result, HTTP_HOST, host)
393409
if _report_new(sem_conv_opt_in_mode):
394410
if not result.get(SERVER_ADDRESS):
395411
set_string_attribute(result, SERVER_ADDRESS, host)
@@ -402,7 +418,7 @@ def _set_http_host_server(result, host, sem_conv_opt_in_mode):
402418
# https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md#common-attributes-across-http-client-and-server-spans
403419
def _set_http_peer_ip_server(result, ip, sem_conv_opt_in_mode):
404420
if _report_old(sem_conv_opt_in_mode):
405-
set_string_attribute(result, SpanAttributes.NET_PEER_IP, ip)
421+
set_string_attribute(result, NET_PEER_IP, ip)
406422
if _report_new(sem_conv_opt_in_mode):
407423
# Only populate if not already populated
408424
if not result.get(CLIENT_ADDRESS):
@@ -411,14 +427,14 @@ def _set_http_peer_ip_server(result, ip, sem_conv_opt_in_mode):
411427

412428
def _set_http_peer_port_server(result, port, sem_conv_opt_in_mode):
413429
if _report_old(sem_conv_opt_in_mode):
414-
set_int_attribute(result, SpanAttributes.NET_PEER_PORT, port)
430+
set_int_attribute(result, NET_PEER_PORT, port)
415431
if _report_new(sem_conv_opt_in_mode):
416432
set_int_attribute(result, CLIENT_PORT, port)
417433

418434

419435
def _set_http_net_peer_name_server(result, name, sem_conv_opt_in_mode):
420436
if _report_old(sem_conv_opt_in_mode):
421-
set_string_attribute(result, SpanAttributes.NET_PEER_NAME, name)
437+
set_string_attribute(result, NET_PEER_NAME, name)
422438
if _report_new(sem_conv_opt_in_mode):
423439
set_string_attribute(result, CLIENT_ADDRESS, name)
424440

@@ -450,10 +466,8 @@ def _set_status(
450466

451467
if _report_old(sem_conv_opt_in_mode):
452468
if span.is_recording():
453-
span.set_attribute(
454-
SpanAttributes.HTTP_STATUS_CODE, status_code
455-
)
456-
metrics_attributes[SpanAttributes.HTTP_STATUS_CODE] = status_code
469+
span.set_attribute(HTTP_STATUS_CODE, status_code)
470+
metrics_attributes[HTTP_STATUS_CODE] = status_code
457471
if _report_new(sem_conv_opt_in_mode):
458472
if span.is_recording():
459473
span.set_attribute(HTTP_RESPONSE_STATUS_CODE, status_code)
@@ -470,4 +484,4 @@ def _set_status(
470484
def _get_schema_url(mode: _StabilityMode) -> str:
471485
if mode is _StabilityMode.DEFAULT:
472486
return "https://opentelemetry.io/schemas/1.11.0"
473-
return SpanAttributes.SCHEMA_URL
487+
return Schemas.V1_21_0.value

0 commit comments

Comments
 (0)