Ë
    tPêjI  ã                   ó„   — d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ erddlmZ neZ G d„ d	e«      Z G d
„ d«      Zy)z¡
DataDog Team Handler

Used to get the DataDogLogger for a given request.
Handles Key/Team Based Datadog Logging, following the same pattern as LangFuseHandler.
é    )ÚTYPE_CHECKINGÚAnyÚFinalÚ	TypedDict)Úverbose_logger)ÚStandardCallbackDynamicParamsé   )ÚDataDogLogger)ÚDynamicLoggingCachec                   óN   — e Zd ZU edz  ed<   edz  ed<   edz  ed<   edz  ed<   y)ÚDatadogLoggingConfigNÚ
dd_api_keyÚdd_siteÚdd_agent_hostÚdd_agent_port)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__© ó    úv/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/integrations/datadog/datadog_team_handler.pyr   r      s*   … Ø�d‘
ÓØ�4‰ZÓØ˜‘:ÓØ˜‘:Ôr   r   c                   ó|   — e Zd Zedededefd„«       Zedededefd„«       Z	edede
fd„«       Zededefd„«       Zy	)
ÚDataDogHandlerÚ standard_callback_dynamic_paramsÚin_memory_dynamic_logger_cacheÚreturnc                 ó    — t         j                  | ¬«      }t        |«      }|j                  |d¬«      }|€t         j	                  ||¬«      }|S )a  
        Get a team-scoped DataDogLogger for a given request.

        Resolves and caches per-team DataDogLogger instances using DynamicLoggingCache,
        keyed by the team's DD credentials. Each unique set of credentials gets its own
        logger instance with its own batch/flush loop.

        Note: This handler is only called when team-scoped DD credentials are present.
        The global (env-var based) DataDogLogger is managed separately by
        _init_custom_logger_compatible_class via _in_memory_loggers.
        ©r   Údatadog)ÚcredentialsÚservice_name)r"   r   )r   Ú"get_dynamic_datadog_logging_configÚdictÚ	get_cacheÚ'_create_datadog_logger_from_credentials)r   r   Ú_credentialsÚcredentials_dictÚtemp_datadog_loggers        r   Úget_datadog_logger_for_requestz-DataDogHandler.get_datadog_logger_for_request   su   € ô  -×OÑOØ-Mð Pó 
ˆô #' |Ó"4Ðð =×FÑFØ(°yð Gó 
Ðð
 Ð&Ü"0×"XÑ"XØ,Ø/Mð #Yó #Ðð
 #Ð"r   r"   c                 ó@  — | j                  d«      du xr | j                  d«      du }t        | j                  d«      | j                  d«      | j                  d«      | j                  d«      |¬«      }|j                  | d|¬«       t        j                  d	«       |S )
zK
        Create a DataDogLogger from the credentials and cache it.
        r   Nr   r   r   )r   r   r   r   Úallow_env_credentialsr!   )r"   r#   Úlogging_objzIDatadog: Created and cached new DataDogLogger for team-scoped credentials)Úgetr
   Ú	set_cacher   Údebug)r"   r   r-   Údatadog_loggers       r   r'   z6DataDogHandler._create_datadog_logger_from_credentials@   s¢   € ð (3§¡°Ó'GÈ4Ð'OÒ'vÐT_×TcÑTcÐdmÓTnÐrvÐTvÐÜ -Ø"—‘ |Ó4Ø—O‘O IÓ.Ø%Ÿ/™/¨/Ó:Ø%Ÿ/™/¨/Ó:Ø"7ô!
ˆð 	'×0Ñ0Ø#Ø"Ø&ð 	1ô 	
ô
 	×ÑÐhÔiØÐr   c                 ó˜   — t        | j                  d«      | j                  d«      | j                  d«      | j                  d«      ¬«      S )zY
        Get the Datadog logging config for a given request from dynamic params.
        r   r   r   r   )r   r   r   r   )r   r/   r    s    r   r$   z1DataDogHandler.get_dynamic_datadog_logging_configZ   sI   € ô $Ø7×;Ñ;¸LÓIØ4×8Ñ8¸ÓCØ:×>Ñ>¸ÓOØ:×>Ñ>¸ÓOô	
ð 	
r   c                 ól   — | j                  d«      €"| j                  d«      €| j                  d«      �yy)zf
        Check if dynamic Datadog credentials are passed in standard_callback_dynamic_params.
        r   r   r   TF)r/   r    s    r   Ú'_dynamic_datadog_credentials_are_passedz6DataDogHandler._dynamic_datadog_credentials_are_passedh   s=   € ð -×0Ñ0°Ó>ÐJØ/×3Ñ3°IÓ>ÐJØ/×3Ñ3°OÓDÐPàØr   N)r   r   r   Ústaticmethodr   r   r
   r+   r%   r'   r   r$   Úboolr5   r   r   r   r   r      s¥   „ Øð #Ø*Gð #à(;ð #ð 
ò #ó ð #ðD ðØðà(;ðð 
òó ðð2 ð
Ø*Gð
à	ò
ó ð
ð ðØ*Gðà	òó ñr   r   N)Ú__doc__Útypingr   r   r   r   Úlitellm._loggingr   Ú*litellm.litellm_core_utils.litellm_loggingr   r!   r
   r   r   r   r   r   r   ú<module>r<      s?   ðñ÷ 8Ó 7å +Ý Tå "áÞNàÐô˜9ô ÷Yò Yr   