24
24
)
25
25
from kiota_abstractions .store import BackingStoreFactory , BackingStoreFactorySingleton
26
26
from opentelemetry import trace
27
- from opentelemetry .semconv .trace import SpanAttributes
27
+ from opentelemetry .semconv .attributes .http_attributes import (
28
+ HTTP_RESPONSE_STATUS_CODE ,
29
+ HTTP_REQUEST_METHOD ,
30
+ )
31
+ from opentelemetry .semconv .attributes .network_attributes import NETWORK_PROTOCOL_NAME
32
+ from opentelemetry .semconv .attributes .server_attributes import SERVER_ADDRESS
33
+ from opentelemetry .semconv .attributes .url_attributes import URL_SCHEME , URL_FULL
28
34
29
35
from kiota_http ._exceptions import (
30
36
BackingStoreError ,
@@ -529,15 +535,15 @@ async def get_http_response_message(
529
535
resp = await self ._http_client .send (request )
530
536
if not resp :
531
537
raise ResponseError ("Unable to get response from request" )
532
- parent_span .set_attribute (SpanAttributes . HTTP_STATUS_CODE , resp .status_code )
538
+ parent_span .set_attribute (HTTP_RESPONSE_STATUS_CODE , resp .status_code )
533
539
if http_version := resp .http_version :
534
- parent_span .set_attribute (SpanAttributes . HTTP_FLAVOR , http_version )
540
+ parent_span .set_attribute (NETWORK_PROTOCOL_NAME , http_version )
535
541
536
542
if content_length := resp .headers .get ("Content-Length" , None ):
537
- parent_span .set_attribute (SpanAttributes . HTTP_RESPONSE_CONTENT_LENGTH , content_length )
543
+ parent_span .set_attribute ("http.response.body.size" , content_length )
538
544
539
545
if content_type := resp .headers .get ("Content-Type" , None ):
540
- parent_span .set_attribute ("http.response_content_type " , content_type )
546
+ parent_span .set_attribute ("http.response.header.content-type " , content_type )
541
547
_get_http_resp_span .end ()
542
548
return await self .retry_cae_response_if_required (resp , request_info , claims )
543
549
@@ -586,15 +592,15 @@ def get_request_from_request_information(
586
592
)
587
593
url = parse .urlparse (request_info .url )
588
594
otel_attributes = {
589
- SpanAttributes . HTTP_METHOD : request_info .http_method ,
595
+ HTTP_REQUEST_METHOD : request_info .http_method ,
590
596
"http.port" : url .port ,
591
- SpanAttributes . HTTP_HOST : url .hostname ,
592
- SpanAttributes . HTTP_SCHEME : url .scheme ,
593
- "http .uri_template" : request_info .url_template ,
597
+ URL_SCHEME : url .hostname ,
598
+ SERVER_ADDRESS : url .scheme ,
599
+ "url .uri_template" : request_info .url_template ,
594
600
}
595
601
596
602
if self .observability_options .include_euii_attributes :
597
- otel_attributes .update ({"http.uri" : url .geturl ()})
603
+ otel_attributes .update ({URL_FULL : url .geturl ()})
598
604
599
605
request = self ._http_client .build_request (
600
606
method = request_info .http_method .value ,
@@ -610,10 +616,10 @@ def get_request_from_request_information(
610
616
setattr (request , "options" , request_options )
611
617
612
618
if content_length := request .headers .get ("Content-Length" , None ):
613
- otel_attributes .update ({SpanAttributes . HTTP_REQUEST_CONTENT_LENGTH : content_length })
619
+ otel_attributes .update ({"http.request.body.size" : content_length })
614
620
615
621
if content_type := request .headers .get ("Content-Type" , None ):
616
- otel_attributes .update ({"http.request_content_type " : content_type })
622
+ otel_attributes .update ({"http.request.header.content-type " : content_type })
617
623
attribute_span .set_attributes (otel_attributes )
618
624
_get_request_span .set_attributes (otel_attributes )
619
625
_get_request_span .end ()
0 commit comments