Skip to content

Commit e6651e4

Browse files
committed
.
1 parent c1dd56a commit e6651e4

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

sentry_sdk/integrations/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ def _enable_integration(integration: "Integration") -> "Optional[Integration]":
285285
client = sentry_sdk.get_client()
286286

287287
with _installer_lock:
288+
if identifier in client.integrations:
289+
logger.debug("Integration already enabled: %s", identifier)
290+
return None
291+
288292
logger.debug("Setting up integration %s", identifier)
289293
_processed_integrations.add(identifier)
290294
try:

sentry_sdk/integrations/asyncio.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ def enable_asyncio_integration(*args: "Any", **kwargs: "Any") -> None:
144144
"""
145145
Enable AsyncioIntegration with the provided options.
146146
147-
The options need to correspond to the options currently accepted by the
148-
AsyncioIntegration() constructor.
149-
150147
This is useful in scenarios where Sentry needs to be initialized before
151148
an event loop is set up, but you still want to instrument asyncio once there
152149
is an event loop. In that case, you can sentry_sdk.init() early on without
@@ -159,8 +156,10 @@ async def async_entrypoint():
159156
enable_asyncio_integration()
160157
```
161158
159+
Any arguments provided will be passed to AsyncioIntegration() as-is.
160+
162161
If AsyncioIntegration is already enabled (e.g. because it was provided in
163-
sentry_sdk.init(integrations=[...])), this function will re-enable it.
162+
sentry_sdk.init(integrations=[...])), this function won't have any effect.
164163
165164
If AsyncioIntegration was provided in
166165
sentry_sdk.init(disabled_integrations=[...]), this function will ignore that

tests/integrations/asyncio/test_asyncio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,17 @@ async def test_delayed_enable_integration_with_options(sentry_init, capture_even
458458
@minimum_python_38
459459
@pytest.mark.asyncio
460460
async def test_delayed_enable_enabled_integration(sentry_init):
461-
sentry_init(integrations=[AsyncioIntegration()], traces_sample_rate=1.0)
461+
integration = AsyncioIntegration()
462+
sentry_init(integrations=[integration], traces_sample_rate=1.0)
462463

463464
assert "asyncio" in sentry_sdk.get_client().integrations
464465

465-
original_integration = sentry_sdk.get_client().integrations["asyncio"]
466466
enable_asyncio_integration()
467467

468468
assert "asyncio" in sentry_sdk.get_client().integrations
469469

470-
# The new asyncio integration should override the old one
471-
assert sentry_sdk.get_client().integrations["asyncio"] is not original_integration
470+
# The new asyncio integration should not override the old one
471+
assert sentry_sdk.get_client().integrations["asyncio"] == integration
472472

473473

474474
@minimum_python_38

0 commit comments

Comments
 (0)