Skip to content

Commit

Permalink
Merge branch 'potel-base' into antonpirker/potel/fix-celery
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker authored Jan 7, 2025
2 parents 0f84b11 + 0f34b49 commit 781e630
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def setup_once():
def patch_enqueue_job():
# type: () -> None
old_enqueue_job = ArqRedis.enqueue_job
original_kwdefaults = old_enqueue_job.__kwdefaults__

async def _sentry_enqueue_job(self, function, *args, **kwargs):
# type: (ArqRedis, str, *Any, **Any) -> Optional[Job]
Expand All @@ -88,6 +89,7 @@ async def _sentry_enqueue_job(self, function, *args, **kwargs):
):
return await old_enqueue_job(self, function, *args, **kwargs)

_sentry_enqueue_job.__kwdefaults__ = original_kwdefaults
ArqRedis.enqueue_job = _sentry_enqueue_job


Expand Down
41 changes: 28 additions & 13 deletions tests/integrations/launchdarkly/test_launchdarkly.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def test_launchdarkly_integration(
sentry_init, use_global_client, capture_events, uninstall_integration
):
td = TestData.data_source()
config = Config("sdk-key", update_processor_class=td)
td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(True))
# Disable background requests as we aren't using a server.
config = Config(
"sdk-key", update_processor_class=td, diagnostic_opt_out=True, send_events=False
)

uninstall_integration(LaunchDarklyIntegration.identifier)
if use_global_client:
Expand All @@ -33,10 +38,6 @@ def test_launchdarkly_integration(
client = LDClient(config=config)
sentry_init(integrations=[LaunchDarklyIntegration(ld_client=client)])

# Set test values
td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(True))

# Evaluate
client.variation("hello", Context.create("my-org", "organization"), False)
client.variation("world", Context.create("user1", "user"), False)
Expand All @@ -59,7 +60,16 @@ def test_launchdarkly_integration_threaded(
sentry_init, capture_events, uninstall_integration
):
td = TestData.data_source()
client = LDClient(config=Config("sdk-key", update_processor_class=td))
td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(True))
client = LDClient(
config=Config(
"sdk-key",
update_processor_class=td,
diagnostic_opt_out=True, # Disable background requests as we aren't using a server.
send_events=False,
)
)
context = Context.create("user1")

uninstall_integration(LaunchDarklyIntegration.identifier)
Expand All @@ -75,8 +85,6 @@ def task(flag_key):
sentry_sdk.set_tag("task_id", flag_key)
sentry_sdk.capture_exception(Exception("something wrong!"))

td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(False))
# Capture an eval before we split isolation scopes.
client.variation("hello", context, False)

Expand Down Expand Up @@ -104,7 +112,7 @@ def task(flag_key):
assert events[2]["contexts"]["flags"] == {
"values": [
{"flag": "hello", "result": True},
{"flag": "world", "result": False},
{"flag": "world", "result": True},
]
}

Expand All @@ -118,7 +126,16 @@ def test_launchdarkly_integration_asyncio(
asyncio = pytest.importorskip("asyncio")

td = TestData.data_source()
client = LDClient(config=Config("sdk-key", update_processor_class=td))
td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(True))
client = LDClient(
config=Config(
"sdk-key",
update_processor_class=td,
diagnostic_opt_out=True, # Disable background requests as we aren't using a server.
send_events=False,
)
)
context = Context.create("user1")

uninstall_integration(LaunchDarklyIntegration.identifier)
Expand All @@ -135,8 +152,6 @@ async def task(flag_key):
async def runner():
return asyncio.gather(task("world"), task("other"))

td.update(td.flag("hello").variation_for_all(True))
td.update(td.flag("world").variation_for_all(False))
# Capture an eval before we split isolation scopes.
client.variation("hello", context, False)

Expand All @@ -163,7 +178,7 @@ async def runner():
assert events[2]["contexts"]["flags"] == {
"values": [
{"flag": "hello", "result": True},
{"flag": "world", "result": False},
{"flag": "world", "result": True},
]
}

Expand Down

0 comments on commit 781e630

Please sign in to comment.