Skip to main content

OpenTelemetry Resource detectors for Azure

pypi

This library contains OpenTelemetry Resource Detectors for the following Azure resources:

Installation

pip install opentelemetry-resource-detector-azure

Usage example for opentelemetry-resource-detector-azure

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.resource.detector.azure import (
    AzureAKSResourceDetector,
    AzureAppServiceResourceDetector,
    AzureVMResourceDetector,
)
from opentelemetry.sdk.resources import get_aggregated_resources


trace.set_tracer_provider(
    TracerProvider(
        resource=get_aggregated_resources(
            [
                AzureAKSResourceDetector(),
                AzureAppServiceResourceDetector(),
                AzureVMResourceDetector(),
            ]
        ),
    )
)

Mappings

The Azure Kubernetes Service Resource Detector reads the cluster resource ID from the CLUSTER_RESOURCE_ID environment variable or from a mounted aks-cluster-metadata ConfigMap at /etc/kubernetes/aks-cluster-metadata. It sets the following Resource Attributes:

  • cloud.platform set to azure.aks.

  • cloud.provider set to azure.

  • cloud.resource_id set to the full Azure Resource Manager cluster resource ID.

The native AKS ConfigMap is named aks-cluster-metadata and contains a clusterResourceId key. It can be exposed to a pod as an environment variable:

env:
  - name: CLUSTER_RESOURCE_ID
    valueFrom:
      configMapKeyRef:
        name: aks-cluster-metadata
        key: clusterResourceId

Alternatively, mount the ConfigMap as a volume:

volumes:
  - name: aks-cluster-metadata
    configMap:
      name: aks-cluster-metadata
volumeMounts:
  - name: aks-cluster-metadata
    mountPath: /etc/kubernetes/aks-cluster-metadata

Kubernetes resolves ConfigMap references within the pod’s namespace. Because the native ConfigMap is in kube-public, copy it into the workload namespace or use tooling such as an init container to expose its value through one of the supported locations.

The Azure App Service Resource Detector sets the following Resource Attributes:
  • service.name set to the value of the WEBSITE_SITE_NAME environment variable.

  • cloud.platform set to azure_app_service.

  • cloud.provider set to azure.

  • cloud.resource_id set using the WEBSITE_RESOURCE_GROUP, WEBSITE_OWNER_NAME, and WEBSITE_SITE_NAME environment variables.

  • cloud.region set to the value of the REGION_NAME environment variable.

  • deployment.environment set to the value of the WEBSITE_SLOT_NAME environment variable.

  • host.id set to the value of the WEBSITE_HOSTNAME environment variable.

  • service.instance.id set to the value of the WEBSITE_INSTANCE_ID environment variable.

  • azure.app.service.stamp set to the value of the WEBSITE_HOME_STAMPNAME environment variable.

The Azure VM Resource Detector sets the following Resource Attributes according to the response from the Azure Metadata Service:
  • azure.vm.scaleset.name set to the value of the vmScaleSetName field.

  • azure.vm.sku set to the value of the sku field.

  • cloud.platform set to the value of the azure_vm.

  • cloud.provider set to the value of the azure.

  • cloud.region set to the value of the location field.

  • cloud.resource_id set to the value of the resourceId field.

  • host.id set to the value of the vmId field.

  • host.name set to the value of the name field.

  • host.type set to the value of the vmSize field.

  • os.type set to the value of the osType field.

  • os.version set to the value of the version field.

  • service.instance.id set to the value of the vmId field.

The Azure Functions Resource Detector is currently experimental. It sets the following Resource Attributes:
  • service.name set to the value of the WEBSITE_SITE_NAME environment variable.

  • process.id set to the process ID collected from the running process.

  • cloud.platform set to azure_functions.

  • cloud.provider set to azure.

  • cloud.resource_id set using the WEBSITE_RESOURCE_GROUP, WEBSITE_OWNER_NAME, and WEBSITE_SITE_NAME environment variables.

  • cloud.region set to the value of the REGION_NAME environment variable.

  • faas.instance set to the value of the WEBSITE_INSTANCE_ID environment variable.

  • faas.max_memory set to the value of the WEBSITE_MEMORY_LIMIT_MB environment variable.

For more information, see the Semantic Conventions for Cloud Resource Attributes.

References

Metadata

Release files for opentelemetry-resource-detector-azure 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-resource-detector-azure 0.3.0
File Size Uploaded
opentelemetry_resource_detector_azure-0.3.0.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-resource-detector-azure 0.3.0
File Interpreter ABI Platform
opentelemetry_resource_detector_azure-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / opentelemetry_resource_detector_azure-0.3.0.tar.gz

Download URL opentelemetry_resource_detector_azure-0.3.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dc191af39d9e798b1bbb05a5620876c7599da961972a1f18ca7e8f7382ead519
BLAKE2b-256 checksum
How to use checksums
2a30ae8e6630506e3c66aa73c865dedee4b6e305f08751e99388b474a0879d06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / opentelemetry_resource_detector_azure-0.3.0-py3-none-any.whl

Download URL opentelemetry_resource_detector_azure-0.3.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6096d6a31a5371928b4fb399f9e6f3d06eb48fdbb7d07f44b15b19cdf3bab5cc
BLAKE2b-256 checksum
How to use checksums
ba7d7a1d0215ba5fc642da9f7b666be204bc6f222c6d55d3f4a3807b5c62e82a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page