Skip to content

Commit d600037

Browse files
committed
Merge branch 'master' into sentry-sdk-2.0
2 parents ef3f691 + e864eab commit d600037

26 files changed

Lines changed: 744 additions & 356 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
- id: end-of-file-fixer
99

1010
- repo: https://github.com/psf/black
11-
rev: 22.6.0
11+
rev: 24.1.0
1212
hooks:
1313
- id: black
1414
exclude: ^(.*_pb2.py|.*_pb2_grpc.py)

docs/apidocs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ API Docs
1111
.. autoclass:: sentry_sdk.Client
1212
:members:
1313

14+
.. autoclass:: sentry_sdk.client._Client
15+
:members:
16+
1417
.. autoclass:: sentry_sdk.Transport
1518
:members:
1619

scripts/split-tox-gh-actions/split-tox-gh-actions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
files have been changed by the scripts execution. This is used in CI to check if the yaml files
1515
represent the current tox.ini file. (And if not the CI run fails.)
1616
"""
17+
1718
import configparser
1819
import hashlib
1920
import sys
@@ -75,6 +76,8 @@
7576
"asyncpg",
7677
"clickhouse_driver",
7778
"pymongo",
79+
"redis",
80+
"rediscluster",
7881
"sqlalchemy",
7982
],
8083
"GraphQL": [
@@ -102,8 +105,6 @@
102105
"falcon",
103106
"pyramid",
104107
"quart",
105-
"redis",
106-
"rediscluster",
107108
"sanic",
108109
"starlite",
109110
"tornado",

sentry_sdk/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ def capture_event(
8383
event, # type: Event
8484
hint=None, # type: Optional[Hint]
8585
scope=None, # type: Optional[Any]
86-
**scope_args # type: Any
86+
**scope_kwargs # type: Any
8787
):
8888
# type: (...) -> Optional[str]
89-
return Hub.current.capture_event(event, hint, scope=scope, **scope_args)
89+
return Hub.current.capture_event(event, hint, scope=scope, **scope_kwargs)
9090

9191

9292
@hubmethod
9393
def capture_message(
9494
message, # type: str
9595
level=None, # type: Optional[str]
9696
scope=None, # type: Optional[Any]
97-
**scope_args # type: Any
97+
**scope_kwargs # type: Any
9898
):
9999
# type: (...) -> Optional[str]
100-
return Hub.current.capture_message(message, level, scope=scope, **scope_args)
100+
return Hub.current.capture_message(message, level, scope=scope, **scope_kwargs)
101101

102102

103103
@hubmethod
104104
def capture_exception(
105105
error=None, # type: Optional[Union[BaseException, ExcInfo]]
106106
scope=None, # type: Optional[Any]
107-
**scope_args # type: Any
107+
**scope_kwargs # type: Any
108108
):
109109
# type: (...) -> Optional[str]
110-
return Hub.current.capture_exception(error, scope=scope, **scope_args)
110+
return Hub.current.capture_exception(error, scope=scope, **scope_kwargs)
111111

112112

113113
@hubmethod

sentry_sdk/client.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
from typing import Dict
4444
from typing import Optional
4545
from typing import Sequence
46+
from typing import Type
47+
from typing import Union
4648

49+
from sentry_sdk.integrations import Integration
4750
from sentry_sdk.scope import Scope
4851
from sentry_sdk._types import Event, Hint
4952
from sentry_sdk.session import Session
@@ -153,6 +156,8 @@ class _Client:
153156
forwarding them to sentry through the configured transport. It takes
154157
the client options as keyword arguments and optionally the DSN as first
155158
argument.
159+
160+
Alias of :py:class:`Client`. (Was created for better intelisense support)
156161
"""
157162

158163
def __init__(self, *args, **kwargs):
@@ -563,8 +568,8 @@ def capture_event(
563568
564569
:param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.
565570
566-
:param scope: An optional scope to use for determining whether this event
567-
should be captured.
571+
:param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
572+
The `scope` and `scope_kwargs` parameters are mutually exclusive.
568573
569574
:returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help.
570575
"""
@@ -667,6 +672,22 @@ def capture_session(
667672
else:
668673
self.session_flusher.add_session(session)
669674

675+
def get_integration(
676+
self, name_or_class # type: Union[str, Type[Integration]]
677+
):
678+
# type: (...) -> Any
679+
"""Returns the integration for this client by name or class.
680+
If the client does not have that integration then `None` is returned.
681+
"""
682+
if isinstance(name_or_class, str):
683+
integration_name = name_or_class
684+
elif name_or_class.identifier is not None:
685+
integration_name = name_or_class.identifier
686+
else:
687+
raise ValueError("Integration has no name")
688+
689+
return self.integrations.get(integration_name)
690+
670691
def close(
671692
self,
672693
timeout=None, # type: Optional[float]

0 commit comments

Comments
 (0)