ó
    Ð]j®÷ ã                  óB  • S SK Jr  S SKrS SKJs  Jr  S SKrS SK	r	S SK
r
S SKrS SKrS SKJrJrJr  S SKJr  S SKJr  S SKJr  S SKJrJr  S SKJr  S S	KJrJrJrJrJrJ r J!r!J"r"J#r#  S SK$J%r&  S SK'J(r)  S S
K$J*r*  S SK+J,r,J-r-J.r.J/r/  S SK0J1r1J2r2  S SK'J3r3J4r4  S SK5J6r7  S SK8J9r9J:r:  SSK;J<r<  SSK=J>r>  SSK?J@r@JArA  SSKBJCrCJDrD  SSKEJFrF  SSKGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrS  SSKTJUrUJVrV  SSKWJWrW  SSKXJYrY  SSKZJ[r[J\r\J]r]J^r^  SSK_J`r`  SSKaJbrb  SSKcJdrdJereJfrfJgrg  SSKhJiriJjrjJkrkJlrl  \(       Ga  S S K6Jmrm  S S!KnJoro  S SKprpS SKqrqS SKrrrS SKsrtS SKuruS S"KvJwrwJxrx  S S#KyJzrz  S S$K{J|r|  S S%K}J~r~JrJ€r€  S S&K+J�r‚  S S'KƒJ„r„  S S(K…J†r†J‡r‡Jˆrˆ  S S)K‰JŠrŠ  S S*K‹JŒrŒ  S S+K�JŽrŽ  S S,K�J�r�  S S-K‘J’r’  S S.K“J”r”  S S/K•J–r–  S S0K8J—r—  SS1K˜J™ršJ›rœ  SS2K�JžrŸJ™r J›r¡  SS3K¢J£r¤J¥r¦J™r§J›r¨  SS4K©Jžrª  SS1K«J™r¬J›r­  SS4K®Jžr¯  SS1K°J™r±J›r²  SS5K³J´r´JµrµJ¶r¶J·r·  SS6K¸J¹r¹Jºrº  SS7K»J¼r¼J½r½  SS8K¾J¿r¿  SS9KÀJÁrÁ  SS:K©JÂrÂJÃrÃ  SS;KÄJÅrÅ  SS<KÆJÇrÈJÉrÊ  SS=KhJËrË  \!\Ë\Ì\ÍS4   rÎ\ " S>5      rÏ " S? S@5      rÐ " SA SB5      rÑ " SC SD\15      rÒ " SE SF5      rÓ\ " SG\!\\7GR¨                  4   SH9rÕSNSI jrÖSOSJ jr×SPSK jrØ\:" SL5      rÙ\ " SM5      rÚg)Qé    )ÚannotationsN)ÚIterableÚMappingÚSequence)ÚAbstractContextManager)ÚToken)ÚEnum)Úcached_propertyÚpartial)Útime)	ÚTYPE_CHECKINGÚAnyÚCallableÚLiteralÚTypeÚTypeVarÚUnionÚcastÚoverload)ÚContext)Ú	CallbackTÚCounterÚ	HistogramÚUpDownCounter)ÚReadableSpanÚSpan)ÚSpanContextÚSpanKind)Útypes)ÚLiteralStringÚ	ParamSpecé   )ÚVERSIONé   )Úasync_)ÚAutoTraceModuleÚinstall_auto_tracing)ÚGLOBAL_CONFIGÚLogfireConfig)ÚPydanticPluginRecordValues)ÚATTRIBUTES_JSON_SCHEMA_KEYÚATTRIBUTES_LOG_LEVEL_NUM_KEYÚATTRIBUTES_MESSAGE_KEYÚATTRIBUTES_MESSAGE_TEMPLATE_KEYÚATTRIBUTES_SAMPLE_RATE_KEYÚATTRIBUTES_SPAN_TYPE_KEYÚATTRIBUTES_TAGS_KEYÚDISABLE_CONSOLE_KEYÚLEVEL_NUMBERSÚOTLP_MAX_INT_SIZEÚ	LevelNameÚlog_level_attributes)Úlogfire_formatÚlogfire_format_with_magic)Ú
instrument)Úlogfire_json_dumps)ÚJsonSchemaPropertiesÚattributes_json_schemaÚ!attributes_json_schema_propertiesÚcreate_json_schema)ÚProxyMeterProvider)Úget_user_stack_info)ÚProxyTracerProviderÚ_LogfireWrappedSpanÚ_ProxyTracerÚset_exception_status)Úget_versionÚhandle_internal_errorsÚlog_internal_errorÚuniquify_sequence)Ú
ModuleType)ÚWSGIApplication)ÚHttpRequestÚHttpResponse)ÚFastAPI)ÚFlask)ÚClientRequestHookÚClientResponseHookÚServerRequestHook)Ú_Gauge)ÚEvaluationReport)ÚCommandFailedEventÚCommandStartedEventÚCommandSucceededEvent)ÚEngine)ÚAsyncEngine)Ú	Starlette)ÚRequest)Ú	WebSocket)ÚAsyncTemplate)ÚSyncTemplate)ÚUnpack)ÚRequestHookÚResponseHook)ÚCommenterOptionsr_   r`   )ÚAsyncRequestHookÚAsyncResponseHookr_   r`   )ra   )ÚResolveFunctionÚValidationReportÚVariableÚVariablesConfig)ÚASGIAppÚASGIInstrumentKwargs)ÚLambdaEventÚLambdaHandler)ÚSemconvVersion)ÚMySQLConnection)ÚPsycopg2ConnectionÚPsycopgConnection)ÚSQLite3Connection)ÚBaseÚConfig)Ú
SysExcInfoÚTc                  óâ  • \ rS rSrSr\SSSSS.           S|S jjr\S}S	 j5       r\S~S
 j5       r	\
SS j5       r\
S€S j5       r\
S 5       r\
S�S j5       r\
S�S j5       rS‚S jrSSSS\R$                  S.               SƒS jjrS„S jr          S…S jrSSS.         S†S jjrSSS.         S†S jjrSSS.         S†S jjrSSS.         S†S jjrSSS.         S†S jjr\rSSS.         S†S jjrSSS.         S†S jjrSSS.         S†S jjrSSSS\R$                  S.               S‡S jjr\  SˆSSSSSS .             S‰S! jjj5       r!\ SŠS" j5       r! SˆSSSSSS .             S‹S# jjjr!    SŒ             S�S$ jjr"SŽS% jr#S�S& jr$SSSS'.       S�S( jjr%S‘S’S) jjr&S“S* jr'S”S•S+ jjr(S,S-.       S–S. jjr)S/ r* Sˆ   S—S0 jjr+SS1.S˜S2 jjr,S™S3 jr-   Sš       S›S4 jjr.\  SˆSSSSS5.             SœS6 jjj5       r/\ SSSSS5.             S�S7 jj5       r/ SˆSSSSS5.             SžS8 jjjr/SSSSSS9.               SŸS: jjr0 SˆSS;S<.       S S= jjjr1S¡S> jr2 SˆSS;S<.       S¢S? jjjr3S£S@ jr4S£SA jr5S£SB jr6S™SC jr7S¤SD jr8\ SSSSSSSE.                 S¥SF jj5       r9\ SSSSSSSE.                 S¦SG jj5       r9\  SˆSSSSSSSSSH.                     S§SI jjj5       r9 SˆSSSSSSSSSH.                     S¨SJ jjjr9S¤SK jr:     S©             SªSL jjr;   S«         S¬SM jjr<\ S­SN j5       r=\    S®         S¯SO jj5       r=   S®         S°SP jjr=SSSSSSSQ.                 S±SR jjr>SSSSSSS.               S²ST jjr?  S³         S´SU jjr@   Sµ           S¶SV jjrASSSSSSSE.               S·SW jjrBS¤SX jrC    SŒ           S¸SY jjrDSˆS¹SZ jjrE Sˆ       SºS[ jjrF    S»           S¼S\ jjrG   Sµ         S½S] jjrHSˆS¾S^ jjrI S¿     SÀS_ jjrJS`S`Sa.SÁSb jjrKS`S`Sa.SÂSc jjrLS`S`Sa.SÃSd jjrMS`S`Sa.SÄSe jjrNS`S`Sa.         SÅSf jjrOS`S`Sa.         SÅSg jjrPS`S`Sa.         SÅSh jjrQSÆSi jrRSÇSÈSj jjrS\ SSk.       SÉSl jj5       rT\ SSk.         SÊSm jj5       rTSSSn.         SËSo jjrTS¡Sp jrUSÌSq jrV SˆSSSSr.         SÍSs jjjrWSSSSr.         SÎSt jjrX Sˆ   SÏSu jjrYSvSSSw.         SÐSx jjrZSÑSy jr[ Sˆ   SÒSz jjr\S{r]g)ÓÚLogfireé�   zThe main logfire class.N© TÚlogfire)ÚconfigÚsample_rateÚtagsÚconsole_logÚ
otel_scopec               ób   • [        U5      U l        Xl        X l        X@l        XPl        0 U l        g ©N)ÚtupleÚ_tagsÚ_configÚ_sample_rateÚ_console_logÚ_otel_scopeÚ
_variables)Úselfrz   r{   r|   r}   r~   s         ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/logfire/_internal/main.pyÚ__init__ÚLogfire.__init__’   s-   € ô ˜4“[ˆŒ
ØŒØ'ÔØ'ÔØ%ÔØ46ˆ�ó    c                ó   • U R                   $ r€   )rƒ   ©rˆ   s    r‰   rz   ÚLogfire.config¢   s   € à�|‰|ÐrŒ   c                óB   • U R                   R                  R                  $ r€   )Ú_tracer_providerÚresourceÚ
attributesrŽ   s    r‰   Úresource_attributesÚLogfire.resource_attributes¦   s   € à×$Ñ$×-Ñ-×8Ñ8Ð8rŒ   c                ól   • U R                   R                  S5        U R                   R                  5       $ )Nz No logs or spans will be created)rƒ   Úwarn_if_not_initializedÚget_tracer_providerrŽ   s    r‰   r‘   ÚLogfire._tracer_providerª   s(   € à�‰×,Ñ,Ð-OÔPØ�|‰|×/Ñ/Ó1Ð1rŒ   c                ó6   • U R                   R                  5       $ r€   )rƒ   Úget_meter_providerrŽ   s    r‰   Ú_meter_providerÚLogfire._meter_provider¯   s   € à�|‰|×.Ñ.Ó0Ð0rŒ   c                óV   • U R                   R                  U R                  [        5      $ r€   )rœ   Ú	get_meterr†   r#   rŽ   s    r‰   Ú_meterÚLogfire._meter³   s!   € à×#Ñ#×-Ñ-¨d×.>Ñ.>ÄÓHÐHrŒ   c                ó    • U R                  SS9$ )NF©Úis_span_tracer©Ú_get_tracerrŽ   s    r‰   Ú_logs_tracerÚLogfire._logs_tracer·   s   € à×Ñ¨uÐÐ5Ð5rŒ   c                ó    • U R                  SS9$ )NTr£   r¥   rŽ   s    r‰   Ú_spans_tracerÚLogfire._spans_tracer»   s   € à×Ñ¨tÐÐ4Ð4rŒ   c               óT   • U R                   R                  U R                  [        US9$ )Nr£   )r‘   Ú
get_tracerr†   r#   )rˆ   r¤   s     r‰   r¦   ÚLogfire._get_tracer¿   s/   € Ø×$Ñ$×/Ñ/Ø×ÑÜØ)ð 0ð 
ð 	
rŒ   ©r‚   Ú
_span_nameÚ_levelÚ_linksÚ
_span_kindc          	     óÚ  •  Ub8  [        U5      nU[           n	X�R                  R                  :  a
  [	        5       $ OS n[        5       n
0 U
EUEnU R                  R                  (       a   [        R                  " 5       R                  nOS n[        UUU R                  R                  US9u  pÞnUR                  U5        UR                  U5        X[        '   XÛ[        '   [!        U5      n[#        U5      =n(       a  [%        U5      U[&        '   U R(                  =(       d    S[+        U=(       d    S5      -   nU(       a  [-        U5      U[.        '   U R0                  b  U R0                  OUR3                  [4        S 5      nUb  US:w  a	  UU[4        '   Ub  UR                  U5        [7        U=(       d    UUU R8                  UUUS9$ ! [:         a    [=        5         [	        5       s $ f = f)N©Úfstring_framerx   r$   )ÚlinksÚ	span_kind)r6   r,   rz   Ú	min_levelÚNoopSpanr@   rƒ   Úinspect_argumentsÚinspectÚcurrentframeÚf_backr8   ÚscrubberÚupdater.   r-   Úprepare_otlp_attributesr=   r<   r+   r‚   r�   rH   r1   r„   Úpopr/   ÚLogfireSpanrª   Ú	ExceptionrG   )rˆ   Úmsg_templater“   r‚   r°   r±   r²   r³   Úlevel_attributesÚ	level_numÚ
stack_infoÚmerged_attributesr¶   Úlog_messageÚextra_attrsÚotlp_attributesÚjson_schema_propertiesr|   r{   s                      r‰   Ú_spanÚLogfire._spanÇ   sÞ  € ð:	ØÑ!Ü#7¸Ó#?Ð Ø,Ô-IÑJ�	ØŸ{™{×4Ñ4Ó4Ü#›:Ð%ð 5ð $(Ð ä,Ó.ˆJØ < :Ð <°Ð <Ðà�|‰|×-×-Ü '× 4Ò 4Ó 6× =Ñ =‘à $�ä5NØØ!Ø—‘×%Ñ%Ø+ñ	6Ñ2ˆK lð ×$Ñ$ [Ô1Ø×Ñ˜kÔ*ØAMÔ=Ñ>Ø8CÔ4Ñ5ä5Ð6GÓHˆOä)JÈ:Ó)VÐVÐ%ÕVÜ>TÐUkÓ>l�Ô :Ñ;à—J‘J×$ "¬¨e¯k°rÓ(:Ñ:ˆDÞÜ7HÈÓ7N�Ô 3Ñ4ð ×$Ñ$Ñ0ð ×!Ò!à$×(Ñ(Ô)CÀTÓJð ð
 Ñ&¨;¸!Ó+;Ø>I�Ô :Ñ;àÑ+Ø×&Ñ&Ð'7Ô8äØ×*˜lØØ×"Ñ"Ø&ØØ$ñð øô ó 	ÜÔ Ü“:Òð	ús   ‚9G	 ¼FG	 Ç	G*Ç)G*c                óž   •  U R                   R                  " SXS.UD6n[        U5      $ ! [         a    [	        5         [        5       s $ f = f)zÎA simple version of `_span` optimized for auto-tracing that doesn't support message formatting.

Returns a similarly simplified version of `LogfireSpan` which must immediately be used as a context manager.
)Únamer“   rx   )rª   Ú
start_spanÚFastLogfireSpanrÄ   rG   rº   )rˆ   rÑ   r“   ÚkwargsÚspans        r‰   Ú
_fast_spanÚLogfire._fast_span  sN   € ð
	Ø×%Ñ%×0Ò0Ð\°dÑ\ÐU[Ñ\ˆDÜ" 4Ó(Ð(øÜó 	ÜÔ Ü“:Òð	ús   ‚(+ «AÁAc                óN  •  U[            n[        XSU R                  R                  5      U[        '   [        U5      =n(       a  [        U5      U[        '   UR                  [        U5      5        U R                  " X40 UD6$ ! [         a    [        5         [        5       s $ f = f)zÒA version of `_span` used by `@instrument` with `extract_args=True`.

This is a bit faster than `_span` but not as fast as `_fast_span` because it supports message formatting
and arbitrary types of attributes.
)r.   r7   rƒ   r¿   r-   r=   r<   r+   rÀ   rÁ   rÖ   rÄ   rG   rº   )rˆ   rÑ   r“   Úfunction_argsrÔ   rÅ   rÍ   s          r‰   Ú_instrument_span_with_argsÚ"Logfire._instrument_span_with_args  s˜   € ð		Ø *Ô+JÑ KˆLÜ1?ÀÐ]a×]iÑ]i×]rÑ]rÓ1sˆJÔ-Ñ.Ü)JÈ=Ó)YÐYÐ%ÕYÜ9OÐPfÓ9g�
Ô5Ñ6Ø×ÑÔ5°mÓDÔEØ—?’? 4Ñ>°vÑ>Ð>øÜó 	ÜÔ Ü“:Òð	ús   ‚B B ÂB$Â#B$F)r‚   Ú	_exc_infoc              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÚ  Log a trace message.

```py
import logfire

logfire.configure()

logfire.trace('This is a trace log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7f©Ú_N©Ú
startswith©Ú.0Úks     r‰   Ú	<genexpr>Ú Logfire.trace.<locals>.<genexpr>I  ó   é € Ð5ª* Q�|‰|˜C× Ð ª*ùó   ‚ú/Attribute keys cannot start with an underscore.Útrace©r|   Úexc_infoN©ÚanyÚ
ValueErrorÚlog©rˆ   rÅ   r‚   rÜ   r“   s        r‰   rë   ÚLogfire.trace-  ó3   € ô8 Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�‰�˜,¸ˆÒSrŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÚ  Log a debug message.

```py
import logfire

logfire.configure()

logfire.debug('This is a debug log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú Logfire.debug.<locals>.<genexpr>i  rè   ré   rê   Údebugrì   Nrî   rò   s        r‰   rø   ÚLogfire.debugM  rô   rŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÙ  Log an info message.

```py
import logfire

logfire.configure()

logfire.info('This is an info log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   ÚLogfire.info.<locals>.<genexpr>‰  rè   ré   rê   Úinforì   Nrî   rò   s        r‰   rý   ÚLogfire.infom  s3   € ô8 Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�‰�˜¸ˆÒRrŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÝ  Log a notice message.

```py
import logfire

logfire.configure()

logfire.notice('This is a notice log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú!Logfire.notice.<locals>.<genexpr>©  rè   ré   rê   Únoticerì   Nrî   rò   s        r‰   r  ÚLogfire.notice�  s3   € ô8 Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�‰�˜<¸%ˆÒTrŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)a  Log a warning message.

```py
import logfire

logfire.configure()

logfire.warning('This is a warning log')
```

`logfire.warn` is an alias of `logfire.warning`.

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú"Logfire.warning.<locals>.<genexpr>Ë  rè   ré   rê   Úwarnrì   Nrî   rò   s        r‰   ÚwarningÚLogfire.warning­  s3   € ô< Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�‰�˜¸ˆÒRrŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÜ  Log an error message.

```py
import logfire

logfire.configure()

logfire.error('This is an error log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú Logfire.error.<locals>.<genexpr>í  rè   ré   rê   Úerrorrì   Nrî   rò   s        r‰   r  ÚLogfire.errorÑ  rô   rŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)aÚ  Log a fatal message.

```py
import logfire

logfire.configure()

logfire.fatal('This is a fatal log')
```

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú Logfire.fatal.<locals>.<genexpr>  rè   ré   rê   Úfatalrì   Nrî   rò   s        r‰   r  ÚLogfire.fatalñ  rô   rŒ   c              ój   • [        S U 5       5      (       a  [        S5      eU R                  SXX#S9  g)a¼  The same as `error` but with `_exc_info=True` by default.

This means that a traceback will be logged for any currently handled exception.

Args:
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    _tags: An optional sequence of tags to include in the log.
    _exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   Ú$Logfire.exception.<locals>.<genexpr>%  rè   ré   rê   r  rì   Nrî   rò   s        r‰   Ú	exceptionÚLogfire.exception  s3   € ô( Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�‰�˜,¸ˆÒSrŒ   c         
     óp   • [        S U 5       5      (       a  [        S5      eU R                  UUUUUUUS9$ )aÆ  Context manager for creating a span.

```py
import logfire

logfire.configure()

with logfire.span('This is a span {a=}', a='data'):
    logfire.info('new log 1')
```

Args:
    msg_template: The template for the span message.
    _span_name: The span name. If not provided, the `msg_template` will be used.
    _tags: An optional sequence of tags to include in the span.
    _level: An optional log level name.
    _links: An optional sequence of links to other spans. Each link is a tuple of a span context and attributes.
    _span_kind: The [OpenTelemetry span kind](https://opentelemetry.io/docs/concepts/signals/traces/#span-kind).
        If not provided, defaults to `INTERNAL`.
        Users don't typically need to set this.
        Not related to the `kind` column of the `records` table in Logfire.
    attributes: The arguments to include in the span and format the message template with.
        Attributes starting with an underscore are not allowed.
c              3  óB   #   • U  H  oR                  S 5      v •  M     g7frß   rá   rã   s     r‰   ræ   ÚLogfire.span.<locals>.<genexpr>M  rè   ré   rê   r¯   )rï   rð   rÎ   )rˆ   rÅ   r‚   r°   r±   r²   r³   r“   s           r‰   rÕ   ÚLogfire.span)  sM   € ôH Ñ5©*Ó5×5Ñ5ÜÐNÓOÐOØ�z‰zØØØØ!ØØØ!ð ð 
ð 	
rŒ   )Ú	span_nameÚextract_argsÚrecord_returnÚallow_generatorÚ	new_tracec               ó   • g)á   Decorator for instrumenting a function as a span.

```py
import logfire

logfire.configure()


@logfire.instrument('This is a span {a=}')
def my_function(a: int):
    logfire.info('new log {a=}', a=a)
```

Args:
    msg_template: The template for the span message. If not provided, the module and function name will be used.
    span_name: The span name. If not provided, the `msg_template` will be used.
    extract_args: By default, all function call arguments are logged as span attributes.
        Set to `False` to disable this, or pass an iterable of argument names to include.
    record_return: Set to `True` to record the return value of the function as an attribute.
        Ignored for generators.
    allow_generator: Set to `True` to prevent a warning when instrumenting a generator function.
        Read https://logfire.pydantic.dev/docs/guides/advanced/generators/#using-logfireinstrument first.
    new_trace: Set to `True` to start a new trace with a span link to the current span
        instead of creating a child of the current span.
Nrx   ©rˆ   rÅ   r  r  r  r   r!  s          r‰   r9   ÚLogfire.instrumentY  ó   � rŒ   c                ó   • g)zÒDecorator for instrumenting a function as a span, with default configuration.

```py
import logfire

logfire.configure()


@logfire.instrument
def my_function(a: int):
    logfire.info('new log {a=}', a=a)
```
Nrx   )rˆ   Úfuncs     r‰   r9   r%  ~  r&  rŒ   c          
     ó’   • [        U5      (       a  U R                  5       " U5      $ [        U [        U R                  5      XX4XV5      $ )r#  )Úcallabler9   r�   r‚   r$  s          r‰   r9   r%  Ž  sD   € ôF �L×!Ñ!Ø—?‘?Ô$ \Ó2Ð2ÜØ”%˜Ÿ
™
Ó# \¸lÐ[jó
ð 	
rŒ   c                óà  • [            [        U5      nU[           nX€R                  R                  :  a
   SSS5        g[        5       n	U=(       d    0 n0 U	EUEn
UR                  [        S5      =ncÆ  SnU R                  R                  (       ag  [        R                  " 5       nUR                  R                  R                  [        R                   R"                  R                  :X  a  UR                  n[%        UU
U R                  R&                  US9u  p½nU(       a  U
R)                  U5        0 UEUEnO[+        U5      =oº[        '   [+        U5      n[-        U
5      n[.        S0UE[0        U[        U0EUEn[3        U5      =n(       a  [5        U5      U[6        '   U R8                  [;        U=(       d    S5      -   nU(       a  [=        U5      U[>        '   U R@                  b  U R@                  OUR                  [B        S5      nUb  US:w  a	  UU[B        '   Uc  U RD                  (       d  OU(       d	  SU[F        '   U R                  RH                  RK                  5       nU RL                  RO                  UUUS9nURQ                  5       (       d
   SSS5        gU(       a   USL a  [R        RT                  " 5       n[W        U[:        5      (       a  US   n[W        U[X        5      (       a2  UR[                  U5        U[           [\        S   :¼  a  [_        UU5        O%Ub"  [a        S	URb                  Rd                   35      eURg                  U5        SSS5        g! , (       d  f       g= f)
aK  Log a message.

```py
import logfire

logfire.configure()

logfire.log('info', 'This is a log {a}', {'a': 'Apple'})
```

Args:
    level: The level of the log.
    msg_template: The message to log.
    attributes: The attributes to bind to the log.
    tags: An optional sequence of tags to include in the log.
    exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
        to record a traceback with the log message.

        Set to `True` to use the currently handled exception.
    console_log: Whether to log to the console, defaults to `True`.
Nrµ   rñ   rx   r$   T)r“   Ú
start_timer  zInvalid type for exc_info: )4rF   r6   r,   rz   r¹   r@   rÂ   r-   rƒ   r»   r¼   r½   r¾   Úf_codeÚco_filenamerv   rñ   Ú__code__r8   r¿   rÀ   ÚstrrÁ   r0   r.   r=   r<   r+   r‚   r�   rH   r1   r„   r/   r…   r2   ÚadvancedÚns_timestamp_generatorr§   rÒ   Úis_recordingÚsysrí   Ú
isinstanceÚBaseExceptionÚrecord_exceptionr3   rD   Ú	TypeErrorÚ	__class__Ú__name__Úend)rˆ   ÚlevelrÅ   r“   r|   rí   r}   rÆ   rÇ   rÈ   rÉ   Úmsgr¶   rË   rÌ   rÍ   r{   r,  rÕ   s                      r‰   rñ   ÚLogfire.log·  s'  € ö< $Ü3°EÓ:ÐØ(Ô)EÑFˆIØŸ;™;×0Ñ0Ó0Ø÷	 $Ð#ô -Ó.ˆJà#×) rˆJØ < :Ð <°Ð <ÐØ!—~‘~Ô&<¸dÓCÐC�ÑLØ $�Ø—<‘<×1×1Ü$+×$8Ò$8Ó$:�MØ$×+Ñ+×2Ñ2×>Ñ>Ä'Ç+Á+×BVÑBV×BbÑBbÓbð )6×(<Ñ(<˜ä1JØ Ø%Ø—L‘L×)Ñ)Ø"/ñ	2Ñ.� ,ö Ø%×,Ñ,¨[Ô9ð "? JÐ!>°+Ð!>�Jøô CFÀcÃ(ÐJ�Ô(>Ñ?Ü" <Ó0�ä5Ð6GÓHˆOä(¨%ðà"ðô 0°Ü&¨ñ	ð
 "ðˆOô *KÈ:Ó)VÐVÐ%ÕVÜ>TÐUkÓ>l�Ô :Ñ;à—:‘:¤ d§j¨bÓ 1Ñ1ˆDÞÜ7HÈÓ7N�Ô 3Ñ4ð ×$Ñ$Ñ0ð ×!Ò!à$×(Ñ(Ô)CÀTÓJð ð
 Ñ&¨;¸!Ó+;Ø>I�Ô :Ñ;à)4Ñ)<�D×%×%Ð%Æ+Ø7;�Ô 3Ñ4ØŸ™×.Ñ.×EÑEÓGˆJà×$Ñ$×/Ñ/ØØ*Ø%ð 0ð ˆDð ×$Ñ$×&Ñ&Ø÷M $Ð#öP Ø˜tÒ#Ü"Ÿ|š|›~�HÜ˜h¬×.Ñ.Ø'¨™{�HÜ˜h¬×6Ñ6Ø×)Ñ)¨(Ô3Ø&Ô'CÑDÌÐV]ÑH^Ó^ô -¨T°8Ô<øØÑ)Ü#Ð&AÀ(×BTÑBT×B]ÑB]ÐA^Ð$_Ó`Ð`à�H‰H�ZÔ ÷o $×#Ö#ús   ‡/M¿IMÊB8MÍ
M-c                ó    • U R                  US9$ )aŠ  A new Logfire instance which always uses the given tags.

```py
import logfire

logfire.configure()

local_logfire = logfire.with_tags('tag1')
local_logfire.info('a log message', _tags=['tag2'])

# This is equivalent to:
logfire.info('a log message', _tags=['tag1', 'tag2'])
```

Args:
    tags: The tags to add.

Returns:
    A new Logfire instance with the `tags` added to any existing tags.
)r|   )Úwith_settings)rˆ   r|   s     r‰   Ú	with_tagsÚLogfire.with_tags.  s   € ð* ×!Ñ! tÐ!Ð,Ð,rŒ   c                ón   • US:”  d  US:  a  [        S5      e[        U R                  U R                  US9$ )z·A new Logfire instance with the given sampling ratio applied.

Args:
    sample_rate: The sampling ratio to use.

Returns:
    A new Logfire instance with the sampling ratio applied.
r$   r   z#sample_rate must be between 0 and 1)rz   r|   r{   )rð   rv   rƒ   r‚   )rˆ   r{   s     r‰   Úwith_trace_sample_rateÚLogfire.with_trace_sample_rateE  s;   € ð ˜‹?˜k¨A›oÜÐBÓCÐCÜØ—<‘<Ø—‘Ø#ñ
ð 	
rŒ   )r|   r}   Úcustom_scope_suffixc               ó¶   • [        U R                  U R                  [        U5      -   U R                  Uc  U R
                  OUUc  U R                  S9$ SU 3S9$ )a_  A new Logfire instance which uses the given settings.

Args:
    tags: Sequence of tags to include in the log.
    console_log: Whether to log to the console, defaults to `True`.
    custom_scope_suffix: A custom suffix to append to `logfire.` e.g. `logfire.loguru`.

        It should only be used when instrumenting another library with Logfire, such as structlog or loguru.

        See the `instrumenting_module_name` parameter on
        [TracerProvider.get_tracer][opentelemetry.sdk.trace.TracerProvider.get_tracer] for more info.

Returns:
    A new Logfire instance with the given settings applied.
zlogfire.)rz   r|   r{   r}   r~   )rv   rƒ   r‚   r�   r„   r…   r†   )rˆ   r|   r}   rF  s       r‰   r@  ÚLogfire.with_settingsV  si   € ô. Ø—<‘<Ø—‘œe D›kÑ)Ø×)Ñ)Ø-8Ñ-@˜×)Ò)ÀkØ+>Ñ+F�t×'Ñ'ñ
ð 	
ð
 OWÐWjÐVkÐLlñ
ð 	
rŒ   c                ó8   • U R                   R                  U5      $ )z”Force flush all spans and metrics.

Args:
    timeout_millis: The timeout in milliseconds.

Returns:
    Whether the flush of spans was successful.
)rƒ   Úforce_flush)rˆ   Útimeout_milliss     r‰   rJ  ÚLogfire.force_flushu  s   € ð �|‰|×'Ñ'¨Ó7Ð7rŒ   c                ó¼   • U R                   R                  nUR                  nUR                  nU(       a  U(       a  U(       d  gUR	                  S5       SU SU 3$ )zÔGenerate a Logfire URL to view an evaluation report.

Args:
    report: An evaluation report from `pydantic_evals`.

Returns:
    The URL string, or `None` if the project URL or trace/span IDs are not available.
NÚ/z/evals/compare?experiment=Ú-)rƒ   Ú_project_urlÚtrace_idÚspan_idÚrstrip)rˆ   ÚreportÚproject_urlrQ  rR  s        r‰   Úurl_from_evalÚLogfire.url_from_eval€  sT   € ð —l‘l×/Ñ/ˆØ—?‘?ˆØ—.‘.ˆÞ¦(¶'ØØ×$Ñ$ SÓ)Ð*Ð*DÀXÀJÈaÐPWÈyÐYÐYrŒ   c                ó.   • [         R                  " X5      $ )aO  Log a warning whenever a function running in the asyncio event loop blocks for too long.

This works by patching the `asyncio.events.Handle._run` method.

Args:
    slow_duration: the threshold in seconds for when a callback is considered slow.

Returns:
    A context manager that will revert the patch when exited.
        This context manager doesn't take into account threads or other concurrency.
        Calling this method will immediately apply the patch
        without waiting for the context manager to be opened,
        i.e. it's not necessary to use this as a context manager.
)r%   Úlog_slow_callbacks)rˆ   Úslow_durations     r‰   Úlog_slow_async_callbacksÚ Logfire.log_slow_async_callbacks�  s   € ô ×(Ò(¨Ó=Ð=rŒ   r  )Úcheck_imported_modulesc               ó   • [        XX2S9  g)aƒ  Install automatic tracing.

See the [Auto-Tracing guide](https://logfire.pydantic.dev/docs/guides/onboarding_checklist/add_auto_tracing/)
for more info.

This will trace all non-generator function calls in the modules specified by the modules argument.
It's equivalent to wrapping the body of every function in matching modules in `with logfire.span(...):`.

!!! note
    This function MUST be called before any of the modules to be traced are imported.

    Generator functions will not be traced for reasons explained [here](https://logfire.pydantic.dev/docs/guides/advanced/generators/).

This works by inserting a new meta path finder into `sys.meta_path`, so inserting another finder before it
may prevent it from working.

It relies on being able to retrieve the source code via at least one other existing finder in the meta path,
so it may not work if standard finders are not present or if the source code is not available.
A modified version of the source code is then compiled and executed in place of the original module.

Args:
    modules: List of module names to trace, or a function which returns True for modules that should be traced.
        If a list is provided, any submodules within a given module will also be traced.
    min_duration: A minimum duration in seconds for which a function must run before it's traced.
        Setting to `0` causes all functions to be traced from the beginning.
        Otherwise, the first time(s) each function is called, it will be timed but not traced.
        Only after the function has run for at least `min_duration` will it be traced in subsequent calls.
    check_imported_modules: If this is `'error'` (the default), then an exception will be raised if any of the
        modules in `sys.modules` (i.e. modules that have already been imported) match the modules to trace.
        Set to `'warn'` to issue a warning instead, or `'ignore'` to skip the check.
)r]  Úmin_durationN)r'   )rˆ   Úmodulesr_  r]  s       r‰   r'   ÚLogfire.install_auto_tracing¡  s   € ôL 	˜TÐCYÓurŒ   c                ó:   • U R                   R                  S5        g )Nz#Instrumentation will have no effect)rz   r—   rŽ   s    r‰   Ú,_warn_if_not_initialized_for_instrumentationÚ4Logfire._warn_if_not_initialized_for_instrumentationÉ  s   € Ø�‰×+Ñ+Ð,QÕRrŒ   c                ó@   • SSK Jn  U R                  5         U" X5        g)a;  Instrument [SurrealDB](https://surrealdb.com/) connections, creating a span for each method.

Args:
    obj: Pass a single connection instance to instrument only that connection.
        Pass a connection class to instrument all instances of that class.
        By default, all connection classes are instrumented.
r$   )Úinstrument_surrealdbN)Úintegrations.surrealdbrf  rc  )rˆ   Úobjrf  s      r‰   rf  ÚLogfire.instrument_surrealdbÌ  s   € õ 	Aà×9Ñ9Ô;Ù˜SÕ'rŒ   )Úpropagate_otel_contextc               ó@   • SSK Jn  U R                  5         U" X5        g)aÕ  Instrument the [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk).

Instruments both the client and server side. If possible, calling this in both the client and server
processes is recommended for nice distributed traces.

Args:
    propagate_otel_context: Whether to enable propagation of the OpenTelemetry context
        for distributed tracing.
        Set to False to prevent setting extra fields like `traceparent` on the metadata of requests.
r$   )Úinstrument_mcpN)Úintegrations.mcprl  rc  )rˆ   rj  rl  s      r‰   rl  ÚLogfire.instrument_mcpÛ  s   € õ 	5à×9Ñ9Ô;Ù�tÕ4rŒ   c                ó>   • SSK Jn  U R                  5         U" U 5      $ )am  Instrument the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview).

All `ClaudeSDKClient` instances created after this call will be automatically traced.
Existing instances created before this call will not have tool call tracing.

Returns:
    A context manager that will revert the instrumentation when exited.
        This context manager doesn't take into account threads or other concurrency.
        Calling this method will immediately apply the instrumentation
        without waiting for the context manager to be opened,
        i.e. it's not necessary to use this as a context manager.
r$   )Úinstrument_claude_agent_sdk)Úintegrations.claude_agent_sdkrp  rc  )rˆ   rp  s     r‰   rp  Ú#Logfire.instrument_claude_agent_sdkë  s   € õ 	Oà×9Ñ9Ô;Ù*¨4Ó0Ð0rŒ   c           	     ó"  • US:w  a1  SSK n[        UR                  5      [        S5      :  a  [        S5      eSSKJnJn  [        U[        5      (       a  U1n[        U[        5      (       a  U1nU" U" U[        U5      [        U5      S95        g)a  Instrument Pydantic model validations.

This must be called before defining and importing the model classes you want to instrument.
See the [Pydantic integration guide](https://logfire.pydantic.dev/docs/integrations/pydantic/) for more info.

Args:
    record: The record mode for the Pydantic plugin. It can be one of the following values:

        - `all`: Send traces and metrics for all events. This is default value.
        - `failure`: Send metrics for all validations and traces only for validation failures.
        - `metrics`: Send only metrics.
        - `off`: Disable instrumentation.
    include:
        By default, third party modules are not instrumented. This option allows you to include specific modules.
    exclude:
        Exclude specific modules from instrumentation.
Úoffr   Nz2.5.0z5The Pydantic plugin requires Pydantic 2.5.0 or newer.)ÚPydanticPluginÚset_pydantic_plugin_config)ÚrecordÚincludeÚexclude)
ÚpydanticrE   Ú__version__ÚRuntimeErrorÚlogfire.integrations.pydanticru  rv  r5  r0  Úset)rˆ   rw  rx  ry  rz  ru  rv  s          r‰   Úinstrument_pydanticÚLogfire.instrument_pydanticý  s€   € ð4 �U‹?Ûä˜8×/Ñ/Ó0´;¸wÓ3GÓGÜ"Ð#ZÓ[Ð[ç\ä�gœs×#Ñ#Ø�iˆGä�gœs×#Ñ#Ø�iˆGñ 	#ÙØÜ˜G›Ü˜G›ñõ	
rŒ   )Úinclude_binary_contentÚinclude_contentÚversionÚ
event_modec              ó   • g r€   rx   ©rˆ   rh  r�  r‚  rƒ  r„  rÔ   s          r‰   Úinstrument_pydantic_aiÚLogfire.instrument_pydantic_ai.  s   € ð rŒ   c              ó   • g r€   rx   r†  s          r‰   r‡  rˆ  ;  s   € ð $'rŒ   c         	     óL   • SSK Jn  U R                  5         U" U 4UUUUUS.UD6$ )a7  Instrument Pydantic AI.

Args:
    obj: What to instrument.
        By default, all agents are instrumented.
        You can also pass a specific model or agent.
        If you pass a model, a new instrumented model will be returned.
    include_binary_content: Whether to include base64 encoded binary content (e.g. images) in the telemetry.
        On by default. Requires Pydantic AI 0.2.5 or newer.
    include_content: Whether to include prompts, completions, and tool call arguments and responses
        in the telemetry. On by default. Requires Pydantic AI 0.3.4 or newer.
    version: Version of the data format. This is unrelated to the Pydantic AI package version.
        Requires Pydantic AI 0.7.5 or newer.
        Version 1 is based on the legacy event-based OpenTelemetry GenAI spec
            and will be removed in a future release.
            The parameter `event_mode` is only relevant for version 1.
        Version 2 uses the newer OpenTelemetry GenAI spec and stores messages in the following attributes:
            - `gen_ai.system_instructions` for instructions passed to the agent.
            - `gen_ai.input.messages` and `gen_ai.output.messages` on model request spans.
            - `pydantic_ai.all_messages` on agent run spans.
        Version 3 changes the names of some attributes and spans but not the shape of the data.
        The default version depends on Pydantic AI.
    event_mode: The mode for emitting events in version 1.
        If `'attributes'`, events are attached to the span as attributes.
        If `'logs'`, events are emitted as OpenTelemetry log-based events.
    kwargs: Additional keyword arguments to pass to
        [`InstrumentationSettings`](https://ai.pydantic.dev/api/models/instrumented/#pydantic_ai.models.instrumented.InstrumentationSettings)
        for future compatibility.
r$   )r‡  )rh  r„  rƒ  r‚  r�  )Úintegrations.pydantic_air‡  rc  )rˆ   rh  r�  r‚  rƒ  r„  rÔ   r‡  s           r‰   r‡  rˆ  H  sC   € õP 	Eà×9Ñ9Ô;á%Øð
àØ!ØØ+Ø#9ñ
ð ñ
ð 	
rŒ   ©Úcapture_headersÚrequest_attributes_mapperÚexcluded_urlsÚrecord_send_receiveÚextra_spansc          	     óN   • SSK Jn  U R                  5         U" U U4UUUUUS.UD6$ )a*
  Instrument a FastAPI app so that spans and logs are automatically created for each request.

Uses the [OpenTelemetry FastAPI Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/fastapi/fastapi.html)
under the hood, with some additional features.

Args:
    app: The FastAPI app to instrument.
    capture_headers: Set to `True` to capture all request and response headers.
    request_attributes_mapper: A function that takes a [`Request`][fastapi.Request] or [`WebSocket`][fastapi.WebSocket]
        and a dictionary of attributes and returns a new dictionary of attributes.
        The input dictionary will contain:

        - `values`: A dictionary mapping argument names of the endpoint function to parsed and validated values.
        - `errors`: A list of validation errors for any invalid inputs.

        The returned dictionary will be used as the attributes for a log message.
        If `None` is returned, no log message will be created.

        You can use this to e.g. only log validation errors, or nothing at all.
        You can also add custom attributes.

        The default implementation will return the input dictionary unchanged.
        The function mustn't modify the contents of `values` or `errors`.
    excluded_urls: A string of comma-separated regexes which will exclude a request from tracing if the full URL
        matches any of the regexes. This applies to both the Logfire and OpenTelemetry instrumentation.
        If not provided, the environment variables
        `OTEL_PYTHON_FASTAPI_EXCLUDED_URLS` and `OTEL_PYTHON_EXCLUDED_URLS` will be checked.
    record_send_receive: Set to `True` to allow the OpenTelemetry ASGI middleware to create send/receive spans.

        These are disabled by default to reduce overhead and the number of spans created,
        since many can be created for a single request, and they are not often useful.
        If enabled, they will be set to debug level, meaning they will usually still be hidden in the UI.
    extra_spans: Whether to include the extra 'FastAPI arguments' and 'endpoint function' spans.
    opentelemetry_kwargs: Additional keyword arguments to pass to the OpenTelemetry FastAPI instrumentation.

Returns:
    A context manager that will revert the instrumentation when exited.
        This context manager doesn't take into account threads or other concurrency.
        Calling this method will immediately apply the instrumentation
        without waiting for the context manager to be opened,
        i.e. it's not necessary to use this as a context manager.
r$   )Úinstrument_fastapirŒ  )Úintegrations.fastapir“  rc  )	rˆ   Úappr�  rŽ  r�  r�  r‘  Úopentelemetry_kwargsr“  s	            r‰   r“  ÚLogfire.instrument_fastapi~  sG   € õx 	=à×9Ñ9Ô;Ù!ØØð	
ð ,Ø&?Ø'Ø 3Ø#ñ	
ð #ñ	
ð 		
rŒ   r$   )Úsuppress_other_instrumentationrƒ  c               óÜ   • SSK nSSKJn  SSKJnJnJn  SSKJn	  U	" U5      n
U R                  5         U" U U=(       d    UR                  UR                  4US[        XjS9[        XŠS9U5      $ )	u)  Instrument an OpenAI client so that spans are automatically created for each request.

This instruments the [standard OpenAI SDK](https://pypi.org/project/openai/) package, for instrumentation
of the OpenAI "agents" framework, see [`instrument_openai_agents()`][logfire.Logfire.instrument_openai_agents].

The following methods are instrumented for both the sync and the async clients:

- [`client.chat.completions.create`](https://platform.openai.com/docs/guides/text-generation/chat-completions-api) â€” with and without `stream=True`
- [`client.completions.create`](https://platform.openai.com/docs/guides/text-generation/completions-api) â€” with and without `stream=True`
- [`client.embeddings.create`](https://platform.openai.com/docs/guides/embeddings/how-to-get-embeddings)
- [`client.images.generate`](https://platform.openai.com/docs/guides/images/generations)

When `stream=True` a second span is created to instrument the streamed response.

Example usage:

```python skip-run="true" skip-reason="external-connection"
import openai

import logfire

client = openai.OpenAI()
logfire.configure()
logfire.instrument_openai(client)

response = client.chat.completions.create(
    model='gpt-4',
    messages=[
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'What is four plus five?'},
    ],
)
print('answer:', response.choices[0].message.content)
```

Args:
    openai_client: The OpenAI client or class to instrument:

        - `None` (the default) to instrument both the `openai.OpenAI` and `openai.AsyncOpenAI` classes.
        - The `openai.OpenAI` class or a subclass
        - The `openai.AsyncOpenAI` class or a subclass
        - An instance of `openai.OpenAI`
        - An instance of `openai.AsyncOpenAI`

    suppress_other_instrumentation: If True, suppress any other OTEL instrumentation that may be otherwise
        enabled. In reality, this means the HTTPX instrumentation, which could otherwise be called since
        OpenAI uses HTTPX to make HTTP requests.

    version: The version(s) of the span attribute format to use:

        - `1` (the default): Uses `request_data` and `response_data` attributes.
        - `'latest'`: Uses OpenTelemetry Gen AI semantic convention attributes
          (`gen_ai.input.messages`, `gen_ai.output.messages`, etc.) and omits the full
          `response_data` attribute. A minimal `request_data` (e.g. `{"model": ...}`) is
          still recorded for message template compatibility. This format may change between
          releases.
        - `[1, 'latest']`: Emits both the full legacy attributes and the semantic convention
          attributes simultaneously, useful for migration and testing.

Returns:
    A context manager that will revert the instrumentation when exited.
        Use of this context manager is optional.
r   Nr$   ©Úinstrument_llm_provider©Úget_endpoint_configÚis_async_clientÚon_response©Únormalize_versionsÚOpenAI©rƒ  )ÚopenaiÚ'integrations.llm_providers.llm_providerr›  Ú!integrations.llm_providers.openair�  rž  rŸ  Ú"integrations.llm_providers.semconvr¡  rc  r¢  ÚAsyncOpenAIr   )rˆ   Úopenai_clientr˜  rƒ  r¤  r›  r�  rž  rŸ  r¡  Únormalized_versionss              r‰   Úinstrument_openaiÚLogfire.instrument_openaiÈ  sl   € óT 	åTßhÑhÝJá0°Ó9ÐØ×9Ñ9Ô;Ù&ØØ×@˜fŸm™m¨V×-?Ñ-?Ð@Ø*ØÜÐ'ÑEÜ�KÑ=Øó
ð 	
rŒ   c                óR   • U R                  5         SSKJn  UR                  U 5        g)zÚInstrument the [`agents`](https://github.com/openai/openai-agents-python) framework from OpenAI.

For instrumentation of the standard OpenAI SDK package,
see [`instrument_openai()`][logfire.Logfire.instrument_openai].
r$   )ÚLogfireTraceProviderWrapperN)rc  Úintegrations.openai_agentsr®  Úinstall)rˆ   r®  s     r‰   Úinstrument_openai_agentsÚ Logfire.instrument_openai_agents$  s!   € ð 	×9Ñ9Ô;åKà#×+Ñ+¨DÕ1rŒ   c               ó  • SSK nSSKJnJnJn  SSKJn  SSKJn	  U	" U5      n
U R                  5         U" U U=(       d.    UR                  UR                  UR                  UR                  4US[        XZS9[        XzS9U5      $ )	aW	  Instrument an Anthropic client so that spans are automatically created for each request.

The following methods are instrumented for both the sync and async clients:

- [`client.messages.create`](https://docs.anthropic.com/en/api/messages)
- [`client.messages.stream`](https://docs.anthropic.com/en/api/messages-streaming)
- [`client.beta.tools.messages.create`](https://docs.anthropic.com/en/docs/tool-use)

When `stream=True` a second span is created to instrument the streamed response.

Example usage:

```python skip-run="true" skip-reason="external-connection"
import anthropic

import logfire

client = anthropic.Anthropic()

logfire.configure()
logfire.instrument_anthropic(client)

response = client.messages.create(
    model='claude-3-haiku-20240307',
    system='You are a helpful assistant.',
    messages=[
        {'role': 'user', 'content': 'What is four plus five?'},
    ],
)
print('answer:', response.content[0].text)
```

Args:
    anthropic_client: The Anthropic client or class to instrument:
        - `None` (the default) to instrument all Anthropic client types
        - The `anthropic.Anthropic` or `anthropic.AnthropicBedrock` class or subclass
        - The `anthropic.AsyncAnthropic` or `anthropic.AsyncAnthropicBedrock` class or subclass
        - An instance of any of the above classes

    suppress_other_instrumentation: If True, suppress any other OTEL instrumentation that may be otherwise
        enabled. In reality, this means the HTTPX instrumentation, which could otherwise be called since
        OpenAI uses HTTPX to make HTTP requests.

    version: The version(s) of the span attribute format to use:

        - `1` (the default): Uses `request_data` and `response_data` attributes.
        - `'latest'`: Uses OpenTelemetry Gen AI semantic convention attributes
          (`gen_ai.input.messages`, `gen_ai.output.messages`, etc.) and omits the full
          `response_data` attribute. A minimal `request_data` (e.g. `{"model": ...}`) is
          still recorded for message template compatibility. This format may change between
          releases.
        - `[1, 'latest']`: Emits both the full legacy attributes and the semantic convention
          attributes simultaneously, useful for migration and testing.

Returns:
    A context manager that will revert the instrumentation when exited.
        Use of this context manager is optional.
r   Nr$   rœ  rš  r   Ú	Anthropicr£  )Ú	anthropicÚ$integrations.llm_providers.anthropicr�  rž  rŸ  r¥  r›  r§  r¡  rc  r´  ÚAsyncAnthropicÚAnthropicBedrockÚAsyncAnthropicBedrockr   )rˆ   Úanthropic_clientr˜  rƒ  rµ  r�  rž  rŸ  r›  r¡  rª  s              r‰   Úinstrument_anthropicÚLogfire.instrument_anthropic0  sˆ   € óV 	çkÑkÝTÝJá0°Ó9ÐØ×9Ñ9Ô;Ù&ØØ÷ à×#Ñ#Ø×(Ñ(Ø×*Ñ*Ø×/Ñ/ð	ð +ØÜÐ'ÑEÜ�KÑ=Øó
ð 	
rŒ   c                óB   • SSK Jn  U R                  5         U" U 40 UD6  g)aí  Instrument the [Google Gen AI SDK (`google-genai`)](https://googleapis.github.io/python-genai/).

!!! note
    To capture message contents (i.e. prompts and completions), set the environment variable
    `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` to `true`.

Uses the `GoogleGenAiSdkInstrumentor().instrument()` method of the
[`opentelemetry-instrumentation-google-genai`](https://pypi.org/project/opentelemetry-instrumentation-google-genai/)
package, to which it passes `**kwargs`.
r$   )Úinstrument_google_genaiN)Úintegrations.google_genair¾  rc  )rˆ   rÔ   r¾  s      r‰   r¾  ÚLogfire.instrument_google_genai“  s!   € õ 	Gà×9Ñ9Ô;Ù Ñ/¨Ó/rŒ   c                óB   • SSK Jn  U R                  5         U" U 40 UD6  g)aÃ  Instrument the [LiteLLM](https://docs.litellm.ai/) Python SDK.

!!! warning
    This currently works best if all arguments of instrumented methods are passed as keyword arguments,
    e.g. `litellm.completion(model=model, messages=messages)`.

Uses the `LiteLLMInstrumentor().instrument()` method of the
[`openinference-instrumentation-litellm`](https://pypi.org/project/openinference-instrumentation-litellm/)
package, to which it passes `**kwargs`.
r$   )Úinstrument_litellmN)Úintegrations.litellmrÂ  rc  )rˆ   rÔ   rÂ  s      r‰   rÂ  ÚLogfire.instrument_litellm£  s    € õ 	=à×9Ñ9Ô;Ù˜4Ñ* 6Ó*rŒ   c                óB   • SSK Jn  U R                  5         U" U 40 UD6  g)zìInstrument [DSPy](https://dspy.ai/).

Uses the `DSPyInstrumentor().instrument()` method of the
[`openinference-instrumentation-dspy`](https://pypi.org/project/openinference-instrumentation-dspy/)
package, to which it passes `**kwargs`.
r$   )Úinstrument_dspyN)Úintegrations.dspyrÆ  rc  )rˆ   rÔ   rÆ  s      r‰   rÆ  ÚLogfire.instrument_dspy³  s    € õ 	7à×9Ñ9Ô;Ù˜Ñ' Ó'rŒ   c                ó>   • SSK Jn  U R                  5         U" U 5      $ )a«  Instrument the built-in `print` function so that calls to it are logged.

If Logfire is configured with [`inspect_arguments=True`][logfire.configure(inspect_arguments)],
the names of the arguments passed to `print` will be included in the log attributes
and will be used for scrubbing.

The fallback attribute name `logfire.print_args` will be used if:

 - `inspect_arguments` is `False`
 - Inspection fails for any reason
 - Multiple starred arguments are used (e.g. `print(*args1, *args2)`)
    in which case names can't be unambiguously determined.

Returns:
    A context manager that will revert the instrumentation when exited.
        Use of this context manager is optional.
r$   )Úinstrument_print)Úintegrations.printrÊ  rc  )rˆ   rÊ  s     r‰   rÊ  ÚLogfire.instrument_print¿  s   € õ$ 	9à×9Ñ9Ô;Ù Ó%Ð%rŒ   c                ó¨   • SSK Jn  U R                  5         U" S0 U R                  R	                  5       U R                  R                  5       S.UED6$ )zWInstrument the `asyncpg` module so that spans are automatically created for each query.r$   )Úinstrument_asyncpg©Útracer_providerÚmeter_providerrx   )Úintegrations.asyncpgrÎ  rc  rƒ   r˜   r›   )rˆ   rÔ   rÎ  s      r‰   rÎ  ÚLogfire.instrument_asyncpgÖ  sR   € å<à×9Ñ9Ô;Ù!ñ 
à#'§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   )Úcapture_allr�  Úcapture_request_bodyÚcapture_response_bodyÚrequest_hookÚresponse_hookc               ó   • g r€   rx   ©	rˆ   ÚclientrÔ  r�  rÕ  rÖ  r×  rØ  rÔ   s	            r‰   Úinstrument_httpxÚLogfire.instrument_httpxã  ó   € ð rŒ   c               ó   • g r€   rx   rÚ  s	            r‰   rÜ  rÝ  ñ  rÞ  rŒ   ©rÔ  r�  rÕ  rÖ  r×  rØ  Úasync_request_hookÚasync_response_hookc               ó   • g r€   rx   )rˆ   rÛ  rÔ  r�  rÕ  rÖ  r×  rØ  rá  râ  rÔ   s              r‰   rÜ  rÝ  ÿ  s   € ð rŒ   c               óT   • SSK Jn  U R                  5         U" U U4UUUUUUUU	S.U
D6$ )aW  Instrument the `httpx` module so that spans are automatically created for each request.

Optionally, pass an `httpx.Client` instance to instrument only that client.

Uses the
[OpenTelemetry HTTPX Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/httpx/httpx.html)
library, specifically `HTTPXClientInstrumentor().instrument()`, to which it passes `**kwargs`.

Args:
    client: The `httpx.Client` or `httpx.AsyncClient` instance to instrument.
        If `None`, the default, all clients will be instrumented.
    capture_all: Set to `True` to capture all HTTP headers, request and response bodies.
        By default checks the environment variable `LOGFIRE_HTTPX_CAPTURE_ALL`.
    capture_headers: Set to `True` to capture all HTTP headers.

        If you don't want to capture all headers, you can customize the headers captured. See the
        [Capture Headers](https://logfire.pydantic.dev/docs/guides/advanced/capture_headers/) section for more info.
    capture_request_body: Set to `True` to capture the request body.
    capture_response_body: Set to `True` to capture the response body.
    request_hook: A function called right after a span is created for a request.
    response_hook: A function called right before a span is finished for the response.
    async_request_hook: A function called right after a span is created for an async request.
    async_response_hook: A function called right before a span is finished for an async response.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` method, for future compatibility.
r$   )rÜ  rà  )Úintegrations.httpxrÜ  rc  )rˆ   rÛ  rÔ  r�  rÕ  rÖ  r×  rØ  rá  râ  rÔ   rÜ  s               r‰   rÜ  rÝ    sP   € õN 	9à×9Ñ9Ô;ÙØØð
ð $Ø+Ø!5Ø"7Ø%Ø'Ø1Ø 3ñ
ð ñ
ð 	
rŒ   c                ó¨   • SSK Jn  U R                  5         U" S0 U R                  R	                  5       U R                  R                  5       S.UED6$ )aó  Instrument `celery` so that spans are automatically created for each task.

Uses the
[OpenTelemetry Celery Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/celery/celery.html)
library.

For distributed tracing to work correctly, this must be called in **both** the worker processes
and the application that enqueues tasks (e.g., your Django or FastAPI web server).
See the [distributed tracing guide](https://logfire.pydantic.dev/docs/how-to-guides/distributed-tracing/#integrations).

See the [Celery guide](https://logfire.pydantic.dev/docs/integrations/celery/) for more details.

Args:
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` method, for future compatibility.
r$   )Úinstrument_celeryrÏ  rx   )Úintegrations.celeryrç  rc  rƒ   r˜   r›   )rˆ   rÔ   rç  s      r‰   rç  ÚLogfire.instrument_celeryG  sT   € õ  	;à×9Ñ9Ô;Ù ñ 
à#'§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   c           	     ó´   • SSK Jn  U R                  5         U" SUUUUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )a~  Instrument `django` so that spans are automatically created for each web request.

Uses the
[OpenTelemetry Django Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/django/django.html)
library.

Args:
    capture_headers: Set to `True` to capture all request and response headers.
    is_sql_commentor_enabled: Adds comments to SQL queries performed by Django,
        so that database logs have additional context.

        This does NOT create spans/logs for the queries themselves.
        For that you need to instrument the database driver, e.g. with `logfire.instrument_psycopg()`.

        To configure the SQL Commentor, see the OpenTelemetry documentation for the
        values that need to be added to `settings.py`.

    request_hook: A function called right after a span is created for a request.
        The function should accept two arguments: the span and the Django `Request` object.

    response_hook: A function called right before a span is finished for the response.
        The function should accept three arguments:
        the span, the Django `Request` object, and the Django `Response` object.

    excluded_urls: A string containing a comma-delimited list of regexes used to exclude URLs from tracking.

    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` method,
        for future compatibility.

r$   )Úinstrument_django)r�  Úis_sql_commentor_enabledr×  rØ  r�  rÏ  rx   )Úintegrations.djangorë  rc  rƒ   r˜   r›   )rˆ   r�  rì  r×  rØ  r�  rÔ   rë  s           r‰   rë  ÚLogfire.instrument_djangob  sk   € õN 	;à×9Ñ9Ô;Ù ð 
Ø+Ø%=Ø%Ø'Ø'ñ
ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   c                ó°   • SSK Jn  U R                  5         U" SUUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )aî  Instrument the `requests` module so that spans are automatically created for each request.

Args:
    excluded_urls: A string containing a comma-delimited list of regexes used to exclude URLs from tracking
    request_hook: A function called right after a span is created for a request.
    response_hook: A function called right before a span is finished for the response.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods, for future compatibility.
r$   )Úinstrument_requests)r�  r×  rØ  rÏ  rx   )Úintegrations.requestsrð  rc  rƒ   r˜   r›   )rˆ   r�  r×  rØ  rÔ   rð  s         r‰   rð  ÚLogfire.instrument_requests™  sd   € õ 	?à×9Ñ9Ô;Ù"ð 	
Ø'Ø%Ø'ñ	
ð
 $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ		
ð 		
rŒ   c                ó   • g r€   rx   )rˆ   Úconn_or_modulerÔ   s      r‰   Úinstrument_psycopgÚLogfire.instrument_psycopg¶  s   € ØqtrŒ   c                ó   • g r€   rx   )rˆ   rô  Úenable_commenterÚcommenter_optionsrÔ   s        r‰   rõ  rö  ¹  s   € ð rŒ   c                óŒ   • SSK Jn  U R                  5         U(       a  UR                  SU=(       d    0 S.5        U" U 4SU0UD6$ )aï  Instrument a `psycopg` connection or module so that spans are automatically created for each query.

Uses the OpenTelemetry instrumentation libraries for
[`psycopg`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/psycopg/psycopg.html)
and
[`psycopg2`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/psycopg2/psycopg2.html).

Args:
    conn_or_module: Can be:

        - The `psycopg` (version 3) or `psycopg2` module.
        - The string `'psycopg'` or `'psycopg2'` to instrument the module.
        - `None` (the default) to instrument whichever module(s) are installed.
        - A `psycopg` or `psycopg2` connection.

    enable_commenter: Adds comments to SQL queries performed by Psycopg, so that database logs have additional context.
    commenter_options: Configure the tags to be added to the SQL comments.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods,
        for future compatibility.
r$   )rõ  T)rø  rù  rô  )Úintegrations.psycopgrõ  rc  rÀ   )rˆ   rô  rø  rù  rÔ   rõ  s         r‰   rõ  rö  Â  sC   € õ6 	=à×9Ñ9Ô;ÞØ�M‰M¨tÐJ[×JaÐ_aÑbÔcÙ! $ÑP°~ÐPÈÑPÐPrŒ   ©r�  rø  rù  r�  r×  rØ  c          
     ó¸   • SSK Jn	  U R                  5         U	" U4UUUUUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )a¦  Instrument `app` so that spans are automatically created for each request.

Uses the
[OpenTelemetry Flask Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/flask/flask.html)
library, specifically `FlaskInstrumentor().instrument_app()`, to which it passes `**kwargs`.

Args:
    app: The Flask app to instrument.
    capture_headers: Set to `True` to capture all request and response headers.
    enable_commenter: Adds comments to SQL queries performed by Flask, so that database logs have additional context.
    commenter_options: Configure the tags to be added to the SQL comments.
        See more about it on the [SQLCommenter Configurations](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/flask/flask.html#sqlcommenter-configurations).
    excluded_urls: A string containing a comma-delimited list of regexes used to exclude URLs from tracking.
    request_hook: A function called right after a span is created for a request.
    response_hook: A function called right before a span is finished for the response.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry Flask instrumentation.
r$   )Úinstrument_flaskrü  rÏ  )Úintegrations.flaskrþ  rc  rƒ   r˜   r›   )
rˆ   r•  r�  rø  rù  r�  r×  rØ  rÔ   rþ  s
             r‰   rþ  ÚLogfire.instrument_flaskä  sp   € õ: 	9à×9Ñ9Ô;ÙØð
à+Ø-Ø/Ø'Ø%Ø'ñ
ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   )r�  r�  Úserver_request_hookÚclient_request_hookÚclient_response_hookc          	     óN   • SSK Jn  U R                  5         U" U U4UUUUUS.UD6$ )a(  Instrument `app` so that spans are automatically created for each request.

Uses the
[OpenTelemetry Starlette Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/starlette/starlette.html)
library, specifically `StarletteInstrumentor.instrument_app()`, to which it passes `**kwargs`.

Args:
    app: The Starlette app to instrument.
    capture_headers: Set to `True` to capture all request and response headers.
    record_send_receive: Set to `True` to allow the OpenTelemetry ASGI middleware to create send/receive spans.

        These are disabled by default to reduce overhead and the number of spans created,
        since many can be created for a single request, and they are not often useful.
        If enabled, they will be set to debug level, meaning they will usually still be hidden in the UI.
    server_request_hook: A function that receives a server span and the ASGI scope for every incoming request.
    client_request_hook: A function that receives a span, the ASGI scope and the receive ASGI message for every ASGI receive event.
    client_response_hook: A function that receives a span, the ASGI scope and the send ASGI message for every ASGI send event.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry Starlette instrumentation.
r$   )Úinstrument_starlette)r�  r�  r  r  r  )Úintegrations.starletter  rc  )	rˆ   r•  r�  r�  r  r  r  rÔ   r  s	            r‰   r  ÚLogfire.instrument_starlette  sG   € õ< 	Aà×9Ñ9Ô;Ù#ØØð	
ð !4Ø+Ø 3Ø 3Ø!5ñ	
ð ñ	
ð 		
rŒ   c                óH   • SSK Jn  U R                  5         U" U U4UUS.UD6$ )aç  Instrument `app` so that spans are automatically created for each request.

Uses the ASGI [`OpenTelemetryMiddleware`][opentelemetry.instrumentation.asgi.OpenTelemetryMiddleware] under
the hood, to which it passes `**kwargs`.

Warning:
    Instead of modifying the app in place, this method returns the instrumented ASGI application.

Args:
    app: The ASGI application to instrument.
    capture_headers: Set to `True` to capture all request and response headers.
    record_send_receive: Set to `True` to allow the OpenTelemetry ASGI middleware to create send/receive spans.

        These are disabled by default to reduce overhead and the number of spans created,
        since many can be created for a single request, and they are not often useful.
        If enabled, they will be set to debug level, meaning they will usually still be hidden in the UI.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry ASGI middleware.

Returns:
    The instrumented ASGI application.
r$   )Úinstrument_asgi)r�  r�  )Úintegrations.asgir	  rc  )rˆ   r•  r�  r�  rÔ   r	  s         r‰   r	  ÚLogfire.instrument_asgi?  s=   € õ8 	7à×9Ñ9Ô;ÙØØð
ð !4Ø+ñ	
ð
 ñ
ð 	
rŒ   c                ó²   • SSK Jn  U R                  5         U" U4UUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )a  Instrument `app` so that spans are automatically created for each request.

Uses the WSGI [`OpenTelemetryMiddleware`][opentelemetry.instrumentation.wsgi.OpenTelemetryMiddleware] under
the hood, to which it passes `**kwargs`.

Warning:
    Instead of modifying the app in place, this method returns the instrumented WSGI application.

Args:
    app: The WSGI application to instrument.
    capture_headers: Set to `True` to capture all request and response headers.
    request_hook: A function called right after a span is created for a request.
    response_hook: A function called right before a span is finished for the response.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry WSGI middleware.

Returns:
    The instrumented WSGI application.
r$   )Úinstrument_wsgi)r�  r×  rØ  rÏ  )Úintegrations.wsgir  rc  rƒ   r˜   r›   )rˆ   r•  r�  r×  rØ  rÔ   r  s          r‰   r  ÚLogfire.instrument_wsgif  sg   € õ4 	7à×9Ñ9Ô;ÙØð

à+Ø%Ø'ñ	

ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ

ð 
	
rŒ   c          
     óN   • SSK Jn  U R                  5         U" U 4UUUUUUS.UD6$ )am  Instrument the `aiohttp` module so that spans are automatically created for each client request.

Uses the
[OpenTelemetry aiohttp client Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/aiohttp_client/aiohttp_client.html)
library, specifically `AioHttpClientInstrumentor().instrument()`, to which it passes `**kwargs`.
r$   )Úinstrument_aiohttp_client)rÔ  rÕ  rÖ  r�  r×  rØ  )Úintegrations.aiohttp_clientr  rc  )	rˆ   rÔ  r�  rÕ  rÖ  r×  rØ  rÔ   r  s	            r‰   r  Ú!Logfire.instrument_aiohttp_client�  sE   € õ" 	Kà×9Ñ9Ô;Ù(Øð	
à#Ø!5Ø"7Ø+Ø%Ø'ñ	
ð ñ	
ð 		
rŒ   c                ó¨   • SSK Jn  U R                  5         U" S0 U R                  R	                  5       U R                  R                  5       S.UED6$ )am  Instrument the `aiohttp` module so that spans are automatically created for each server request.

Uses the
[OpenTelemetry aiohttp server Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/aiohttp_server/aiohttp_server.html)
library, specifically `AioHttpServerInstrumentor().instrument()`, to which it passes `**kwargs`.
r$   )Úinstrument_aiohttp_serverrÏ  rx   )Úintegrations.aiohttp_serverr  rc  rƒ   r˜   r›   )rˆ   rÔ   r  s      r‰   r  Ú!Logfire.instrument_aiohttp_server®  sU   € õ 	Kà×9Ñ9Ô;Ù(ñ 
à#'§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   c                óÄ   • SSK Jn  U R                  5         U" SUUUU=(       d    0 S.U R                  R	                  5       U R                  R                  5       S.UED6$ )aö  Instrument the `sqlalchemy` module so that spans are automatically created for each query.

Uses the
[OpenTelemetry SQLAlchemy Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlalchemy/sqlalchemy.html)
library, specifically `SQLAlchemyInstrumentor().instrument()`, to which it passes `**kwargs`.

Args:
    engine: The `sqlalchemy` engine to instrument.
    engines: An iterable of `sqlalchemy` engines to instrument.
    enable_commenter: Adds comments to SQL queries performed by SQLAlchemy, so that database logs have additional context.
    commenter_options: Configure the tags to be added to the SQL comments.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods.
r$   )Úinstrument_sqlalchemy)ÚengineÚenginesrø  rù  rÏ  rx   )Úintegrations.sqlalchemyr  rc  rƒ   r˜   r›   )rˆ   r  r  rø  rù  rÔ   r  s          r‰   r  ÚLogfire.instrument_sqlalchemyÀ  sm   € õ* 	Cà×9Ñ9Ô;Ù$ð 

ØØØ-Ø/×5°2ñ	

ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ

ð 
	
rŒ   c                óz   • SSK Jn  U R                  5         U" SSU0SU R                  R	                  5       0UED6$ )aR  Instrument the `sqlite3` module or a specific connection so that spans are automatically created for each operation.

Uses the
[OpenTelemetry SQLite3 Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlite3/sqlite3.html)
library.

Args:
    conn: The `sqlite3` connection to instrument, or `None` to instrument all connections.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods.

Returns:
    If a connection is provided, returns the instrumented connection. If no connection is provided, returns `None`.
r$   )Úinstrument_sqlite3ÚconnrÐ  rx   )Úintegrations.sqlite3r  rc  rƒ   r˜   )rˆ   r   rÔ   r  s       r‰   r  ÚLogfire.instrument_sqlite3ä  s?   € õ 	=à×9Ñ9Ô;Ù!Ñq tÐqÐ0AÀ4Ç<Á<×CcÑCcÓCeÐ/pÐioÐ/pÑqÐqrŒ   c                ó®   • SSK Jn  U R                  5         U" SUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )aw  Instrument AWS Lambda so that spans are automatically created for each invocation.

Uses the
[OpenTelemetry AWS Lambda Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/aws_lambda/aws_lambda.html)
library, specifically `AwsLambdaInstrumentor().instrument()`, to which it passes `**kwargs`.

Args:
    lambda_handler: The lambda handler function to instrument.
    event_context_extractor: A function that returns an OTel Trace Context given the Lambda Event the AWS.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods for future compatibility.
r$   )Úinstrument_aws_lambda)Úlambda_handlerÚevent_context_extractorrÏ  rx   )Úintegrations.aws_lambdar$  rc  rƒ   r˜   r›   )rˆ   r%  r&  rÔ   r$  s        r‰   r$  ÚLogfire.instrument_aws_lambda÷  sb   € õ" 	Cà×9Ñ9Ô;Ù$ð 
Ø)Ø$;ñ
ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   c                ó²   • SSK Jn  U R                  5         U" SUUUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )a  Instrument the `pymongo` module so that spans are automatically created for each operation.

Uses the
[OpenTelemetry pymongo Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/pymongo/pymongo.html)
library, specifically `PymongoInstrumentor().instrument()`, to which it passes `**kwargs`.

Args:
    capture_statement: Set to `True` to capture the statement in the span attributes.
    request_hook: A function called when a command is sent to the server.
    response_hook: A function that is called when a command is successfully completed.
    failed_hook: A function that is called when a command fails.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods for future compatibility.
r$   )Úinstrument_pymongo)Úcapture_statementr×  rØ  Úfailed_hookrÏ  rx   )Úintegrations.pymongor*  rc  rƒ   r˜   r›   )rˆ   r+  r×  rØ  r,  rÔ   r*  s          r‰   r*  ÚLogfire.instrument_pymongo  sg   € õ* 	=à×9Ñ9Ô;Ù!ð 

Ø/Ø%Ø'Ø#ñ	

ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ

ð 
	
rŒ   c                ó°   • SSK Jn  U R                  5         U" SUUUS.U R                  R	                  5       U R                  R                  5       S.UED6$ )a­  Instrument the `redis` module so that spans are automatically created for each operation.

Uses the
[OpenTelemetry Redis Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html)
library, specifically `RedisInstrumentor().instrument()`, to which it passes `**kwargs`.

Args:
    capture_statement: Set to `True` to capture the statement in the span attributes.
    request_hook: A function that is called before performing the request.
    response_hook: A function that is called after receiving the response.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods for future compatibility.
r$   )Úinstrument_redis)r+  r×  rØ  rÏ  rx   )Úintegrations.redisr0  rc  rƒ   r˜   r›   )rˆ   r+  r×  rØ  rÔ   r0  s         r‰   r0  ÚLogfire.instrument_redis9  sd   € õ& 	9à×9Ñ9Ô;Ùð 	
Ø/Ø%Ø'ñ	
ð
 $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ		
ð 		
rŒ   c                ó¬   • SSK Jn  U R                  5         U" SSU0U R                  R	                  5       U R                  R                  5       S.UED6$ )aL  Instrument the `mysql` module or a specific MySQL connection so that spans are automatically created for each operation.

Uses the
[OpenTelemetry MySQL Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/mysql/mysql.html)
library.

Args:
    conn: The `mysql` connection to instrument, or `None` to instrument all connections.
    **kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods.

Returns:
    If a connection is provided, returns the instrumented connection. If no connection is provided, returns None.
r$   )Úinstrument_mysqlr   rÏ  rx   )Úintegrations.mysqlr4  rc  rƒ   r˜   r›   )rˆ   r   rÔ   r4  s       r‰   r4  ÚLogfire.instrument_mysqlZ  s^   € õ 	9à×9Ñ9Ô;Ùñ 
Øð
ð $(§<¡<×#CÑ#CÓ#EØ"&§,¡,×"AÑ"AÓ"Cñð ðñ
ð 	
rŒ   c                ó@   • SSK Jn  U R                  5         U" XU5      $ )a“  Collect system metrics.

See [the guide](https://logfire.pydantic.dev/docs/integrations/system-metrics/) for more information.

Args:
    config: A dictionary where the keys are metric names
        and the values are optional further configuration for that metric.
    base: A string indicating the base config dictionary which `config` will be merged with,
        or `None` for an empty base config.
r$   )Úinstrument_system_metrics)Úintegrations.system_metricsr8  rc  )rˆ   rz   Úbaser8  s       r‰   r8  Ú!Logfire.instrument_system_metricst  s!   € õ 	Kà×9Ñ9Ô;Ù(¨°tÓ<Ð<rŒ   Ú )ÚunitÚdescriptionc               ó:   • U R                   R                  XU5      $ )ai  Create a counter metric.

A counter is a cumulative metric that represents a single numerical value that only ever goes up.

```py
import logfire

logfire.configure()
counter = logfire.metric_counter('exceptions', unit='1', description='Number of exceptions caught')

try:
    raise Exception('oops')
except Exception:
    counter.add(1)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#counter) about
counters.

Args:
    name: The name of the metric.
    unit: The unit of the metric.
    description: The description of the metric.

Returns:
    The counter metric.
)r    Úcreate_counter©rˆ   rÑ   r=  r>  s       r‰   Úmetric_counterÚLogfire.metric_counter†  s   € ð8 �{‰{×)Ñ)¨$°kÓBÐBrŒ   c               ó:   • U R                   R                  XU5      $ )ak  Create a histogram metric.

A histogram is a metric that samples observations (usually things like request durations or response sizes).

```py
import logfire

logfire.configure()
histogram = logfire.metric_histogram('bank.amount_transferred', unit='$', description='Amount transferred')


def transfer(amount: int):
    histogram.record(amount)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram) about

Args:
    name: The name of the metric.
    unit: The unit of the metric.
    description: The description of the metric.

Returns:
    The histogram metric.
)r    Úcreate_histogramrA  s       r‰   Úmetric_histogramÚLogfire.metric_histogram¤  s   € ð4 �{‰{×+Ñ+¨D¸ÓDÐDrŒ   c               ó:   • U R                   R                  XU5      $ )aA  Create a gauge metric.

Gauge is a synchronous instrument which can be used to record non-additive measurements.

```py
import logfire

logfire.configure()
gauge = logfire.metric_gauge('system.cpu_usage', unit='%', description='CPU usage')


def update_cpu_usage(cpu_percent):
    gauge.set(cpu_percent)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge) about gauges.

Args:
    name: The name of the metric.
    unit: The unit of the metric.
    description: The description of the metric.

Returns:
    The gauge metric.
)r    Úcreate_gaugerA  s       r‰   Úmetric_gaugeÚLogfire.metric_gaugeÀ  s   € ð4 �{‰{×'Ñ'¨°KÓ@Ð@rŒ   c               ó:   • U R                   R                  XU5      $ )aÀ  Create an up-down counter metric.

An up-down counter is a cumulative metric that represents a single numerical value that can be adjusted up or
down.

```py
import logfire

logfire.configure()
up_down_counter = logfire.metric_up_down_counter('users.logged_in', unit='1', description='Users logged in')


def on_login(user):
    up_down_counter.add(1)


def on_logout(user):
    up_down_counter.add(-1)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter) about
up-down counters.

Args:
    name: The name of the metric.
    unit: The unit of the metric.
    description: The description of the metric.

Returns:
    The up-down counter metric.
)r    Úcreate_up_down_counterrA  s       r‰   Úmetric_up_down_counterÚLogfire.metric_up_down_counterÜ  s   € ð@ �{‰{×1Ñ1°$¸kÓJÐJrŒ   c               ó<   • U R                   R                  XX45        g)a«  Create a counter metric that uses a callback to collect observations.

The callback is called every 60 seconds in a background thread.

The counter metric is a cumulative metric that represents a single numerical value that only ever goes up.

```py
import psutil
from opentelemetry.metrics import CallbackOptions, Observation

import logfire

logfire.configure()


def cpu_usage_callback(options: CallbackOptions):
    cpu_percents = psutil.cpu_percent(percpu=True)

    for i, cpu_percent in enumerate(cpu_percents):
        yield Observation(cpu_percent, {'cpu': i})


cpu_usage_counter = logfire.metric_counter_callback(
    'system.cpu.usage',
    callbacks=[cpu_usage_callback],
    unit='%',
    description='CPU usage',
)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter)
about asynchronous counter.

Args:
    name: The name of the metric.
    callbacks: A sequence of callbacks that return an iterable of
        [Observation](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html#opentelemetry.metrics.Observation).
    unit: The unit of the metric.
    description: The description of the metric.
N)r    Úcreate_observable_counter©rˆ   rÑ   Ú	callbacksr=  r>  s        r‰   Úmetric_counter_callbackÚLogfire.metric_counter_callbackþ  s   € ð` 	�‰×-Ñ-¨d¸tÕQrŒ   c               ó<   • U R                   R                  XX45        g)a:  Create a gauge metric that uses a callback to collect observations.

The callback is called every 60 seconds in a background thread.

The gauge metric is a metric that represents a single numerical value that can arbitrarily go up and down.

```py
import threading

from opentelemetry.metrics import CallbackOptions, Observation

import logfire

logfire.configure()


def thread_count_callback(options: CallbackOptions):
    yield Observation(threading.active_count())


logfire.metric_gauge_callback(
    'system.thread_count',
    callbacks=[thread_count_callback],
    unit='1',
    description='Number of threads',
)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge)
about asynchronous gauge.

Args:
    name: The name of the metric.
    callbacks: A sequence of callbacks that return an iterable of
        [Observation](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html#opentelemetry.metrics.Observation).
    unit: The unit of the metric.
    description: The description of the metric.
N)r    Úcreate_observable_gaugerR  s        r‰   Úmetric_gauge_callbackÚLogfire.metric_gauge_callback0	  s   € ðR 	�‰×+Ñ+¨D¸TÕOrŒ   c               ó<   • U R                   R                  XX45        g)aT  Create an up-down counter metric that uses a callback to collect observations.

The callback is called every 60 seconds in a background thread.

The up-down counter is a cumulative metric that represents a single numerical value that can be adjusted up or
down.

```py
from opentelemetry.metrics import CallbackOptions, Observation

import logfire

logfire.configure()

items = []


def inventory_callback(options: CallbackOptions):
    yield Observation(len(items))


logfire.metric_up_down_counter_callback(
    name='store.inventory',
    description='Number of items in the inventory',
    callbacks=[inventory_callback],
)
```

See the [Opentelemetry documentation](https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter)
about asynchronous up-down counters.

Args:
    name: The name of the metric.
    callbacks: A sequence of callbacks that return an iterable of
        [Observation](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html#opentelemetry.metrics.Observation).
    unit: The unit of the metric.
    description: The description of the metric.
N)r    Ú!create_observable_up_down_counterrR  s        r‰   Úmetric_up_down_counter_callbackÚ'Logfire.metric_up_down_counter_callback[	  s   € ðR 	�‰×5Ñ5°dÀtÕYrŒ   c                ó6   • U R                   R                  " U6   g)zÈPrevent spans and metrics from being created for the given OpenTelemetry scope names.

To get the scope name of a span/metric,
check the value of the `otel_scope_name` column in the Logfire database.
N)rƒ   Úsuppress_scopes)rˆ   Úscopess     r‰   r_  ÚLogfire.suppress_scopes†	  s   € ð 	�‰×$Ò$ fÒ-rŒ   c                ó   ^^• [        5       mSUU4S jjnU R                  R                  5       R                  U" 5       S9  U" 5       nU(       d  gU(       a*  U R                  R                  U5        U" 5       nU(       d  gU R                  R                  5         U" 5       nU(       d  gU(       a*  U R                  R                  U5        U" 5       nU(       d  gU R                  R                  U5        U" 5       nU(       d  gU" 5       S:„  $ )az  Shut down all tracers and meters.

This will clean up any resources used by the tracers and meters and flush any remaining spans and metrics.

Args:
    timeout_millis: The timeout in milliseconds.
    flush: Whether to flush remaining spans and metrics before shutting down.

Returns:
    `False` if the timeout was reached before the shutdown was completed, `True` otherwise.
c                 óP   >• [        S[        T[        5       T -
  S-  -
  5      5      $ )Nr   iè  )ÚmaxÚintr   )ÚstartrK  s   €€r‰   Úremaining_msÚ&Logfire.shutdown.<locals>.remaining_msœ	  s%   ø€ Ü�qœ#˜n´³¸±À$Ñ/FÑFÓGÓHÐHrŒ   )rK  Fr   )Úreturnre  )r   rz   Úget_variable_providerÚshutdownr‘   rJ  rœ   )rˆ   rK  Úflushrg  Ú	remainingrf  s    `   @r‰   rk  ÚLogfire.shutdownŽ	  sÜ   ù€ ô “ˆ÷	Ið 	Ið 	�‰×)Ñ)Ó+×4Ñ4ÁLÃNÐ4ÑSÙ “Nˆ	ÞØæØ×!Ñ!×-Ñ-¨iÔ8Ù$›ˆIÞØà×Ñ×&Ñ&Ô(Ù “Nˆ	ÞØæØ× Ñ ×,Ñ,¨YÔ7Ù$›ˆIÞØà×Ñ×%Ñ% iÔ0Ù “Nˆ	ÞØá‹~ Ñ!Ð!rŒ   )r>  c               ó   • g r€   rx   )rˆ   rÑ   Údefaultr>  s       r‰   ÚvarÚLogfire.var¼	  s   € ð rŒ   c               ó   • g r€   rx   )rˆ   rÑ   Útyperp  r>  s        r‰   rq  rr  Å	  s   € ð rŒ   )rt  r>  c               ó^  • SSK JnJn  Uc:  U" U5      (       a  [        S5      e[	        [
        [           UR                  5      nOUnSSKnUR                  SU5      (       d  [        SU S35      eXR                  ;   a  [        SU S	35      eU[           " XXpUS
9n	X�R                  U'   U	$ )a^  Define a managed variable.

Managed variables let you externalize runtime configuration from your code,
controlling values from the Logfire UI without redeploying. Use `.get()` on the
returned `Variable` to resolve the current value.

See the [managed variables guide](https://logfire.pydantic.dev/docs/reference/advanced/managed-variables/)
for more details.

```py
import logfire

logfire.configure()

# Simple primitive variable (type inferred from default)
feature_enabled = logfire.var('feature_enabled', default=False)

# Use the variable
with feature_enabled.get(targeting_key='user-123') as resolved:
    if resolved.value:
        ...
```

Args:
    name: Unique identifier for the variable. Must match the name configured in the
        Logfire UI when using remote variables.
    type: Expected type for validation and JSON schema generation. Can be a primitive
        type or a Pydantic model. If not provided, the type is inferred from `default`.
        Required when `default` is a resolve function.
    default: Default value used when no remote configuration is found.
        When `type` is not provided, the type is inferred from this value.
        Can also be a callable with `targeting_key` and `attributes` parameters
        (requires `type` to be set explicitly).
    description: Optional human-readable description of what the variable controls.
r   )rf   Úis_resolve_functionNz™When `default` is a resolve function (callable with targeting_key and attributes parameters), `type` must be provided to specify the variable value type.z^[a-zA-Z_][a-zA-Z0-9_]*$zInvalid variable name 'zq'. Variable names must be valid Python identifiers (letters, digits, and underscores, not starting with a digit).zA variable with name 'zE' has already been registered. Each variable must have a unique name.)rp  rt  Úlogfire_instancer>  )Úlogfire.variables.variablerf   rv  r8  r   r   rt   r9  ÚreÚmatchrð   r‡   )
rˆ   rÑ   rt  rp  r>  rf   rv  Útpry  Úvariables
             r‰   rq  rr  Ï	  sÈ   € ÷V 	Mà‰<Ù" 7×+Ñ+ÜðRóð ô ”dœ1‘g˜w×0Ñ0Ó1‰BàˆBãà�x‰xÐ3°T×:Ñ:ÜØ)¨$¨ð 0.ð .óð ð —?‘?Ó"ÜØ(¨¨Ð.sÐtóð ð œA’;˜t¸2ÐbmÑnˆØ (�‰˜ÑàˆrŒ   c                ó8   • U R                   R                  5         g)a  Clear all registered variables from this Logfire instance.

This removes all variables previously registered via [`var()`][logfire.Logfire.var],
allowing them to be re-registered. This is primarily intended for use in tests
to ensure a clean state between test cases.
N)r‡   ÚclearrŽ   s    r‰   Úvariables_clearÚLogfire.variables_clear
  s   € ð 	�‰×ÑÕrŒ   c                óH   • [        U R                  R                  5       5      $ )z8Get all variables registered with this Logfire instance.)Úlistr‡   ÚvaluesrŽ   s    r‰   Úvariables_getÚLogfire.variables_get"
  s   € ä�D—O‘O×*Ñ*Ó,Ó-Ð-rŒ   ©Údry_runÚyesÚstrictc               ó|   • Uc  U R                  5       nU R                  R                  5       nUR                  XX4S9$ )a=  Push variable definitions (metadata only) to the configured variable provider.

This method syncs local variable definitions with the provider:
- Creates new variables that don't exist in the provider
- Updates JSON schemas for existing variables if they've changed
- Warns about existing label values that are incompatible with new schemas

The provider is determined by the Logfire configuration. For remote providers,
this requires proper authentication (via VariablesOptions or LOGFIRE_API_KEY).

Args:
    variables: Variable instances to push. If None, all variables
        registered with this Logfire instance will be pushed.
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.
    strict: If True, fail if any existing label values are incompatible with new schemas.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.

Example:
    ```python
    import logfire

    feature_enabled = logfire.var(name='feature_enabled', type=bool, default=False)
    max_retries = logfire.var(name='max_retries', type=int, default=3)

    if __name__ == '__main__':
        # Push all registered variables
        logfire.variables_push()

        # Or push specific variables only
        logfire.variables_push([feature_enabled])
    ```
r†  )r„  rz   rj  Úpush_variables)rˆ   Ú	variablesr‡  rˆ  r‰  Úproviders         r‰   Úvariables_pushÚLogfire.variables_push&
  sA   € ðV ÑØ×*Ñ*Ó,ˆIà—;‘;×4Ñ4Ó6ˆØ×&Ñ& yÀsÐ&ÐZÐZrŒ   c               óV   • U R                   R                  5       nUR                  XX4S9$ )a?  Push variable type definitions to the configured variable provider.

Variable types are reusable schema definitions that can be referenced by variables.
They help organize and standardize variable schemas across your project.

This method syncs local Python types with the provider:
- Creates new types that don't exist in the provider
- Updates schemas for existing types if they've changed
- Shows a diff of changes before applying
- Checks if existing variable label values are compatible with the new schemas

The provider is determined by the Logfire configuration. For remote providers,
this requires proper authentication (via VariablesOptions or LOGFIRE_API_KEY).

Args:
    types: Types to push. Items can be:
        - A type (name defaults to __name__ or str(type))
        - A tuple of (type, name) for explicit naming
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.
    strict: If True, abort when existing label values are incompatible with
        the new type schema.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.

Example:
    ```python
    import logfire
    from pydantic import BaseModel


    class FeatureConfig(BaseModel):
        enabled: bool = False
        max_retries: int = 3
        timeout_seconds: float = 30.0


    class UserSettings(BaseModel):
        theme: str = 'light'
        notifications_enabled: bool = True


    if __name__ == '__main__':
        # Push type definitions using their class names
        logfire.variables_push_types([FeatureConfig, UserSettings])

        # Or push with explicit names
        logfire.variables_push_types(
            [
                (FeatureConfig, 'my-feature-config'),
                (UserSettings, 'my-user-settings'),
            ]
        )
    ```
r†  )rz   rj  Úpush_variable_types)rˆ   r   r‡  rˆ  r‰  r�  s         r‰   Úvariables_push_typesÚLogfire.variables_push_typesW
  s-   € ð@ —;‘;×4Ñ4Ó6ˆØ×+Ñ+¨EÈÐ+Ð[Ð[rŒ   c                ó~   • Uc  U R                  5       nU R                  R                  5       nUR                  U5      $ )a  Validate that provider-side variable label values match local type definitions.

This method fetches the current variable configuration from the provider and
validates that all label values can be deserialized to the expected types
defined in the local Variable instances.

Args:
    variables: Variable instances to validate. If None, all variables
        registered with this Logfire instance will be validated.

Returns:
    A ValidationReport containing any errors found. Use `report.is_valid` to check
    if validation passed, and `report.format()` to get a human-readable summary.

Example:
    ```python
    import logfire

    feature_enabled = logfire.var(name='feature_enabled', type=bool, default=False)
    max_retries = logfire.var(name='max_retries', type=int, default=3)

    if __name__ == '__main__':
        # Validate all registered variables
        logfire.variables_validate()

        # Or validate specific variables only
        report = logfire.variables_validate([feature_enabled])
        assert report.is_valid
    ```
)r„  rz   rj  Úvalidate_variables)rˆ   rŒ  r�  s      r‰   Úvariables_validateÚLogfire.variables_validateš
  s<   € ðD ÑØ×*Ñ*Ó,ˆIà—;‘;×4Ñ4Ó6ˆØ×*Ñ*¨9Ó5Ð5rŒ   Úmerge©Úmoder‡  rˆ  c               óV   • U R                   R                  5       nUR                  XX4S9$ )a  Push a VariablesConfig to the configured provider.

This method pushes a complete VariablesConfig (including labels and rollouts)
to the provider. It's useful for:
- Pushing configs generated or modified locally
- Pushing configs read from files
- Partial updates (merge mode) or full replacement (replace mode)

Args:
    config: The VariablesConfig to sync.
    mode: 'merge' updates/creates only variables in config (leaves others unchanged).
          'replace' makes the server match the config exactly (deletes missing variables).
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.

Example:
    ```python skip="true"
    import logfire
    from logfire.variables import VariablesConfig

    # Push config to server
    logfire.variables_push_config(config)

    # Or merge just a subset of variables
    logfire.variables_push_config(config, mode='merge')
    ```
r™  )rz   rj  Úpush_config)rˆ   rz   rš  r‡  rˆ  r�  s         r‰   Úvariables_push_configÚLogfire.variables_push_configÂ
  s-   € ðL —;‘;×4Ñ4Ó6ˆØ×#Ñ# F¸wÐ#ÐPÐPrŒ   c                óV   • U R                   R                  5       nUR                  5       $ )a¿  Pull the current variable configuration from the provider.

This method fetches the complete configuration from the provider,
useful for generating local copies of the config that can be modified.

Returns:
    The current VariablesConfig from the provider.

Example:
    ```python skip="true"
    import logfire

    # Pull config from the provider
    config = logfire.variables_pull_config()
    print(config.model_dump_json(indent=2))
    ```
)rz   rj  Úpull_config)rˆ   r�  s     r‰   Úvariables_pull_configÚLogfire.variables_pull_configë
  s%   € ð$ —;‘;×4Ñ4Ó6ˆØ×#Ñ#Ó%Ð%rŒ   c                óX   • Uc  U R                  5       nSSKJn  UR                  " U5      $ )aú  Build a VariablesConfig from registered Variable instances.

This creates a minimal config with just the name, schema, and example for each variable.
No labels or versions are created - use this to build a template config that can be edited.

Args:
    variables: Variable instances to include. If None, uses all registered variables.

Returns:
    A VariablesConfig with minimal configs for each variable.

Example:
    ```python skip="true"
    import logfire

    feature_enabled = logfire.var(name='feature_enabled', type=bool, default=False)
    max_retries = logfire.var(name='max_retries', type=int, default=3)

    # Build config from registered variables
    config = logfire.variables_build_config()
    print(config.model_dump_json(indent=2))
    ```
r   )rg   )r„  Úlogfire.variables.configrg   Úfrom_variables)rˆ   rŒ  rg   s      r‰   Úvariables_build_configÚLogfire.variables_build_config   s,   € ð6 ÑØ×*Ñ*Ó,ˆIå<à×-Ò-¨iÓ8Ð8rŒ   )rƒ   r…   r†   r„   r‚   r‡   )rz   r)   r{   zfloat | Noner|   úSequence[str]r}   Úboolr~   r0  ri  ÚNone)ri  r)   )ri  zMapping[str, Any])ri  rA   )ri  r?   )ri  rC   )r¤   r©  ri  rC   )rÅ   r0  r“   údict[str, Any]r‚   úSequence[str] | Noner°   ú
str | Noner±   zLevelName | int | Noner²   ú3Sequence[tuple[SpanContext, otel_types.Attributes]]r³   r   ri  rÃ   )rÑ   r0  r“   úotel_types.AttributesrÔ   r   ri  rÓ   )
rÑ   r0  r“   ú$dict[str, otel_types.AttributeValue]rÙ   r«  rÔ   r   ri  rÓ   )
rÅ   r0  r‚   r¬  rÜ   ÚExcInfor“   r   ri  rª  )rÅ   r0  r‚   r¬  r°   r­  r±   zLevelName | Noner²   r®  r³   r   r“   r   ri  rÃ   r€   )rÅ   zLiteralString | Noner  r­  r  úbool | Iterable[str]r  r©  r   r©  r!  r©  ri  z*Callable[[Callable[P, R]], Callable[P, R]])r(  úCallable[P, R]ri  r³  )rÅ   z%Callable[P, R] | LiteralString | Noner  r­  r  r²  r  r©  r   r©  r!  r©  ri  z;Callable[[Callable[P, R]], Callable[P, R]] | Callable[P, R])NNFN)r<  úLevelName | intrÅ   r0  r“   zdict[str, Any] | Noner|   r¬  rí   r±  r}   úbool | Noneri  rª  )r|   r0  ri  rv   )r{   Úfloatri  rv   )r|   r¨  r}   rµ  rF  r­  ri  rv   )i¸  )rK  re  ri  r©  )rT  zEvaluationReport[Any, Any, Any]ri  r­  )gš™™™™™¹?)rZ  r¶  ri  úAbstractContextManager[None])r`  z1Sequence[str] | Callable[[AutoTraceModule], bool]r_  r¶  r]  z"Literal['error', 'warn', 'ignore']ri  rª  )rh  zNSyncTemplate | AsyncTemplate | type[SyncTemplate] | type[AsyncTemplate] | Noneri  rª  )rj  r©  ri  rª  )ri  r·  )Úallrx   rx   )rw  r*   rx  úIterable[str]ry  r¹  ri  rª  )rh  zpydantic_ai.Agent | Noner�  rµ  r‚  rµ  rƒ  úLiteral[1, 2, 3] | Noner„  ú$Literal['attributes', 'logs'] | NonerÔ   r   ri  rª  )rh  úpydantic_ai.models.Modelr�  rµ  r‚  rµ  rƒ  rº  r„  r»  rÔ   r   ri  r¼  )rh  z3pydantic_ai.Agent | pydantic_ai.models.Model | Noner�  rµ  r‚  rµ  rƒ  rº  r„  r»  rÔ   r   ri  zpydantic_ai.models.Model | None)r•  rM   r�  r©  rŽ  zMCallable[[Request | WebSocket, dict[str, Any]], dict[str, Any] | None] | Noner�  zstr | Iterable[str] | Noner�  r©  r‘  r©  r–  r   ri  r·  )r©  zZopenai.OpenAI | openai.AsyncOpenAI | type[openai.OpenAI] | type[openai.AsyncOpenAI] | Noner˜  r©  rƒ  ú)SemconvVersion | Sequence[SemconvVersion]ri  r·  )ri  rª  )rº  züanthropic.Anthropic | anthropic.AsyncAnthropic | anthropic.AnthropicBedrock | anthropic.AsyncAnthropicBedrock | type[anthropic.Anthropic] | type[anthropic.AsyncAnthropic] | type[anthropic.AnthropicBedrock] | type[anthropic.AsyncAnthropicBedrock] | Noner˜  r©  rƒ  r½  ri  r·  )rÔ   r   )rÔ   r   ri  rª  )rÛ  zhttpx.ClientrÔ  r©  r�  r©  rÕ  r©  rÖ  r©  r×  úHttpxRequestHook | NonerØ  úHttpxResponseHook | NonerÔ   r   ri  rª  )rÛ  zhttpx.AsyncClientrÔ  r©  r�  r©  rÕ  r©  rÖ  r©  r×  ú/HttpxRequestHook | HttpxAsyncRequestHook | NonerØ  ú1HttpxResponseHook | HttpxAsyncResponseHook | NonerÔ   r   ri  rª  )rÛ  rª  rÔ  r©  r�  r©  rÕ  r©  rÖ  r©  r×  r¾  rØ  r¿  rá  úHttpxAsyncRequestHook | Nonerâ  úHttpxAsyncResponseHook | NonerÔ   r   ri  rª  )rÛ  z'httpx.Client | httpx.AsyncClient | NonerÔ  rµ  r�  r©  rÕ  r©  rÖ  r©  r×  rÀ  rØ  rÁ  rá  rÂ  râ  rÃ  rÔ   r   ri  rª  )FNNNN)r�  r©  rì  rµ  r×  z4Callable[[trace_api.Span, HttpRequest], None] | NonerØ  zBCallable[[trace_api.Span, HttpRequest, HttpResponse], None] | Noner�  r­  rÔ   r   ri  rª  )NNN)
r�  r­  r×  z7Callable[[Span, requests.PreparedRequest], None] | NonerØ  zJCallable[[Span, requests.PreparedRequest, requests.Response], None] | NonerÔ   r   ri  rª  )rô  z&PsycopgConnection | Psycopg2ConnectionrÔ   r   ri  rª  )NFN)
rô  z2None | Literal['psycopg', 'psycopg2'] | ModuleTyperø  r©  rù  úPsycopgCommenterOptions | NonerÔ   r   ri  rª  )
rô  r   rø  r©  rù  rÄ  rÔ   r   ri  rª  )r•  rN   r�  r©  rø  r©  rù  zFlaskCommenterOptions | Noner�  r­  r×  zFlaskRequestHook | NonerØ  zFlaskResponseHook | NonerÔ   r   ri  rª  )r•  rY   r�  r©  r�  r©  r  zServerRequestHook | Noner  zClientRequestHook | Noner  zClientResponseHook | NonerÔ   r   ri  rª  )FF)
r•  rh   r�  r©  r�  r©  rÔ   zUnpack[ASGIInstrumentKwargs]ri  rh   )FNN)r•  rJ   r�  r©  r×  zWSGIRequestHook | NonerØ  zWSGIResponseHook | NonerÔ   r   ri  rJ   )rÔ  rµ  r�  r©  rÕ  r©  rÖ  r©  r×  zAiohttpClientRequestHook | NonerØ  z AiohttpClientResponseHook | NonerÔ   r   ri  rª  )r  zAsyncEngine | Engine | Noner  z%Iterable[AsyncEngine | Engine] | Nonerø  r©  rù  z!SQLAlchemyCommenterOptions | NonerÔ   r   ri  rª  )r   rp   rÔ   r   ri  rp   )r%  rk   r&  z'Callable[[LambdaEvent], Context] | NonerÔ   r   ri  rª  )FNNN)r+  r©  r×  z2Callable[[Span, CommandStartedEvent], None] | NonerØ  z4Callable[[Span, CommandSucceededEvent], None] | Noner,  z1Callable[[Span, CommandFailedEvent], None] | NonerÔ   r   ri  rª  )
r+  r©  r×  zRedisRequestHook | NonerØ  zRedisResponseHook | NonerÔ   r   ri  rª  )r   rm   rÔ   r   ri  rm   )NÚbasic)rz   zSystemMetricsConfig | Noner:  ÚSystemMetricsBaseri  rª  )rÑ   r0  r=  r0  r>  r0  ri  r   )rÑ   r0  r=  r0  r>  r0  ri  r   )rÑ   r0  r=  r0  r>  r0  ri  ÚGauge)rÑ   r0  r=  r0  r>  r0  ri  r   )
rÑ   r0  rS  zSequence[CallbackT]r=  r0  r>  r0  ri  rª  )r`  r0  ri  rª  )i0u  T)rK  re  rl  r©  ri  r©  )rÑ   r0  rp  rt   r>  r­  ri  úVariable[T])
rÑ   r0  rt  ztype[T]rp  úT | ResolveFunction[T]r>  r­  ri  rÈ  )
rÑ   r0  rt  ztype[T] | Nonerp  rÉ  r>  r­  ri  rÈ  )ri  zlist[Variable[Any]])
rŒ  úlist[Variable[Any]] | Noner‡  r©  rˆ  r©  r‰  r©  ri  r©  )
r   z+Sequence[type[Any] | tuple[type[Any], str]]r‡  r©  rˆ  r©  r‰  r©  ri  r©  )rŒ  rÊ  ri  re   )
rz   rg   rš  zLiteral['merge', 'replace']r‡  r©  rˆ  r©  ri  r©  )ri  rg   )rŒ  rÊ  ri  rg   )^r:  Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r(   rŠ   Úpropertyrz   r”   r
   r‘   rœ   r    r§   rª   r¦   r   ÚINTERNALrÎ   rÖ   rÚ   rë   rø   rý   r  r  r  r  r  r  rÕ   r   r9   rñ   rA  rD  r@  rJ  rV  r[  r'   rc  rf  rl  rp  r  r‡  r“  r«  r±  r»  r¾  rÂ  rÆ  rÊ  rÎ  rÜ  rç  rë  rð  rõ  rþ  r  r	  r  r  r  r  r  r$  r*  r0  r4  r8  rB  rF  rJ  rN  rT  rX  r\  r_  rk  rq  r  r„  rŽ  r’  r–  r�  r¡  r¦  Ú__static_attributes__rx   rŒ   r‰   rv   rv   �   sW  † Ù!ð
 !.Ø$(Ø Ø Ø#ñ7ð ð7ð "ð	7ð
 ð7ð ð7ð ð7ð 
õ7ð  óó ðð ó9ó ð9ð ó2ó ð2ð ó1ó ð1ð ñIó ðIð ó6ó ð6ð ó5ó ð5ô
ð '+Ø!%Ø)-ØFHØ'×0Ñ0ñEàðEð #ðEð
 $ðEð ðEð 'ðEð DðEð ðEð 
õEôN
ðØðØ%IðØZhðØtwðà	ôð0 '+Ø"ñTàðTð
 $ðTð ðTð ðTð 
õTðJ '+Ø"ñTàðTð
 $ðTð ðTð ðTð 
õTðJ '+Ø"ñSàðSð
 $ðSð ðSð ðSð 
õSðJ '+Ø"ñUàðUð
 $ðUð ðUð ðUð 
õUðJ '+Ø"ñ Sàð Sð
 $ð Sð ð Sð ð Sð 
õ SðD €Dð '+Ø"ñTàðTð
 $ðTð ðTð ðTð 
õTðJ '+Ø"ñTàðTð
 $ðTð ðTð ðTð 
õTðJ '+Ø!ñTàðTð
 $ðTð ðTð ðTð 
õTð: '+Ø!%Ø#'ØFHØ'×0Ñ0ñ.
àð.
ð
 $ð.
ð ð.
ð !ð.
ð Dð.
ð ð.
ð ð.
ð 
õ.
ð` ð .2ð"ð !%Ø-1Ø#Ø %Øñ"à*ð"ð ð	"ð
 +ð"ð ð"ð ð"ð ð"ð 
4õ"ó ð"ðH óó ðð" ?Cð'
ð !%Ø-1Ø#Ø %Øñ'
à;ð'
ð ð	'
ð
 +ð'
ð ð'
ð ð'
ð ð'
ð 
Eö'
ðZ -1Ø%)Ø!Ø#'ðu!àðu!ð ðu!ð *ð	u!ð
 #ðu!ð ðu!ð !ðu!ð 
õu!ôn-ô.
ð( !Ø#'Ø*.ñ
ð ð
ð !ð	
ð
 (ð
ð 
õ
ö>	8ôZö >ð, FMñ&vàBð&vð ð	&vð
 !Cð&vð 
õ&vòPSð eið(Øað(à	õ(ð @D÷ 5ô 1ð( .3Ø!#Ø!#ð	/
à*ð/
ð ð/
ð ð	/
ð
 
õ/
ðb ð )-ð
ð
 /3Ø'+Ø+/Ø;?ñ
à%ð
ð
 !,ð
ð %ð
ð )ð
ð 9ð
ð ð
ð 
õ
ó ð
ð ð /3Ø'+Ø+/Ø;?ñ
'à%ð
'ð
 !,ð
'ð %ð
'ð )ð
'ð 9ð
'ð ð
'ð 
"ô
'ó ð
'ð DHð4
ð
 /3Ø'+Ø+/Ø;?ñ4
à@ð4
ð
 !,ð4
ð %ð4
ð )ð4
ð 9ð4
ð ð4
ð 
)ö4
ðt !&ð Ø48Ø$)Ø!ñH
àðH
ð ð	H
ð
$ðH
ð 2ðH
ð "ðH
ð ðH
ð  !$ð!H
ð" 
&õ#H
ð` ðZ
ð 04Ø=>ñZ
ððZ
ð )-ðZ
ð ;ðZ
ð 
&öZ
ôx
2ð0 ða
ð 04Ø=>ña
ðða
ð )-ða
ð ;ða
ð  
&ö!a
ôF0ô +ô 
(ô&ô.
ð ð
 "Ø %Ø%*Ø&+Ø04Ø26ñàðð ð	ð
 ðð #ðð  $ðð .ðð 0ðð ðð 
ôó ðð ð
 "Ø %Ø%*Ø&+ØHLØKOñà!ðð ð	ð
 ðð #ðð  $ðð Fðð Iðð ðð 
ôó ðð ð ðð "Ø %Ø%*Ø&+Ø04Ø26Ø;?Ø=Añàðð ð	ð
 ðð #ðð  $ðð .ðð 0ðð 9ðð ;ðð ðð 
õó ðð" ;?ð6
ð $(Ø %Ø%*Ø&+ØHLØKOØ;?Ø=Añ6
à7ð6
ð !ð	6
ð
 ð6
ð #ð6
ð  $ð6
ð Fð6
ð Ið6
ð 9ð6
ð ;ð6
ð ð6
ð 
ö6
ôp
ð: !&Ø04ØMQØ\`Ø$(ð5
àð5
ð #.ð5
ð Kð	5
ð
 Zð5
ð "ð5
ð ð5
ð 
õ5
ðr %)ØPTØdhð	
à!ð
ð Nð
ð bð	
ð
 ð
ð 
õ
ð: Ûtó Øtàð NRØ!&Ø<@ð	àJðð ðð :ð	ð
 ðð 
ôó ðð #Ø!&Ø<@ð	 Qàð Qð ð Qð :ð	 Qð
 ð Qð 
õ QðL !&Ø!%Ø:>Ø$(Ø04Ø26ñ-
àð-
ð ð	-
ð
 ð-
ð 8ð-
ð "ð-
ð .ð-
ð 0ð-
ð ð-
ð 
õ-
ðf !&Ø$)Ø8<Ø8<Ø:>ñ*
àð*
ð ð	*
ð
 "ð*
ð 6ð*
ð 6ð*
ð 8ð*
ð ð*
ð 
õ*
ð^ !&Ø$)ð	%
àð%
ð ð%
ð "ð	%
ð
 /ð%
ð 
õ%
ðT !&Ø/3Ø15ð'
àð'
ð ð'
ð -ð	'
ð
 /ð'
ð ð'
ð 
õ'
ðX $(Ø %Ø%*Ø&+Ø8<Ø:>ñ
ð !ð
ð ð	
ð
 #ð
ð  $ð
ð 6ð
ð 8ð
ð ð
ð 
õ
ô>
ð( /3Ø9=Ø!&Ø?Cð"
à+ð"
ð 7ð"
ð ð	"
ð
 =ð"
ð ð"
ð 
õ"
öHrð, LPð
à%ð
ð "Ið
ð ð	
ð
 
õ
ð@ #(ØKOØNRØIMð"
àð"
ð Ið"
ð Lð	"
ð
 Gð"
ð ð"
ð 
õ"
ðL #(Ø04Ø26ð	
àð
ð .ð
ð 0ð	
ð
 ð
ð 
õ
öB
ð6 T[ð=Ø0ð=Ø?Pð=à	õ=ð$ 8:Èb÷ Cð< :<ÐPR÷ Eð8 68ÈB÷ Að8 @BÐVX÷  KðN Øñ0Ràð0Rð 'ð	0Rð
 ð0Rð ð0Rð 
õ0Rðf IKÐ_añ)PØð)PØ$7ð)PØBEð)PØY\ð)Pà	õ)PðX IKÐ_añ)ZØð)ZØ$7ð)ZØBEð)ZØY\ð)Zà	õ)ZôV.ö,"ð\ ð #'ñàðð ð	ð
  ðð 
ôó ðð ð #'ñàðð ð	ð
 (ðð  ðð 
ôó ðð  $à"&ñHàðHð ð	Hð
 (ðHð  ðHð 
õHôT ô.ð 15ð/[ð ØØñ/[à-ð/[ð ð	/[ð
 ð/[ð ð/[ð 
ö/[ðj ØØñA\à:ðA\ð ð	A\ð
 ðA\ð ðA\ð 
õA\ðJ 15ð&6à-ð&6ð 
õ&6ðX -4ØØñ'Qàð'Qð *ð	'Qð
 ð'Qð ð'Qð 
õ'QôR&ð. 15ð 9à-ð 9ð 
÷ 9ð  9rŒ   rv   c                  óD   • \ rS rSrSrSrSS jrS	S jr\S
S j5       r	Sr
g)rÓ   i#  z=A simple version of `LogfireSpan` optimized for auto-tracing.)rÎ   Ú_tokenc                ó‚   • Xl         [        R                  " [        R                  " U R                   5      5      U l        g r€   )rÎ   Úcontext_apiÚattachÚ	trace_apiÚset_span_in_contextrÓ  )rˆ   rÕ   s     r‰   rŠ   ÚFastLogfireSpan.__init__(  s(   € ØŒ
Ü!×(Ò(¬×)FÒ)FÀtÇzÁzÓ)RÓSˆ�rŒ   c                ó   • U $ r€   rx   rŽ   s    r‰   Ú	__enter__ÚFastLogfireSpan.__enter__,  ó   € ØˆrŒ   c                ó|   • [         R                  " U R                  5        U R                  R	                  XU5        g r€   )rÕ  ÚdetachrÓ  rÎ   Ú__exit__©rˆ   Úexc_typeÚ	exc_valueÚ	tracebacks       r‰   rà  ÚFastLogfireSpan.__exit__/  s(   € ä×Ò˜4Ÿ;™;Ô'Ø�
‰
×Ñ˜H°Õ;rŒ   N)rÕ   ztrace_api.Spanri  rª  )ri  rÓ   ©râ  ztype[BaseException] | Nonerã  zBaseException | Nonerä  r   ri  rª  )r:  rË  rÌ  rÍ  rÎ  Ú	__slots__rŠ   rÛ  rF   rà  rÑ  rx   rŒ   r‰   rÓ   rÓ   #  s)   † ÙGà#€IôTôð ó<ó ó<rŒ   rÓ   c                  óØ  • \ rS rSr\R
                  4             SS jjr\(       d  SS jr\	S 5       r
\	S 5       rSS jr\	S 5       rS r\	SS	 j5       r\SS
 j5       r\SS j5       r\R&                  \	SS j5       5       r\S S j5       r\R&                  S!S j5       r\	S"S j5       rS#S jrS$S%S jjr   S&         S'S jjrS(S jr\	S)S j5       rS*S jrS"S jrSrg)+rÃ   i6  c                ó˜   • Xl         X l        X0l        X@l        [	        S U 5       5      U l        X`l        SU l        S U l        S U l	        g )Nc              3  óN   #   • U  H  u  p[         R                  " XS 9v •  M     g7f)©Úcontextr“   N)r×  ÚLink)rä   rì  r“   s      r‰   ræ   Ú'LogfireSpan.__init__.<locals>.<genexpr>D  s   é € ÐsÒmrÑViÐV]œ9Ÿ>š>°'ÖQÒmrùs   ‚#%F)
r°   Ú_otlp_attributesÚ_tracerÚ_json_schema_propertiesr‚  r²   r³   Ú_added_attributesrÓ  rÎ   )rˆ   r  rÌ   ÚtracerrÍ   r·   r¸   s          r‰   rŠ   ÚLogfireSpan.__init__7  sH   € ð $ŒØ /ÔØŒØ'=Ô$ÜÑsÑmrÓsÓsˆŒØ#Œà!&ˆÔØ-1ˆŒØ15ˆ�
rŒ   c                ó.   • [        U R                  U5      $ r€   )ÚgetattrrÎ   )rˆ   rÑ   s     r‰   Ú__getattr__ÚLogfireSpan.__getattr__M  s   € Ü˜4Ÿ:™: tÓ,Ð,rŒ   c                ó²   • U R                   b  g U R                  R                  U R                  U R                  U R
                  U R                  S9U l         g )N)rÑ   r“   r·   Úkind)rÎ   rð  rÒ   r°   rï  r²   r³   rŽ   s    r‰   Ú_startÚLogfireSpan._startP  sH   € à�:‰:Ñ!ØØ—\‘\×,Ñ,Ø—‘Ø×,Ñ,Ø—+‘+Ø—‘ð	 -ð 
ˆ�
rŒ   c                ó>  • U R                   b  g U R                  nS o!ULo3(       dº  [        R                  " SU4SX45      S[        R
                  " 5       ;   d  [        R                  " U 5      (       a  [        R                  " U 5      OS[        R                  " U5      [        R                  " U5      S.-  nSSU0-  n[        [        R                  " U5      5      eS =n=p2[        R                  " [        R                  " U R                  5      5      U l         g )N)úis not)z1%(py2)s
{%(py2)s = %(py0)s._span
} is not %(py5)srˆ   )Úpy0Úpy2Úpy5zassert %(py7)sÚpy7)rÓ  rÎ   Ú
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanationrÕ  rÖ  r×  rØ  )rˆ   Ú@py_assert1Ú@py_assert4Ú@py_assert3Ú@py_format6Ú@py_format8s         r‰   Ú_attachÚLogfireSpan._attach[  sŸ   € à�;‰;Ñ"ØØ�z‰zÐ% Ð% Ð%×%×%×%Ò%ˆz×%×%×%×%×%Õ%ˆt×%×%×%Ñ%ˆt×%×%Õ%ˆz×%×%Ó% ×%×%×%×%×%×%Ó%Ü!×(Ò(¬×)FÒ)FÀtÇzÁzÓ)RÓSˆ�rŒ   c                óF   • U R                  5         U R                  5         U $ r€   )rû  r  rŽ   s    r‰   rÛ  ÚLogfireSpan.__enter__b  s   € Ø�‰ŒØ�‰ŒØˆrŒ   c                ó"  • U R                   (       a  U R                   R                  5       (       d  g U R                  (       a3  U R                   R                  [        [        U R                  5      5        U R                   R                  5         g r€   )rÎ   r3  rò  Úset_attributer+   r<   rñ  r;  rŽ   s    r‰   Ú_endÚLogfireSpan._endg  sW   € à�z�z §¡×!8Ñ!8×!:Ñ!:ØØ×!×!Ø�J‰J×$Ñ$Ô%?ÔAWÐX\×XtÑXtÓAuÔvØ�
‰
�‰ÕrŒ   c                ón   • U R                   c  g [        R                  " U R                   5        S U l         g r€   )rÓ  rÕ  rß  rŽ   s    r‰   Ú_detachÚLogfireSpan._detacho  s(   € Ø�;‰;ÑØÜ×Ò˜4Ÿ;™;Ô'Øˆ�rŒ   c                ó  • U R                  5         U R                  (       aN  U R                  R                  5       (       a/  [        U[        5      (       a  U R                  R                  USS9  U R                  5         g )NT)Úescaped)r  rÎ   r3  r5  r6  r7  r  rá  s       r‰   rà  ÚLogfireSpan.__exit__u  sP   € à�‰ŒØ�:�:˜$Ÿ*™*×1Ñ1×3Ñ3¼
À9Ìm×8\Ñ8\Ø�J‰J×'Ñ'¨	¸4Ð'Ñ@Ø�	‰	�rŒ   c                ó.   • U R                  [        S 5      $ r€   )Ú_get_attributer.   rŽ   s    r‰   Úmessage_templateÚLogfireSpan.message_template|  s   € à×"Ñ"Ô#BÀDÓIÐIrŒ   c                ó.   • U R                  [        S5      $ ©Nrx   )r  r1   rŽ   s    r‰   r|   ÚLogfireSpan.tags€  s   € à×"Ñ"Ô#6¸Ó;Ð;rŒ   c                ó„   • [        U[        5      (       a  U4nU R                  [        [	        [        U5      5      5        g)zSet or add tags to the span.N)r5  r0  Ú_set_attributer1   r�   rH   ©rˆ   Únew_tagss     r‰   r|   r$  „  s4   € ô �h¤×$Ñ$Ø �{ˆHØ×ÑÔ/´Ô7HÈÓ7RÓ1SÕTrŒ   c                óB   • U R                  [        U R                  5      $ r€   )r  r-   r°   rŽ   s    r‰   ÚmessageÚLogfireSpan.messageŒ  s   € à×"Ñ"Ô#9¸4¿?¹?ÓKÐKrŒ   c                ó0   • U R                  [        U5        g r€   )r&  r-   ©rˆ   r*  s     r‰   r*  r+  �  s   € à×ÑÔ2°GÕ<rŒ   c                óØ   • SU l         [        U[        5       5      U R                  U'   [	        U5      =o0R
                  U'   U R                  b  U R                  R                  X5        gg)zpSets an attribute on the span.

Args:
    key: The key of the attribute.
    value: The value of the attribute.
TN)rò  r>   r~  rñ  Úprepare_otlp_attributerï  rÎ   r  )rˆ   ÚkeyÚvalueÚ
otel_values       r‰   r  ÚLogfireSpan.set_attribute”  s^   € ð "&ˆÔÜ,>¸uÄcÃeÓ,Lˆ×$Ñ$ SÑ)Ü2HÈÓ2OÐOˆ
×*Ñ*¨3Ñ/Ø�:‰:Ñ!Ø�J‰J×$Ñ$ SÕ5ð "rŒ   c                óX   • UR                  5        H  u  p#U R                  X#5        M     g)z&Sets the given attributes on the span.N)Úitemsr  )rˆ   r“   r0  r1  s       r‰   Úset_attributesÚLogfireSpan.set_attributes¢  s%   € à$×*Ñ*Ö,‰JˆCØ×Ñ˜sÖ*ò -rŒ   Nc                ó¦   • U R                   c)  U =R                  [        R                  " XS9/-  sl        g U R                   R	                  X5        g )Nrë  )rÎ   r²   r×  rí  Úadd_link)rˆ   rì  r“   s      r‰   r9  ÚLogfireSpan.add_link§  s8   € Ø�:‰:ÑØ�KŠKœIŸNšN°7ÑRÐSÑSŽKà�J‰J×Ñ Õ4rŒ   c                ól   • U R                   c  [        S5      eU R                   R                  UUUUS9  g)zjRecords an exception as a span event.

Delegates to the OpenTelemetry SDK `Span.record_exception` method.
NzSpan has not been started)r“   Ú	timestampr  )rÎ   r|  r7  )rˆ   r  r“   r<  r  s        r‰   r7  ÚLogfireSpan.record_exception®  s=   € ð �:‰:ÑÜÐ:Ó;Ð;à�
‰
×#Ñ#ØØ!ØØð	 	$ò 	
rŒ   c                ó`   • U R                   S L=(       a    U R                   R                  5       $ r€   )rÎ   r3  rŽ   s    r‰   r3  ÚLogfireSpan.is_recordingÃ  s#   € Ø�z‰z Ð%×C¨$¯*©*×*AÑ*AÓ*CÐCrŒ   c                ó¢   • [        U5      nU R                  c  U R                  R                  U5        gU R                  R	                  U5        g)zSet the log level of this span.N)r6   rÎ   rï  rÀ   r6  )rˆ   r<  r“   s      r‰   Ú	set_levelÚLogfireSpan.set_levelÆ  s>   € ô *¨%Ó0ˆ
Ø�:‰:ÑØ×!Ñ!×(Ñ(¨Õ4à�J‰J×%Ñ% jÕ1rŒ   c                óf   • [        U R                  SU R                  5      nUR                  X5      $ )Nr“   )rö  rÎ   rï  Úget)rˆ   r0  rp  r“   s       r‰   r  ÚLogfireSpan._get_attributeÏ  s)   € Ü˜TŸZ™Z¨°t×7LÑ7LÓMˆ
Ø�~‰~˜cÓ+Ð+rŒ   c                ór   • U R                   c  X R                  U'   gU R                   R                  X5        g)zSSet an attribute on the span or in the _otlp_attributes if span is not yet created.N)rÎ   rï  r  )rˆ   r0  r1  s      r‰   r&  ÚLogfireSpan._set_attributeÓ  s,   € à�:‰:ÑØ).×!Ñ! #Ò&à�J‰J×$Ñ$ SÕ0rŒ   )	rò  rñ  r²   rï  rÎ   r³   r°   rÓ  rð  )r  r0  rÌ   r°  ró  rC   rÍ   r;   r·   r®  r¸   r   ri  rª  )rÑ   r0  ri  r   )ri  rÃ   ræ  )ri  r­  ©ri  ztuple[str, ...]©r(  r¨  ri  rª  ©ri  r0  ©r*  r0  )r0  r0  r1  r   ri  rª  )r“   r«  ri  rª  r€   )rì  r   r“   r¯  ri  rª  )NNF)
r  r6  r“   r¯  r<  z
int | Noner  r©  ri  rª  ©ri  r©  )r<  r´  )r0  r0  rp  r   ri  r   )r:  rË  rÌ  rÍ  r   rÐ  rŠ   r   r÷  rF   rû  r  rÛ  r  r  rà  rÏ  r   r|   Úsetterr*  r  r6  r9  r7  r3  rA  r  r&  rÑ  rx   rŒ   r‰   rÃ   rÃ   6  s¹  † ð '×/Ñ/ð6àð6ð >ð6ð ð	6ð
 !5ð6ð Cð6ð ð6ð 
õ6ö( ô	-ð ñ
ó ð
ð ñTó ðTôð
 ñó ðòð óó ðð óJó ðJð ó<ó ð<ð 
‡[�[ØóUó ó ðUð óLó ðLð ‡^�^ó=ó ð=ð ó6ó ð6ô+ö
5ð -1Ø $Øð
à ð
ð *ð
ð ð	
ð
 ð
ð 
õ
ô*Dð ó2ó ð2ô,÷1rŒ   rÃ   c                  óÖ   • \ rS rSrSrSS jrSS jrSS jrSS jr\	SS j5       r
\	SS j5       r\R                  SS	 j5       r\	SS
 j5       r\R                  SS j5       rSS jrSrg)rº   iÛ  a  Implements the same methods as `LogfireSpan` but does nothing.

Used in place of `LogfireSpan` and `FastLogfireSpan` when an exception occurs during span creation.
This way code like:

    with logfire.span(...) as span:
        span.set_attribute(...)

doesn't raise an error even if `logfire.span` fails internally.
If `logfire.span` just returned `None` then the `with` block and the `span.set_attribute` call would raise an error.

TODO this should also be used when tracing is disabled, e.g. before `logfire.configure()` has been called.
c                ó   • g r€   rx   )rˆ   Ú_argsÚ_NoopSpan__kwargss      r‰   rŠ   ÚNoopSpan.__init__ê  ó   € ØrŒ   c                ó   • S $ )Nc                 ó   • g r€   rx   )rP  rQ  s     r‰   Ú<lambda>Ú&NoopSpan.__getattr__.<locals>.<lambda>ï  s   € ¨$rŒ   rx   )rˆ   Ú_names     r‰   r÷  ÚNoopSpan.__getattr__í  s   € á.Ð.rŒ   c                ó   • U $ r€   rx   rŽ   s    r‰   rÛ  ÚNoopSpan.__enter__ñ  rÝ  rŒ   c                ó   • g r€   rx   rá  s       r‰   rà  ÚNoopSpan.__exit__ô  rS  rŒ   c                ó   • g©Nr<  rx   rŽ   s    r‰   r   ÚNoopSpan.message_templateø  ó   € àrŒ   c                ó   • gr#  rx   rŽ   s    r‰   r|   ÚNoopSpan.tagsü  ra  rŒ   c                ó   • g r€   rx   r'  s     r‰   r|   rc    ó   € àrŒ   c                ó   • gr_  rx   rŽ   s    r‰   r*  ÚNoopSpan.message  ra  rŒ   c                ó   • g r€   rx   r-  s     r‰   r*  rg  
  re  rŒ   c                ó   • g)NFrx   rŽ   s    r‰   r3  ÚNoopSpan.is_recording  s   € ØrŒ   rx   N)rP  r   rQ  r   ri  rª  )rX  r0  ri  r   )ri  rº   ræ  rJ  rH  rI  rK  rL  )r:  rË  rÌ  rÍ  rÎ  rŠ   r÷  rÛ  rà  rÏ  r   r|   rM  r*  r3  rÑ  rx   rŒ   r‰   rº   rº   Û  sŒ   † ñôô/ôôð óó ðð óó ðð 
‡[�[óó ðð óó ðð ‡^�^óó ð÷rŒ   rº   ÚAttributesValueType)Úboundc                ól   • U R                  5        VVs0 s H  u  pU[        U5      _M     snn$ s  snnf )ztPrepare attributes for sending to OpenTelemetry.

This will convert any non-OpenTelemetry compatible types to JSON.
)r5  r/  )r“   r0  r1  s      r‰   rÁ   rÁ     s6   € ð
 BL×AQÑAQÔASÔTÒAS±:°3ˆCÔ'¨Ó.Ò.ÑASÒTÐTùÓTs   ”0c                ó@  • [        U [        5      (       a  [        U 5      $ [        U [        5      (       a=  U [        :”  a1  [
        R                  " SU  S[         S3[        5        [        U 5      $ U $ [        U [        [        [        45      (       a  U $ [        U 5      $ )z=Convert a user attribute to an OpenTelemetry compatible type.zInteger value z1 is larger than the maximum OTLP integer size of z[ (64-bits),  if you need support for sending larger integers, please open a feature request)r5  r	   r:   re  r4   Úwarningsr  ÚUserWarningr0  r©  r¶  )r1  s    r‰   r/  r/    s‘   € ä�%œ×ÑÜ! %Ó(Ð(Ü	�Eœ3×	Ñ	ØÔ$Ó$Ü�MŠMØ   Ð'XÔYjÐXkð lbð bäôô
 �u“:ÐàˆLÜ	�EœC¤¤uÐ-×	.Ñ	.Øˆä! %Ó(Ð(rŒ   c                ó<  • U R                  5       (       d  g [        U5      n[        U5      =n(       aÇ  [        0 5      nU R                  =(       d    0 R                  [        5      nU(       aj  [        U[        5      (       aU  [        R                  " [        R                  5         [        R                  " U5      nUR                  S0 5      nS S S 5        UR                  U5        [        U5      U[        '   U R!                  U5        g ! , (       d  f       NC= f)NÚ
properties)r3  rÁ   r=   r;   r“   rD  r+   r5  r0  Ú
contextlibÚsuppressÚjsonÚJSONDecodeErrorÚloadsrÀ   r<   r6  )rÕ   r“   rÌ   rÍ   Úexisting_propertiesÚexisting_json_schema_strÚexisting_json_schemas          r‰   Úset_user_attributes_on_raw_spanr{  1  sÚ   € Ø×Ñ×ÑØä-¨jÓ9€OÜ!BÀ:Ó!NÐNÐÕNÜ2°2Ó6ÐØ$(§O¡O×$9°r×#>Ñ#>Ô?YÓ#ZÐ Þ#¬
Ð3KÌS×(QÑ(QÜ×$Ò$¤T×%9Ñ%9Õ:Ü'+§z¢zÐ2JÓ'KÐ$Ø&:×&>Ñ&>¸|ÈRÓ&PÐ#÷ ;ð 	×"Ñ"Ð#9Ô:Ü6LÐM`Ó6aˆÔ2Ñ3Ø×Ñ˜Õ(÷ ;Õ:ús   Â')DÄ
DÚPÚR)r“   r«  ri  r°  )r1  r   ri  zotel_types.AttributeValue)rÕ   r   r“   r«  ri  rª  )ÛÚ
__future__r   Úbuiltinsr  Ú_pytest.assertion.rewriteÚ	assertionÚrewriter  rs  r¼   ru  r4  ro  Úcollections.abcr   r   r   r   Úcontextvarsr   Úenumr	   Ú	functoolsr
   r   r   Útypingr   r   r   r   r   r   r   r   r   Úopentelemetry.contextrì  rÕ  Úopentelemetry.tracerë   r×  r   Úopentelemetry.metricsr   r   r   r   Úopentelemetry.sdk.tracer   r   r   r   Úopentelemetry.utilr   Ú
otel_typesÚtyping_extensionsr    r!   rƒ  r#   r<  r%   Ú
auto_tracer&   r'   rz   r(   r)   Úconfig_paramsr*   Ú	constantsr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   Ú	formatterr7   r8   r9   Újson_encoderr:   Újson_schemar;   r<   r=   r>   Úmetricsr?   rÈ   r@   ró  rA   rB   rC   rD   ÚutilsrE   rF   rG   rH   rI   Úwsgiref.typesrJ   rµ  Úhttpxr¤  Úpydantic_ai.modelsÚpydantic_aiÚrequestsÚdjango.httprK   rL   ÚfastapirM   Ú	flask.apprN   Ú(opentelemetry.instrumentation.asgi.typesrO   rP   rQ   rR   rÇ  Úpydantic_evals.reportingrS   Úpymongo.monitoringrT   rU   rV   Ú
sqlalchemyrW   Úsqlalchemy.ext.asynciorX   Ústarlette.applicationsrY   Ústarlette.requestsrZ   Ústarlette.websocketsr[   Ú$surrealdb.connections.async_templater\   Ú#surrealdb.connections.sync_templater]   r^   r  r_   ÚAiohttpClientRequestHookr`   ÚAiohttpClientResponseHookrÿ  ra   ÚFlaskCommenterOptionsÚFlaskRequestHookÚFlaskResponseHookrå  rb   ÚHttpxAsyncRequestHookrc   ÚHttpxAsyncResponseHookÚHttpxRequestHookÚHttpxResponseHookrû  ÚPsycopgCommenterOptionsr1  ÚRedisRequestHookÚRedisResponseHookr  ÚSQLAlchemyCommenterOptionsr  ÚWSGIRequestHookÚWSGIResponseHookrŒ  rd   re   rf   rg   r
  rh   ri   r'  rj   rk   r§  rl   r5  rm   rn   ro   r!  rp   r9  rq   rÆ  rr   ÚSystemMetricsConfigrs   r6  r©  r±  rt   rv   rÓ   rÃ   rº   ÚAttributeValuerk  rÁ   r/  r{  r|  r}  rx   rŒ   r‰   Ú<module>rº     sÝ  ðÝ "ç  „ Ó Û Û Û 
Û ß 7Ñ 7Ý -Ý Ý ß .Ý ÷
÷ 
õ 
õ ,Ý 'Ý )ß NÓ Nß 6ß 5Ý 2ß 6å Ý ß =ß 0Ý 5÷÷ ÷ ó ÷ AÝ "Ý ,÷ó õ (Ý +÷ó ÷ ^Ó ]çÝ Ý-ãÛÛÛÛß5ÝÝßqÑqÝ5Ý9ßaÑaÝ!Ý2Ý0Ý*Ý.ÝBÝ@Ý(÷÷ñ ÷
ó õ SßgÝXßd÷ó ÷ AßCÝBÝ3ßKÝ7ßeÝ!ð �J ¨t°TÐ9Ñ:€GáˆCƒL€÷Q*9ñ Q*9÷hT<ñ <ô&b1�,ô b1÷J4ñ 4ñn Ð3¸5ÀÀj×F_ÒF_ÐA_Ñ;`ÑaÐ ôUô)ô()ñ" ˆcƒN€ÙˆCƒL�rŒ   