Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

### Features Added

- Default Resource Detector environment variable to allow for customization. Add App Service Resource Detector to Auto-Instrumentation.
- Add App Service Resource Detector to Auto-Instrumentation.
([#33340](https://github.com/Azure/azure-sdk-for-python/pull/33340))
- Remove VM Resource Detector while bug is investigated.
([#33305](https://github.com/Azure/azure-sdk-for-python/pull/33305))
([#33373](https://github.com/Azure/azure-sdk-for-python/pull/33373))

## 1.1.0 (2023-11-08)

Expand Down
1 change: 0 additions & 1 deletion sdk/monitor/azure-monitor-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ You can configure further with [OpenTelemetry environment variables][ot_env_vars
| `OTEL_BSP_SCHEDULE_DELAY` | Specifies the distributed tracing export interval in milliseconds. Defaults to 5000. |
| `OTEL_TRACES_SAMPLER_ARG` | Specifies the ratio of distributed tracing telemetry to be [sampled][application_insights_sampling]. Accepted values are in the range [0,1]. Defaults to 1.0, meaning no telemetry is sampled out. |
| `OTEL_PYTHON_DISABLED_INSTRUMENTATIONS` | Specifies which of the supported instrumentations to disable. Disabled instrumentations will not be instrumented as part of `configure_azure_monitor`. However, they can still be manually instrumented with `instrument()` directly. Accepts a comma-separated list of lowercase [Library Names](#officially-supported-instrumentations). For example, set to `"psycopg2,fastapi"` to disable the Psycopg2 and FastAPI instrumentations. Defaults to an empty list, enabling all supported instrumentations. |
| `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` | Specifies OpenTelemetry Resource Detectors to be used to generate Resource Attributes. Defaults to "azure_app_service,azure_vm" to enable the [Azure Resource Detectors][ot_resource_detector_azure] for Azure App Service and Azure VM. See the [OpenTelemetry Python Resource Detector Documentation][ot_python_resource_detectors] for more. |

#### Azure monitor OpenTelemetry Exporter configurations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
_ALL_SUPPORTED_INSTRUMENTED_LIBRARIES,
_AZURE_APP_SERVICE_RESOURCE_DETECTOR_NAME,
_AZURE_SDK_INSTRUMENTATION_NAME,
_AZURE_VM_RESOURCE_DETECTOR_NAME,
DISABLE_LOGGING_ARG,
DISABLE_METRICS_ARG,
DISABLE_TRACING_ARG,
Expand All @@ -54,7 +53,7 @@

_SUPPORTED_RESOURCE_DETECTORS = (
_AZURE_APP_SERVICE_RESOURCE_DETECTOR_NAME,
_AZURE_VM_RESOURCE_DETECTOR_NAME,
# _AZURE_VM_RESOURCE_DETECTOR_NAME,
)

_logger = getLogger(__name__)
Expand Down Expand Up @@ -104,10 +103,11 @@ def configure_azure_monitor(**kwargs) -> None:
_setup_instrumentations(configurations)

def _setup_resources():
os.environ.setdefault(
OTEL_EXPERIMENTAL_RESOURCE_DETECTORS,
",".join(_SUPPORTED_RESOURCE_DETECTORS)
)
detectors = os.environ.get(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS, "")
if detectors:
detectors = detectors + ","
detectors += ",".join(_SUPPORTED_RESOURCE_DETECTORS)
os.environ[OTEL_EXPERIMENTAL_RESOURCE_DETECTORS] = detectors


def _setup_tracing(configurations: Dict[str, ConfigurationValue]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,26 @@ def test_setup_resources(self):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
"azure_app_service,azure_vm"
# TODO: Change back to "azure_app_service,azure_vm" after VM Resource Detector fix for https://github.com/Azure/azure-sdk-for-python/issues/33295
"azure_app_service"
)

@patch.dict("os.environ", {"OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "test_detector"})
def test_setup_resources_existing_detectors(self):
@patch.dict("os.environ", {"OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": ""})
def test_setup_resources_empty_string(self):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
"test_detector"
# TODO: Change back to "azure_app_service,azure_vm" after VM Resource Detector fix for https://github.com/Azure/azure-sdk-for-python/issues/33295
"azure_app_service"
)

@patch.dict("os.environ", {"OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "test_detector,azure_vm"})
def test_setup_resources_existing_with_azure_detectors(self):
@patch.dict("os.environ", {"OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "test_detector"})
def test_setup_resources_existing_detectors(self):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
"test_detector,azure_vm"
# TODO: Change back to "azure_app_service,azure_vm" after VM Resource Detector fix for https://github.com/Azure/azure-sdk-for-python/issues/33295
"test_detector,azure_app_service"
)

@patch(
Expand Down