! yWu d d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z e rd dl mZ dZdZ d e Zd e ZdZd e Z G d d Z G d d Z G d de Zej ej ej ej iZdS ) N)Integration)set_context)logger) TYPE_CHECKING)Dictcloud_resourcez169.254.169.254zhttp://{}/latest/api/tokenz3http://{}/latest/dynamic/instance-identity/documentzmetadata.google.internalz,http://{}/computeMetadata/v1/?recursive=truec * e Zd ZdZdZdZdZdZdZdZ dS ) CLOUD_PROVIDERz Name of the cloud provider. see https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/cloud/ alibaba_cloudawsazuregcp ibm_cloud tencent_cloudN) __name__ __module____qualname____doc__ALIBABAAWSAZUREGCPIBMTENCENT /builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/sentry_sdk/integrations/cloud_resource_context.pyr r s8 G CE C CGGGr r c e Zd ZdZdZdZdS )CLOUD_PLATFORMz The cloud platform. see https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/cloud/ aws_ec2gcp_compute_engineN)r r r r AWS_EC2GCP_COMPUTE_ENGINEr r r r r * s' G-r r c e Zd ZdZdZdZdZ ej Z dZ d dZed Z ed Zed Zed Zed Zed Zed ZdS )CloudResourceContextIntegrationz8 Adds cloud resource context to the Senty scope cloudresourcecontext Nc |t _ d S )N)r% cloud_provider)selfr) s r __init__z(CloudResourceContextIntegration.__init__B s 9G'666r c | j dt ddi }|j dk rdS |j | _ dS # t $ r Y dS w xY w)NPUTz$X-aws-ec2-metadata-token-ttl-seconds60headers FT)httprequest AWS_TOKEN_URLstatusdatadecode aws_token Exceptionclsrs r _is_awsz'CloudResourceContextIntegration._is_awsF s{ ?F ! A x3uFMMOOCM4 55 s /A A A! A!c B t j t j d} | j dt d| j i }|j dk r|S t j |j d } |d |d<