
    uYfD                     j    d dl Z d dlmZ d dlmZ ddlmZ ddlmZ ddlm	Z	 dd	l
mZ  G d
 de      Zy)    N)Optional)Tuple   )Hooks)AttrDict)asbool   )
HttpConfigc                   n     e Zd ZdZ fdZd Zd Zed        Zed        Z	d Z
d Zd	 Zdd
Zd Z xZS )IntegrationConfiga}  
    Integration specific configuration object.

    This is what you will get when you do::

        from ddtrace import config

        # This is an `IntegrationConfig`
        config.flask

        # `IntegrationConfig` supports both attribute and item accessors
        config.flask['service_name'] = 'my-service-name'
        config.flask.service_name = 'my-service-name'
    c                    t        t        | 
  |i | t        j	                  | d|       t        j	                  | d|       t        j	                  | dt                      t        j	                  | dt                      | j                         \  }}| j                  d|       | j                  dt        |             t        j                  d|j                         z  t        j                  d|j                         z  d	
      
      }| j                  d|       | j                  d|       t        j	                  | d| j                  t        | dd	                   y	)zw
        :param global_config:
        :type global_config: Config
        :param args:
        :param kwargs:
        global_configintegration_namehookshttpanalytics_enabledanalytics_sample_ratezDD_%s_SERVICEzDD_%s_SERVICE_NAMENdefaultserviceservice_namehttp_tag_query_stringdefault_http_tag_query_string)superr   __init__object__setattr__r   r
   _get_analytics_settings
setdefaultfloatosgetenvupperget_http_tag_query_stringgetattr)	selfr   nameargskwargsr   r   r   	__class__s	           \/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/ddtrace/settings/integration.pyr   zIntegrationConfig.__init__   s)    	/@@ 	4-@4!3T:4%'246373O3O3Q00+->?/7L1MN))djjl*II$tzz|3
 		7+ 	0#**749XZ^+_`	
    c           
         t        j                  d| j                  j                         z  t        j                  d| j                  j                         z              }|t	        |      nd }t        t        j                  d| j                  j                         z  t        j                  d| j                  j                         z  d                  }||fS )NzDD_TRACE_%s_ANALYTICS_ENABLEDzDD_%s_ANALYTICS_ENABLEDz!DD_TRACE_%s_ANALYTICS_SAMPLE_RATEzDD_%s_ANALYTICS_SAMPLE_RATEg      ?r   )r!   r"   r   r#   r   r    )r&   _r   r   s       r+   r   z)IntegrationConfig._get_analytics_settingsA   s    
 II+d.C.C.I.I.KKII/$2G2G2M2M2OOP
 *+F1ID %II3d6K6K6Q6Q6SS		7$:O:O:U:U:WWade!
 !"777r,   c                     | j                   j                  r,|r|nt        j                  dd      }|j	                         dvS y)NDD_HTTP_SERVER_TAG_QUERY_STRINGtrue)false0F)r   r   r!   r"   lower)r&   valuedd_http_server_tag_query_strings      r+   r$   z+IntegrationConfig.get_http_tag_query_stringU   s?    337<e"))LmouBv+288:.PPr,   c                     | j                   j                  | j                   j                  S | j                  j                   j                  S N)r   trace_query_stringr   r&   s    r+   r9   z$IntegrationConfig.trace_query_string\   s:    99''399///!!&&999r,   c                 r    | j                   j                  xs  | j                  j                   j                  S )zReturns whether header tracing is enabled for this integration.

        Will return true if traced headers are configured for this integration
        or if they are configured globally.
        )r   is_header_tracing_configuredr   r:   s    r+   r<   z.IntegrationConfig.is_header_tracing_configuredb   s+     yy55m9K9K9P9P9m9mmr,   c                 (    | j                  |      duS )z
        Returns whether or not the current header should be traced.
        :param header_name: the header name
        :type header_name: str
        :rtype: bool
        N)_header_tag_name)r&   header_names     r+   header_is_tracedz"IntegrationConfig.header_is_tracedl   s     $$[1==r,   c                 v    | j                   j                  |      }|| j                  j                  |      S |S r8   )r   r>   r   )r&   r?   tag_names      r+   r>   z"IntegrationConfig._header_tag_namev   s8    99--k:%%66{CCr,   c                 j    |r$| j                   j                  r| j                  duS | j                  du S )NFT)r   r   )r&   use_global_configs     r+   _is_analytics_enabledz'IntegrationConfig._is_analytics_enabled}   s7     !3!3!E!E))66))T11r,   c                 J    | j                  |      rt        | dd      }|y|S y)z
        Returns analytics sample rate but only when integration-specific
        analytics configuration is enabled with optional override with global
        configuration
        r   NT)rE   r%   )r&   rD   r   s      r+   get_analytics_sample_ratez+IntegrationConfig.get_analytics_sample_rate   s7     %%&78$+D2I4$P!$,(( r,   c                     | j                   }dj                  | j                               }dj                  |j                  |j
                  |      S )Nz, z	{}.{}({}))r*   joinkeysformat
__module____name__)r&   clsrJ   s      r+   __repr__zIntegrationConfig.__repr__   s<    nnyy%!!#..#,,EEr,   )F)rM   rL   __qualname____doc__r   r   r$   propertyr9   r<   r@   r>   rE   rG   rO   __classcell__)r*   s   @r+   r   r      s\    $
L8( : :
 n n>2$Fr,   r   )r!   typingr   r   _hooksr   internal.utils.attrdictr   internal.utils.formatsr   r   r
   r    r,   r+   <module>rY      s*    	    . + OF OFr,   