-
Notifications
You must be signed in to change notification settings - Fork 825
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe your environment
OS: CentOS
Python version: 3.11
Package version: 0.60b0
What happened?
I'm requesting a S3-like cloud server(qcloud_cos), and when after i setup [opentelemetry-instrumentation-requests], requests went wrong and i got this exception
| Traceback (most recent call last):
-- | --
| File "/usr/local/lib/python3.11/site-packages/qcloud_cos/cos_client.py", line 427, in send_request
| res = self._session.head(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 624, in head
| return self.request("HEAD", url, **kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
| resp = self.send(prep, **send_kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/opentelemetry/instrumentation/requests/__init__.py", line 256, in instrumented_send
| synthetic_type = detect_synthetic_user_agent(user_agent)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/opentelemetry/util/http/__init__.py", line 329, in detect_synthetic_user_agent
| if any(test_pattern in user_agent_lower for test_pattern in TEST_PATTERNS):
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.11/site-packages/opentelemetry/util/http/__init__.py", line 329, in <genexpr>
| if any(test_pattern in user_agent_lower for test_pattern in TEST_PATTERNS):
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| TypeError: a bytes-like object is required, not 'str'
|
Notice that, a S3-like client sdk would format header into bytes before calling requests, and opentelemetry-util-http add user-agent detection in version 0.60b0(which never happened <=0.59b0)
Steps to Reproduce
from opentelemetry.instrumentation.requests import RequestsInstrumentor
RequestsInstrumentor().instrument()
from qcloud_cos import CosConfig, CosS3Client
config = CosConfig(SecretId=ak, SecretKey=sk, Endpoint=endpoint, Scheme='http', KeepAlive=False)
cos_client = CosS3Client(config)
cos_client.head_object(bucket, key)
Expected Result
i expect the code run normally and would not raise and Exception
Actual Result
Exception thrown due to incompatible of bytes-like headers
Additional context
No response
Would you like to implement a fix?
None
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working