Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from sentry_sdk._types import MYPY

if MYPY:
import sentry_sdk

from typing import Optional
from typing import Callable
from typing import Union
Expand All @@ -11,7 +13,6 @@
from typing import Sequence
from typing_extensions import TypedDict

from sentry_sdk.transport import Transport
from sentry_sdk.integrations import Integration

from sentry_sdk._types import (
Expand All @@ -36,6 +37,7 @@
total=False,
)

DEFAULT_QUEUE_SIZE = 100
DEFAULT_MAX_BREADCRUMBS = 100


Expand All @@ -56,7 +58,8 @@ def __init__(
in_app_exclude=[], # type: List[str] # noqa: B006
default_integrations=True, # type: bool
dist=None, # type: Optional[str]
transport=None, # type: Optional[Union[Transport, Type[Transport], Callable[[Event], None]]]
transport=None, # type: Optional[Union[sentry_sdk.transport.Transport, Type[sentry_sdk.transport.Transport], Callable[[Event], None]]]
transport_queue_size=DEFAULT_QUEUE_SIZE, # type: int
sample_rate=1.0, # type: float
send_default_pii=False, # type: bool
http_proxy=None, # type: Optional[str]
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def __init__(

Transport.__init__(self, options)
assert self.parsed_dsn is not None
self._worker = BackgroundWorker()
self.options = options
self._worker = BackgroundWorker(queue_size=options["transport_queue_size"])
self._auth = self.parsed_dsn.to_auth("sentry.python/%s" % VERSION)
self._disabled_until = {} # type: Dict[DataCategory, datetime]
self._retry = urllib3.util.Retry()
self.options = options

self._pool = self._make_pool(
self.parsed_dsn,
Expand Down
9 changes: 7 additions & 2 deletions sentry_sdk/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sentry_sdk._compat import check_thread_support
from sentry_sdk._queue import Queue, Full
from sentry_sdk.utils import logger
from sentry_sdk.consts import DEFAULT_QUEUE_SIZE

from sentry_sdk._types import MYPY

Expand All @@ -18,7 +19,7 @@


class BackgroundWorker(object):
def __init__(self, queue_size=30):
def __init__(self, queue_size=DEFAULT_QUEUE_SIZE):
# type: (int) -> None
check_thread_support()
self._queue = Queue(queue_size) # type: Queue
Expand Down Expand Up @@ -110,7 +111,11 @@ def submit(self, callback):
try:
self._queue.put_nowait(callback)
except Full:
logger.debug("background worker queue full, dropping event")
self.on_full_queue(callback)

def on_full_queue(self, callback):
# type: (Optional[Any]) -> None
logger.debug("background worker queue full, dropping event")

def _target(self):
# type: () -> None
Expand Down