
    	]j                     Z    d Z ddlmZ ddlmZ dZdZdZeZdZ	dZ
dZd	 Zeefd
ZeefdZy)z9Add diagnostic instrumentation source information to logs    )__version__)StructEntryz!logging.googleapis.com/diagnosticinstrumentation_sourcepython      c                 \    t        di |}| j                  d|j                                | S )a  Add instrumentation information to a list of entries

        A new diagnostic entry is prepended to the list of
        entries.

    Args:
       entries (Sequence[Mapping[str, ...]]): sequence of mappings representing
            the log entry resources to log.

    Returns:
        Sequence[Mapping[str, ...]]: entries with instrumentation info added to
        the beginning of list.
    r    )_create_diagnostic_entryinsertto_api_repr)entrieskwdiagnostic_entrys      R/root/env/lib/python3.12/site-packages/google/cloud/logging_v2/_instrumentation.py_add_instrumentationr      s/     05"5NN1&2245N    c                     t         t        t        | |      gii}d}|j                         D ci c]  \  }}||v s|| }}}t	        dd|i|}|S c c}}w )aX  Create a diagnostic log entry describing this library

        The diagnostic log consists of a list of library name and version objects
        that have handled a given log entry.  If this library is the originator
        of the log entry, it will look like:
        {logging.googleapis.com/diagnostic: {instrumentation_source: [{name: "python", version: "3.0.0"}]}}

    Args:
        name(str): The name of this library (e.g. 'python')
        version(str) The version of this library (e.g. '3.0.0')

    Returns:
        google.cloud.logging_v2.LogEntry: Log entry with library information
    )log_nameresourcepayloadr
   )_DIAGNOSTIC_INFO_KEY_INSTRUMENTATION_SOURCE_KEY_get_instrumentation_sourceitemsr   )	nameversionr   r   
allow_listkv
active_kwsentrys	            r   r   r   3   sn      	'*EdG*T)U
G *J#%88:A41aj!Q$AJA66:6EL Bs
   AAc                     | |d}|j                         D ](  \  }}t        |      t        k  r|n|dt          d||<   * |S )a  Gets a JSON representation of the instrumentation_source

    Args:
        name(str): The name of this library (e.g. 'python')
        version(str) The version of this library (e.g. '3.0.0')
    Returns:
       obj: JSON object with library information
    )r   r   N*)r   len_MAX_NAME_LENGTH)r   r   sourcekeyvals        r   r   r   N   sY     w/FLLN 
Ss8//C<M=M8N7Oq5Q 	s
 Mr   N)__doc__google.cloud.logging_v2r   google.cloud.logging_v2.entriesr   r   r   _PYTHON_LIBRARY_NAME_LIBRARY_VERSIONr&   _MAX_VERSION_LENGTH_MAX_INSTRUMENTATION_ENTRIESr   r   r   r
   r   r   <module>r1      sZ    @ / 7: 6       ( #7@P 6 &:CS r   