Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto committed Jun 28, 2024
1 parent 26dc8e8 commit 409897f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2616](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2616))
- `opentelemetry-instrumentation-confluent-kafka` Add support for produce purge
([#2638](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2638))
- `opentelemetry-instrumentation-httpx` Implement new semantic convention opt-in with stable http semantic conventions
([#2631](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2631))

### Breaking changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,18 @@ def _extract_response(
]
) -> typing.Tuple[int, Headers, httpx.SyncByteStream, dict, str]:
if isinstance(response, httpx.Response):
return (
response.status_code,
response.headers,
response.stream,
response.extensions,
response.http_version,
)

if isinstance(response, tuple):
status_code = response.status_code
headers = response.headers
stream = response.stream
extensions = response.extensions
http_version = response.http_version
else:
status_code, headers, stream, extensions = response
http_version = extensions.get("http_version", b"HTTP/1.1").decode(
"ascii", errors="ignore"
)
return (status_code, headers, stream, extensions, http_version)

return (status_code, headers, stream, extensions, http_version)


def _apply_request_client_attributes_to_span(
Expand Down Expand Up @@ -420,6 +418,7 @@ def __exit__(
) -> None:
self._transport.__exit__(exc_type, exc_value, traceback)

# pylint: disable=R0914
def handle_request(
self,
*args,
Expand Down Expand Up @@ -456,7 +455,7 @@ def handle_request(

try:
response = self._transport.handle_request(*args, **kwargs)
except Exception as exc:
except Exception as exc: # pylint: disable=W0703
exception = exc
response = getattr(exc, "response", None)

Expand Down Expand Up @@ -536,6 +535,7 @@ async def __aexit__(
) -> None:
await self._transport.__aexit__(exc_type, exc_value, traceback)

# pylint: disable=R0914
async def handle_async_request(self, *args, **kwargs) -> typing.Union[
typing.Tuple[int, "Headers", httpx.AsyncByteStream, dict],
httpx.Response,
Expand Down Expand Up @@ -570,7 +570,7 @@ async def handle_async_request(self, *args, **kwargs) -> typing.Union[
response = await self._transport.handle_async_request(
*args, **kwargs
)
except Exception as exc:
except Exception as exc: # pylint: disable=W0703
exception = exc
response = getattr(exc, "response", None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=too-many-lines

import abc
import asyncio
import typing
Expand Down Expand Up @@ -119,6 +121,9 @@ async def _async_no_update_request_hook(span: "Span", request: "RequestInfo"):
return 123


# pylint: disable=too-many-public-methods


# Using this wrapper class to have a base class for the tests while also not
# angering pylint or mypy when calling methods not in the class when only
# subclassing abc.ABC.
Expand Down

0 comments on commit 409897f

Please sign in to comment.