Skip to content

Commit

Permalink
feat: Add httpcore based HTTP2Transport (#3588)
Browse files Browse the repository at this point in the history
All our ingest endpoints support HTTP/2 and some even HTTP/3 which are significantly more efficient compared to HTTP/1.1 with multiplexing and, header compression, connection reuse and 0-RTT TLS.

This patch adds an experimental HTTP2Transport with the help of httpcore library. It makes minimal changes to the original HTTPTransport that said with httpcore we should be able to implement asyncio support easily and remove the worker logic (see #2824).

This should also open the door for future HTTP/3 support (see encode/httpx#275).


---------

Co-authored-by: Ivana Kellyer <[email protected]>
  • Loading branch information
BYK and sentrivana authored Oct 4, 2024
1 parent 55d757a commit 2bfce50
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 124 deletions.
2 changes: 2 additions & 0 deletions requirements-testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ executing
asttokens
responses
pysocks
socksio
httpcore[http2]
setuptools
4 changes: 2 additions & 2 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from sentry_sdk.serializer import serialize
from sentry_sdk.tracing import trace
from sentry_sdk.transport import HttpTransport, make_transport
from sentry_sdk.transport import BaseHttpTransport, make_transport
from sentry_sdk.consts import (
DEFAULT_MAX_VALUE_LENGTH,
DEFAULT_OPTIONS,
Expand Down Expand Up @@ -427,7 +427,7 @@ def _capture_envelope(envelope):
self.monitor
or self.metrics_aggregator
or has_profiling_enabled(self.options)
or isinstance(self.transport, HttpTransport)
or isinstance(self.transport, BaseHttpTransport)
):
# If we have anything on that could spawn a background thread, we
# need to check if it's safe to use them.
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class EndpointType(Enum):
"otel_powered_performance": Optional[bool],
"transport_zlib_compression_level": Optional[int],
"transport_num_pools": Optional[int],
"transport_http2": Optional[bool],
"enable_metrics": Optional[bool],
"before_emit_metric": Optional[
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]
Expand Down
Loading

0 comments on commit 2bfce50

Please sign in to comment.