32
32
33
33
from .. import PipelineRequest , PipelineResponse
34
34
from ..policies import SansIOHTTPPolicy
35
- from ..transport import HttpResponse as LegacyHttpResponse , HttpRequest as LegacyHttpRequest
36
35
from ...rest import HttpResponse , HttpRequest
37
36
from ...settings import settings
38
37
from ...tracing import SpanKind
42
41
AbstractSpan ,
43
42
)
44
43
45
- HTTPResponseType = TypeVar ("HTTPResponseType" , HttpResponse , LegacyHttpResponse )
46
- HTTPRequestType = TypeVar ("HTTPRequestType" , HttpRequest , LegacyHttpRequest )
44
+ HTTPResponseType = TypeVar ("HTTPResponseType" , bound = HttpResponse )
45
+ HTTPRequestType = TypeVar ("HTTPRequestType" , bound = HttpRequest )
47
46
ExcInfo = Tuple [Type [BaseException ], BaseException , TracebackType ]
48
47
OptExcInfo = Union [ExcInfo , Tuple [None , None , None ]]
49
48
@@ -54,7 +53,7 @@ def _default_network_span_namer(http_request: HTTPRequestType) -> str:
54
53
"""Extract the path to be used as network span name.
55
54
56
55
:param http_request: The HTTP request
57
- :type http_request: ~generic.core.pipeline.transport .HttpRequest
56
+ :type http_request: ~generic.core.rest .HttpRequest
58
57
:returns: The string to use as network span name
59
58
:rtype: str
60
59
"""
@@ -68,14 +67,14 @@ class DistributedTracingPolicy(SansIOHTTPPolicy[HTTPRequestType, HTTPResponseTyp
68
67
"""The policy to create spans for service calls.
69
68
70
69
:keyword network_span_namer: A callable to customize the span name
71
- :type network_span_namer: callable[[~generic.core.pipeline.transport .HttpRequest], str]
70
+ :type network_span_namer: callable[[~generic.core.rest .HttpRequest], str]
72
71
:keyword tracing_attributes: Attributes to set on all created spans
73
72
:type tracing_attributes: dict[str, str]
74
73
"""
75
74
76
75
TRACING_CONTEXT = "TRACING_CONTEXT"
77
- _REQUEST_ID = "x-ms- client-request-id"
78
- _RESPONSE_ID = "x-ms- request-id"
76
+ _REQUEST_ID = "x-client-request-id"
77
+ _RESPONSE_ID = "x-request-id"
79
78
80
79
def __init__ (self , ** kwargs : Any ):
81
80
self ._network_span_namer = kwargs .get ("network_span_namer" , _default_network_span_namer )
@@ -114,15 +113,15 @@ def end_span(
114
113
:param request: The PipelineRequest object
115
114
:type request: ~generic.core.pipeline.PipelineRequest
116
115
:param response: The HttpResponse object
117
- :type response: ~generic.core.rest.HTTPResponse or ~generic.core.pipeline.transport .HttpResponse
116
+ :type response: ~generic.core.rest.HTTPResponse or ~generic.core.rest .HttpResponse
118
117
:param exc_info: The exception information
119
118
:type exc_info: tuple
120
119
"""
121
120
if self .TRACING_CONTEXT not in request .context :
122
121
return
123
122
124
123
span : "AbstractSpan" = request .context [self .TRACING_CONTEXT ]
125
- http_request : Union [ HttpRequest , LegacyHttpRequest ] = request .http_request
124
+ http_request : HttpRequest = request .http_request
126
125
if span is not None :
127
126
span .set_http_attributes (http_request , response = response )
128
127
request_id = http_request .headers .get (self ._REQUEST_ID )
0 commit comments