Skip to content

Commit 2bfce50

Browse files
BYKsentrivana
andauthored
feat: Add httpcore based HTTP2Transport (#3588)
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]>
1 parent 55d757a commit 2bfce50

11 files changed

+490
-124
lines changed

requirements-testing.txt

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ executing
1010
asttokens
1111
responses
1212
pysocks
13+
socksio
14+
httpcore[http2]
1315
setuptools

sentry_sdk/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
from sentry_sdk.serializer import serialize
2525
from sentry_sdk.tracing import trace
26-
from sentry_sdk.transport import HttpTransport, make_transport
26+
from sentry_sdk.transport import BaseHttpTransport, make_transport
2727
from sentry_sdk.consts import (
2828
DEFAULT_MAX_VALUE_LENGTH,
2929
DEFAULT_OPTIONS,
@@ -427,7 +427,7 @@ def _capture_envelope(envelope):
427427
self.monitor
428428
or self.metrics_aggregator
429429
or has_profiling_enabled(self.options)
430-
or isinstance(self.transport, HttpTransport)
430+
or isinstance(self.transport, BaseHttpTransport)
431431
):
432432
# If we have anything on that could spawn a background thread, we
433433
# need to check if it's safe to use them.

sentry_sdk/consts.py

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class EndpointType(Enum):
6060
"otel_powered_performance": Optional[bool],
6161
"transport_zlib_compression_level": Optional[int],
6262
"transport_num_pools": Optional[int],
63+
"transport_http2": Optional[bool],
6364
"enable_metrics": Optional[bool],
6465
"before_emit_metric": Optional[
6566
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]

0 commit comments

Comments
 (0)