o
    i                     @   s   d dl mZ d dlZ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 d dlmZ d	Zd
edefddZdd Zdee fddZG dd deZe ZdS )    )PathN)config)gitmetadata)DEFAULT_SERVICE_NAME)DDConfig)get_application_name)__version__g      Y@creturnc                 C   s@   t tjtjtd}|tj t| d	dd |
 D S )N)envversiondebugger_version,c                 S   s&   g | ]\}}|d urd ||fqS )N:)join).0kv r   e/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/internal/settings/dynamic_instrumentation.py
<listcomp>   s   & z _derive_tags.<locals>.<listcomp>)dictddconfigr   r   r   updatetagsr   add_tagsr   items)r	   _tagsr   r   r   _derive_tags   s   
r   c                 C   s   |    ddS )N_ )striplowerreplace)identr   r   r   normalize_ident   s   r%   typesc                 C   sX   | D ]'}|  dD ]}|  dd}| s(|dv s(td| d| dqqd S )N.*a>   <locals>zInvalid redaction type pattern z: z is not a valid identifier)r!   splitr#   isidentifier
ValueError)r&   typsr   r   r   validate_type_patterns   s   r0   c                	   @   sR  e Zd ZdZeedd Zeedd Zee	dd Z
eedd ZeeeZejeddd	d
dZejeddd	ddZejedddddZejedddddZeje	dddddZejedddddZejedee ddd Zejed!eje edd"d#Zeejej  d$d Z!ejed%ee dd&d Z"ejeje# d'd(d)d*dZ$d(S )+DynamicInstrumentationConfigzdd.dynamic_instrumentationc                 C   s   t jpt ptS N)r   servicer   r   r   r   r   r   <lambda>0   s    z%DynamicInstrumentationConfig.<lambda>c                 C   s   t jS r2   )agent_configtrace_agent_urlr4   r   r   r   r5   1   s    c                 C   s   t S r2   )DEFAULT_GLOBAL_RATE_LIMITr4   r   r   r   r5   2       c                 C   s   dS )NTr   r4   r   r   r   r5   3   r9   enabledFBooleanzEnable Dynamic Instrumentation)default	help_typehelpzmetrics.enabledTz1Enable Dynamic Instrumentation diagnostic metricsmax_payload_sizei   IntegerzWMaximum size in bytes of a single configuration payload that can be handled per requestzupload.timeout   zATimeout in seconds for uploading Dynamic Instrumentation payloadszupload.interval_secondsg      ?Floatz>Interval in seconds for flushing the dynamic logs upload queuezdiagnostics.intervali  zGInterval in seconds for periodically emitting probe diagnostic messagesredacted_identifiersListzYList of identifiers/object attributes/dict keys to redact from dynamic logs and snapshots)mapr<   r=   r>   redacted_typesz>List of object types to redact from dynamic logs and snapshots)rE   r<   	validatorr=   r>   c                 C   s.   | j rtdddd | j D  dS d S )Nz^(?:|c                 s   s$    | ]}| d d ddV  qdS )r'   z[.]r(   z.*N)r#   )r   r   r   r   r   	<genexpr>{   s   " z8DynamicInstrumentationConfig.<lambda>.<locals>.<genexpr>z)$)rF   recompiler   )r	   r   r   r   r5   {   s   &redaction_excluded_identifiersz-List of identifiers to exclude from redaction
probe_fileNr   z+Path to a file containing probe definitions)%__name__
__module____qualname__
__prefix__r   dstrservice_name_intake_urlfloatglobal_rate_limitbool_tags_in_qsr   r   r   r:   metricsintr?   upload_timeoutupload_interval_secondsdiagnostics_intervalsetr%   rC   r!   r0   rF   tOptionalrJ   Patternredacted_types_rerL   r   rM   r   r   r   r   r1   -   s    	

	
r1   )pathlibr   rJ   typingr`   ddtracer   r   ddtrace.internalr   ddtrace.internal.constantsr    ddtrace.internal.settings._agentr6   ddtrace.internal.settings._corer   ddtrace.internal.utils.configr   ddtrace.versionr   r8   rS   r   r%   r_   r0   r1   r   r   r   r   <module>   s     

e