File tree 2 files changed +25
-12
lines changed
opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi
opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi
2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change 33
33
from opentelemetry .trace .status import Status , StatusCanonicalCode
34
34
35
35
36
- # pylint:disable=arguments-differ
37
36
class CarrierGetter (DictGetter ):
38
- def get (self , scope : dict , header_name : str ) -> typing .List [str ]:
39
- headers = scope .get ("headers" )
37
+ def get (self , carrier : dict , key : str ) -> typing .List [str ]:
38
+ """Getter implementation to retrieve a HTTP header value from the ASGI
39
+ scope.
40
+
41
+ Args:
42
+ carrier: ASGI scope object
43
+ key: header name in scope
44
+ Returns:
45
+ A list with a single string with the header value if it exists,
46
+ else an empty list.
47
+ """
48
+ headers = carrier .get ("headers" )
40
49
return [
41
- value .decode ("utf8" )
42
- for (key , value ) in headers
43
- if key .decode ("utf8" ) == header_name
50
+ _value .decode ("utf8" )
51
+ for (_key , _value ) in headers
52
+ if _key .decode ("utf8" ) == key
44
53
]
45
54
46
55
Original file line number Diff line number Diff line change @@ -67,16 +67,20 @@ def hello():
67
67
_HTTP_VERSION_PREFIX = "HTTP/"
68
68
69
69
70
- # pylint:disable=arguments-differ
71
70
class CarrierGetter (DictGetter ):
72
- def get (self , environ : dict , header_name : str ) -> typing .List [str ]:
73
- """Retrieve a HTTP header value from the PEP3333-conforming WSGI environ.
71
+ def get (self , carrier : dict , key : str ) -> typing .List [str ]:
72
+ """Getter implementation to retrieve a HTTP header value from the
73
+ PEP3333-conforming WSGI environ
74
74
75
+ Args:
76
+ carrier: WSGI environ object
77
+ key: header name in environ object
75
78
Returns:
76
- A list with a single string with the header value if it exists, else an empty list.
79
+ A list with a single string with the header value if it exists,
80
+ else an empty list.
77
81
"""
78
- environ_key = "HTTP_" + header_name .upper ().replace ("-" , "_" )
79
- value = environ .get (environ_key )
82
+ environ_key = "HTTP_" + key .upper ().replace ("-" , "_" )
83
+ value = carrier .get (environ_key )
80
84
if value is not None :
81
85
return [value ]
82
86
return []
You can’t perform that action at this time.
0 commit comments