|
5 | 5 |
|
6 | 6 |
|
7 | 7 | def test_telemetry_is_noop_without_application_insights() -> None: |
8 | | - configure_telemetry(Settings()) |
| 8 | + with patch("cas_reference_product.telemetry.build_credential") as credential: |
| 9 | + configure_telemetry(Settings()) |
| 10 | + credential.assert_not_called() |
| 11 | + |
| 12 | + |
| 13 | +def test_telemetry_uses_identity_and_privacy_hardening() -> None: |
| 14 | + settings = Settings( |
| 15 | + environment="prod", |
| 16 | + applicationinsights_connection_string=( |
| 17 | + "InstrumentationKey=00000000-0000-0000-0000-000000000000" |
| 18 | + ), |
| 19 | + ) |
| 20 | + with ( |
| 21 | + patch("cas_reference_product.telemetry.build_credential") as credential, |
| 22 | + patch("azure.monitor.opentelemetry.configure_azure_monitor") as configure, |
| 23 | + ): |
| 24 | + configure_telemetry(settings) |
| 25 | + |
| 26 | + credential.assert_called_once_with("prod") |
| 27 | + configure.assert_called_once_with( |
| 28 | + connection_string=settings.applicationinsights_connection_string, |
| 29 | + credential=credential.return_value, |
| 30 | + disable_offline_storage=True, |
| 31 | + instrumentation_options={ |
| 32 | + "azure_sdk": {"enabled": False}, |
| 33 | + "requests": {"enabled": False}, |
| 34 | + "urllib": {"enabled": False}, |
| 35 | + "urllib3": {"enabled": False}, |
| 36 | + }, |
| 37 | + service_name=settings.app_name, |
| 38 | + ) |
9 | 39 |
|
10 | 40 |
|
11 | 41 | def test_invalid_span_preserves_incoming_traceparent() -> None: |
|
0 commit comments