Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 2 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Release History

## 1.1.1 (2023-11-30)
## 1.1.1 (2023-12-04)

### Features Added

- 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.
- Default Resource Detector environment variable to enable configuration.
([#33305](https://github.com/Azure/azure-sdk-for-python/pull/33305))
([#33373](https://github.com/Azure/azure-sdk-for-python/pull/33373))
([#33390](https://github.com/Azure/azure-sdk-for-python/pull/33390))

## 1.1.0 (2023-11-08)

Expand Down
1 change: 1 addition & 0 deletions sdk/monitor/azure-monitor-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ 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` | An experimental OpenTelemetry environment varialbe used to specify 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. To add or remove specific resource detectors, set the environment variable accordingly. See the [OpenTelemetry Python Resource Detector Documentation][ot_python_resource_detectors] for more. |
Comment thread
jeremydvoss marked this conversation as resolved.
Outdated

#### Azure monitor OpenTelemetry Exporter configurations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
_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 @@ -53,7 +54,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 @@ -103,11 +104,10 @@ def configure_azure_monitor(**kwargs) -> None:
_setup_instrumentations(configurations)

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


def _setup_tracing(configurations: Dict[str, ConfigurationValue]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,31 @@ def test_setup_resources(self):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
# 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"
"azure_app_service,azure_vm"
)

@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"],
# 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):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
# 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"
"test_detector"
)

@patch.dict("os.environ", {"OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "azure_vm,test_detector, azure_app_service"})
def test_setup_resources_azure_and_existing_detectors(self):
_setup_resources()
self.assertEqual(
os.environ["OTEL_EXPERIMENTAL_RESOURCE_DETECTORS"],
"azure_vm,test_detector, azure_app_service"
)

@patch(
Expand Down