|
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
| 5 | +from sentry_sdk.integrations.opentelemetry.integration import OpenTelemetryIntegration |
| 6 | + |
5 | 7 |
|
6 | 8 | @pytest.mark.forked |
7 | 9 | def test_integration_enabled_if_option_is_on(sentry_init, reset_integrations): |
8 | | - mocked_setup_once = MagicMock() |
| 10 | + mocked_setup_sentry_tracing = MagicMock() |
9 | 11 |
|
10 | 12 | with patch( |
11 | | - "sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once", |
12 | | - mocked_setup_once, |
| 13 | + "sentry_sdk.integrations.opentelemetry.integration._setup_sentry_tracing", |
| 14 | + mocked_setup_sentry_tracing, |
13 | 15 | ): |
14 | | - sentry_init( |
15 | | - _experiments={ |
16 | | - "otel_powered_performance": True, |
17 | | - }, |
18 | | - ) |
19 | | - mocked_setup_once.assert_called_once() |
| 16 | + with pytest.warns(DeprecationWarning): |
| 17 | + sentry_init(_experiments={"otel_powered_performance": True}) |
| 18 | + mocked_setup_sentry_tracing.assert_called_once() |
20 | 19 |
|
21 | 20 |
|
22 | 21 | @pytest.mark.forked |
23 | 22 | def test_integration_not_enabled_if_option_is_off(sentry_init, reset_integrations): |
24 | | - mocked_setup_once = MagicMock() |
| 23 | + mocked_setup_sentry_tracing = MagicMock() |
25 | 24 |
|
26 | 25 | with patch( |
27 | | - "sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once", |
28 | | - mocked_setup_once, |
| 26 | + "sentry_sdk.integrations.opentelemetry.integration._setup_sentry_tracing", |
| 27 | + mocked_setup_sentry_tracing, |
29 | 28 | ): |
30 | | - sentry_init( |
31 | | - _experiments={ |
32 | | - "otel_powered_performance": False, |
33 | | - }, |
34 | | - ) |
35 | | - mocked_setup_once.assert_not_called() |
| 29 | + sentry_init(_experiments={"otel_powered_performance": False}) |
| 30 | + mocked_setup_sentry_tracing.assert_not_called() |
36 | 31 |
|
37 | 32 |
|
38 | 33 | @pytest.mark.forked |
39 | 34 | def test_integration_not_enabled_if_option_is_missing(sentry_init, reset_integrations): |
40 | | - mocked_setup_once = MagicMock() |
| 35 | + mocked_setup_sentry_tracing = MagicMock() |
41 | 36 |
|
42 | 37 | with patch( |
43 | | - "sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration.setup_once", |
44 | | - mocked_setup_once, |
| 38 | + "sentry_sdk.integrations.opentelemetry.integration._setup_sentry_tracing", |
| 39 | + mocked_setup_sentry_tracing, |
45 | 40 | ): |
46 | 41 | sentry_init() |
47 | | - mocked_setup_once.assert_not_called() |
| 42 | + mocked_setup_sentry_tracing.assert_not_called() |
| 43 | + |
| 44 | + |
| 45 | +@pytest.mark.forked |
| 46 | +def test_integration_disabled_with_span_streaming(sentry_init, reset_integrations): |
| 47 | + mocked_setup_sentry_tracing = MagicMock() |
| 48 | + |
| 49 | + with patch( |
| 50 | + "sentry_sdk.integrations.opentelemetry.integration._setup_sentry_tracing", |
| 51 | + mocked_setup_sentry_tracing, |
| 52 | + ): |
| 53 | + sentry_init( |
| 54 | + integrations=[OpenTelemetryIntegration()], |
| 55 | + _experiments={"trace_lifecycle": "stream"}, |
| 56 | + ) |
| 57 | + mocked_setup_sentry_tracing.assert_not_called() |
0 commit comments