HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/mysql/opentelemetry/sdk/resources/__pycache__/__init__.cpython-39.pyc
a

�,�h�7�@s�dZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZmZmZddlmZdd	lmZmZdd
lmZeZejeefZe�e�Z ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&ej'Z'ej(Z(ej)Z)ej*Z*ej+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z2ej3Z4ej5Z6ej7Z8ej9Z:ej;Z<ej=Z>ej?Z@ejAZBejCZDejEZFejGZHejIZJejKZLejMZNejOZPejQZRejSZTejUZUejVZVejWZWejXZXejYZYejZZZej[Z[ej\Z\ej]Z]ej^Z^ej_Z_ej`Z`ejaZaejbZbejcZcejdZdejeZeejfZfejgZgejhZhed�ZiGdd
�d
�Zjeji�Zkejehdeedefeii�ZlGdd�dejm�ZnGdd�den�ZoGdd�den�Zpdejqdejrejd
d�dd�ZsdS)a�
This package implements `OpenTelemetry Resources
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-sdk>`_:

    *A Resource is an immutable representation of the entity producing
    telemetry. For example, a process producing telemetry that is running in
    a container on Kubernetes has a Pod name, it is in a namespace and
    possibly is part of a Deployment which also has a name. All three of
    these attributes can be included in the Resource.*

Resource objects are created with `Resource.create`, which accepts attributes
(key-values). Resources should NOT be created via constructor, and working with
`Resource` objects should only be done via the Resource API methods. Resource
attributes can also be passed at process invocation in the
:envvar:`OTEL_RESOURCE_ATTRIBUTES` environment variable. You should register
your resource with the  `mysql.opentelemetry.sdk.trace.TracerProvider` by passing
them into their constructors. The `Resource` passed to a provider is available
to the exporter, which can send on this information as it sees fit.

.. code-block:: python

    trace.set_tracer_provider(
        TracerProvider(
            resource=Resource.create({
                "service.name": "shoppingcart",
                "service.instance.id": "instance-12",
            }),
        ),
    )
    print(trace.get_tracer_provider().resource.attributes)

    {'telemetry.sdk.language': 'python',
    'telemetry.sdk.name': 'opentelemetry',
    'telemetry.sdk.version': '0.13.dev0',
    'service.name': 'shoppingcart',
    'service.instance.id': 'instance-12'}

Note that the OpenTelemetry project documents certain `"standard attributes"
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md>`_
that have prescribed semantic meanings, for example ``service.name`` in the
above example.
 �N)�dumps)�environ)�parse)�BoundedAttributes)�$OTEL_EXPERIMENTAL_RESOURCE_DETECTORS�OTEL_RESOURCE_ATTRIBUTES�OTEL_SERVICE_NAME)�ResourceAttributes)�entry_points�version)�AttributeValuezopentelemetry-sdkc@s�eZdZdZdeejed�dd�Ze	dejeejedd�dd��Z
e	dd	�d
d��Zeed	�dd
��Z
eed	�dd��Zddd�dd�Zeed�dd�Zdd�Zded	�dd�ZdS)�ResourcezZA Resource is an immutable representation of the entity producing telemetry as Attributes.N��
attributes�
schema_urlcCs"t|d�|_|durd}||_dS)N)r�)r�_attributes�_schema_url)�selfrr�r�]/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/opentelemetry/sdk/resources/__init__.py�__init__�szResource.__init__)rr�returnc	Cs�|si}g}t}t�td��d�}d|vr4|�d�|D](}|�tttd|�	�d����
���q8t|t��t
||��}|j�td�s�d}|j�td�}|r�|d|7}|�t
t|i|��}|S)z�Creates a new `Resource` from attributes.

        Args:
            attributes: Optional zero or more key-value pairs.
            schema_url: Optional URL pointing to the schema

        Returns:
            The newly-created Resource.
        Zotel�,Zopentelemetry_resource_detector)�group�nameNZunknown_service�:)�_DEFAULT_RESOURCEr�getr�split�append�next�iterr
�strip�load�get_aggregated_resources�merger
r�SERVICE_NAME�PROCESS_EXECUTABLE_NAME)rrZresource_detectors�resourceZ$otel_experimental_resource_detectorsZresource_detectorZdefault_service_nameZprocess_executable_namerrr�create�sL��
��������zResource.create�rcCstS�N)�_EMPTY_RESOURCErrrr�	get_empty�szResource.get_emptycCs|jSr,)r�rrrrr�szResource.attributescCs|jSr,)rr/rrrr�szResource.schema_url)�otherrcCsn|j��}|�|j�|jdkr(|j}n<|jdkr:|j}n*|j|jkrN|j}nt�d|j|j�|St||�S)a^Merges this resource and an updating resource into a new `Resource`.

        If a key exists on both the old and updating resource, the value of the
        updating resource will override the old resource value.

        The updating resource's `schema_url` will be used only if the old
        `schema_url` is empty. Attempting to merge two resources with
        different, non-empty values for `schema_url` will result in an error
        and return the old resource.

        Args:
            other: The other resource to be merged.

        Returns:
            The newly-created Resource.
        rzEFailed to merge resources: The two schemas %s and %s are incompatible)r�copy�updater�logger�errorr
)rr0Zmerged_attributesrrrrr&�s


�zResource.mergecCs&t|t�sdS|j|jko$|j|jkS)NF)�
isinstancer
rr)rr0rrr�__eq__s


�zResource.__eq__cCs"tt|j��dd��d|j���S)NT)�	sort_keys�|)�hashrrr1rr/rrr�__hash__	s�zResource.__hash__�cCstt|j�|jd�|d�S)Nr)�indent)r�dictrr)rr<rrr�to_jsons��zResource.to_json)N)NN)r;)�__name__�
__module__�__qualname__�__doc__�
Attributes�typing�Optional�strr�staticmethodr*r.�propertyrrr&�object�boolr6r:r>rrrrr
�s(��8$r
�pythonZ
opentelemetryc@s*eZdZd	dd�Zejdd�dd��ZdS)
�ResourceDetectorFcCs
||_dSr,)�raise_on_error)rrMrrrr#szResourceDetector.__init__r
r+cCs
t��dSr,)�NotImplementedErrorr/rrr�detect&szResourceDetector.detectN)F)r?r@rAr�abc�abstractmethodrOrrrrrL"s
rLc@seZdZdd�dd�ZdS)�OTELResourceDetectorr
r+c	Cs�t�t�}i}|r�|�d�D]t}z|jddd�\}}Wn>tyt}z&t�d||�WYd}~qWYd}~n
d}~00t�|�	��}|||�	�<qt�t
�}|r�||t<t|�S)Nr�=�)�maxsplitz0Invalid key value resource attribute pair %s: %s)
rrrr�
ValueErrorr3�warningr�unquoter#rr'r
)	rZenv_resources_itemsZenv_resource_map�item�key�value�excZvalue_url_decodedZservice_namerrrrO-s&
�"
zOTELResourceDetector.detectN�r?r@rArOrrrrrR+srRc@seZdZdd�dd�ZdS)�ProcessResourceDetectorr
r+cCsNd�tttjjdkr*tjjs*tjdd�ntj��}tttj	t
tjjt
|i�S)N�.�final�)�join�maprF�sys�version_info�releaselevel�serialr
�PROCESS_RUNTIME_DESCRIPTIONr�PROCESS_RUNTIME_NAME�implementationr�PROCESS_RUNTIME_VERSION)rZ_runtime_versionrrrrOGs 
����
��zProcessResourceDetector.detectNr]rrrrr^Esr^�)�	detectors�initial_resourcerc
s�|p
t��}tjjdd�����fdd�|D�}t|�D]~\}}||}z`z|j|d�}Wn@ty�}	z(t}|j	rv|	�t
�d|	|�WYd}	~	n
d}	~	00W|�|�}q6|�|�}0q6Wd�n1s�0Y|S)a'Retrieves resources from detectors in the order that they were passed

    :param detectors: List of resources in order of priority
    :param initial_resource: Static resource. This has highest priority
    :param timeout: Number of seconds to wait for each detector to return
    :return:
    r;)�max_workerscsg|]}��|j��qSr)�submitrO)�.0�detector��executorrr�
<listcomp>j�z,get_aggregated_resources.<locals>.<listcomp>)�timeoutz%Exception %s in detector %s, ignoringN)
r
r*�
concurrent�futures�ThreadPoolExecutor�	enumerate�result�	Exceptionr-rMr3rWr&)
rmrnrwZdetectors_merged_resourceryZdetector_ind�futurerrZdetected_resource�exrrsrr%[s$&�
�&r%)Nrl)trBrP�concurrent.futuresrx�loggingrdrD�jsonr�osr�urllibrZmysql.opentelemetry.attributesrZ-mysql.opentelemetry.sdk.environment_variablesrrrZ$mysql.opentelemetry.semconv.resourcer	Z,mysql.opentelemetry.util._importlib_metadatar
rZmysql.opentelemetry.util.typesrZ
LabelValue�DictrFrC�	getLoggerr?r3ZCLOUD_PROVIDERZCLOUD_ACCOUNT_IDZCLOUD_REGIONZCLOUD_AVAILABILITY_ZONEZCONTAINER_NAMEZCONTAINER_IDZCONTAINER_IMAGE_NAMEZCONTAINER_IMAGE_TAGZDEPLOYMENT_ENVIRONMENTZ	FAAS_NAMEZFAAS_IDZFAAS_VERSIONZ
FAAS_INSTANCEZ	HOST_NAMEZ	HOST_TYPEZHOST_IMAGE_NAMEZ
HOST_IMAGE_IDZHOST_IMAGE_VERSIONZK8S_CLUSTER_NAMEZKUBERNETES_CLUSTER_NAMEZK8S_NAMESPACE_NAMEZKUBERNETES_NAMESPACE_NAMEZK8S_POD_UIDZKUBERNETES_POD_UIDZK8S_POD_NAMEZKUBERNETES_POD_NAMEZK8S_CONTAINER_NAMEZKUBERNETES_CONTAINER_NAMEZK8S_REPLICASET_UIDZKUBERNETES_REPLICA_SET_UIDZK8S_REPLICASET_NAMEZKUBERNETES_REPLICA_SET_NAMEZK8S_DEPLOYMENT_UIDZKUBERNETES_DEPLOYMENT_UIDZK8S_DEPLOYMENT_NAMEZKUBERNETES_DEPLOYMENT_NAMEZK8S_STATEFULSET_UIDZKUBERNETES_STATEFUL_SET_UIDZK8S_STATEFULSET_NAMEZKUBERNETES_STATEFUL_SET_NAMEZK8S_DAEMONSET_UIDZKUBERNETES_DAEMON_SET_UIDZK8S_DAEMONSET_NAMEZKUBERNETES_DAEMON_SET_NAMEZK8S_JOB_UIDZKUBERNETES_JOB_UIDZK8S_JOB_NAMEZKUBERNETES_JOB_NAMEZK8S_CRONJOB_UIDZKUBERNETES_CRON_JOB_UIDZK8S_CRONJOB_NAMEZKUBERNETES_CRON_JOB_NAMEZOS_TYPEZOS_DESCRIPTIONZPROCESS_PIDr(ZPROCESS_EXECUTABLE_PATHZPROCESS_COMMANDZPROCESS_COMMAND_LINEZPROCESS_COMMAND_ARGSZ
PROCESS_OWNERrirkrhr'ZSERVICE_NAMESPACEZSERVICE_INSTANCE_IDZSERVICE_VERSIONZTELEMETRY_SDK_NAMEZTELEMETRY_SDK_VERSIONZTELEMETRY_AUTO_VERSIONZTELEMETRY_SDK_LANGUAGEZ_OPENTELEMETRY_SDK_VERSIONr
r-r�ABCrLrRr^�ListrEr%rrrr�<module>s�+

��		��