logfire-api 4.32.1__tar.gz → 4.34.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. {logfire_api-4.32.1 → logfire_api-4.34.0}/PKG-INFO +2 -2
  2. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/__init__.py +18 -10
  3. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/__init__.pyi +3 -1
  4. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/auto_trace/__init__.pyi +2 -2
  5. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/auto_trace/import_hook.pyi +2 -2
  6. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/auto_trace/rewrite_ast.pyi +2 -1
  7. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/baggage.pyi +2 -2
  8. logfire_api-4.34.0/logfire_api/_internal/cli/ai_tools.pyi +32 -0
  9. logfire_api-4.34.0/logfire_api/_internal/cli/gateway.pyi +48 -0
  10. logfire_api-4.34.0/logfire_api/_internal/cli/gateway_auth.pyi +61 -0
  11. logfire_api-4.34.0/logfire_api/_internal/cli/prompt.pyi +14 -0
  12. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/client.pyi +7 -2
  13. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/config.pyi +19 -6
  14. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/config_params.pyi +4 -4
  15. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/constants.pyi +3 -1
  16. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/otlp.pyi +7 -0
  17. logfire_api-4.34.0/logfire_api/_internal/forwarding.pyi +85 -0
  18. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/instrument.pyi +5 -5
  19. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/aiohttp_client.pyi +2 -1
  20. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/asgi.pyi +2 -2
  21. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/aws_lambda.pyi +2 -1
  22. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/django.pyi +2 -1
  23. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/executors.pyi +2 -1
  24. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/fastapi.pyi +2 -2
  25. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/google_genai.pyi +1 -2
  26. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/httpx.pyi +2 -2
  27. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/pymongo.pyi +2 -1
  28. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/pytest.pyi +18 -18
  29. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/requests.pyi +2 -1
  30. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/surrealdb.pyi +1 -1
  31. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/json_formatter.pyi +1 -0
  32. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/main.pyi +61 -6
  33. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/scrubbing.pyi +3 -3
  34. logfire_api-4.34.0/logfire_api/_internal/server_response.pyi +11 -0
  35. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/tracer.pyi +5 -2
  36. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/ulid.pyi +1 -1
  37. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/utils.pyi +2 -2
  38. logfire_api-4.34.0/logfire_api/exceptions.pyi +4 -0
  39. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/experimental/api_client.pyi +24 -17
  40. logfire_api-4.34.0/logfire_api/experimental/forwarding.pyi +25 -0
  41. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/experimental/query_client.pyi +1 -0
  42. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/httpx.pyi +2 -2
  43. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/loguru.pyi +1 -0
  44. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/propagate.pyi +2 -2
  45. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/sampling/_tail_sampling.pyi +2 -1
  46. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/types.pyi +22 -1
  47. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/__init__.pyi +2 -2
  48. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/abstract.pyi +9 -5
  49. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/remote.pyi +4 -1
  50. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/variable.pyi +3 -3
  51. {logfire_api-4.32.1 → logfire_api-4.34.0}/pyproject.toml +2 -2
  52. logfire_api-4.32.1/logfire_api/_internal/cli/prompt.pyi +0 -18
  53. logfire_api-4.32.1/logfire_api/exceptions.pyi +0 -2
  54. logfire_api-4.32.1/logfire_api/experimental/forwarding.pyi +0 -42
  55. {logfire_api-4.32.1 → logfire_api-4.34.0}/.gitignore +0 -0
  56. {logfire_api-4.32.1 → logfire_api-4.34.0}/README.md +0 -0
  57. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/__init__.pyi +0 -0
  58. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/ast_utils.pyi +0 -0
  59. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/async_.pyi +0 -0
  60. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/auth.pyi +0 -0
  61. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/auto_trace/types.pyi +0 -0
  62. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/cli/__init__.pyi +0 -0
  63. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/cli/auth.pyi +0 -0
  64. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/cli/run.pyi +0 -0
  65. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/cli.pyi +0 -0
  66. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/collect_system_info.pyi +0 -0
  67. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/db_statement_summary.pyi +0 -0
  68. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/__init__.pyi +0 -0
  69. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/console.pyi +0 -0
  70. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/dynamic_batch.pyi +0 -0
  71. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/logs.pyi +0 -0
  72. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/processor_wrapper.pyi +0 -0
  73. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/quiet_metrics.pyi +0 -0
  74. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/remove_pending.pyi +0 -0
  75. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/tail_sampling.pyi +0 -0
  76. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/exporters/wrapper.pyi +0 -0
  77. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/formatter.pyi +0 -0
  78. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/__init__.pyi +0 -0
  79. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/aiohttp_server.pyi +0 -0
  80. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/asyncpg.pyi +0 -0
  81. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/celery.pyi +0 -0
  82. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi +0 -0
  83. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/dspy.pyi +0 -0
  84. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/flask.pyi +0 -0
  85. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/litellm.pyi +0 -0
  86. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/mcp.pyi +0 -0
  87. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/mysql.pyi +0 -0
  88. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/openai_agents.pyi +0 -0
  89. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/print.pyi +0 -0
  90. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/psycopg.pyi +0 -0
  91. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/pydantic_ai.pyi +0 -0
  92. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/redis.pyi +0 -0
  93. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/sqlalchemy.pyi +0 -0
  94. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/sqlite3.pyi +0 -0
  95. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/starlette.pyi +0 -0
  96. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/system_metrics.pyi +0 -0
  97. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/integrations/wsgi.pyi +0 -0
  98. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/json_encoder.pyi +0 -0
  99. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/json_schema.pyi +0 -0
  100. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/json_types.pyi +0 -0
  101. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/logs.pyi +0 -0
  102. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/metrics.pyi +0 -0
  103. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/_internal/stack_info.pyi +0 -0
  104. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/cli.pyi +0 -0
  105. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/db_api.pyi +0 -0
  106. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/experimental/__init__.pyi +0 -0
  107. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/experimental/annotations.pyi +0 -0
  108. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/experimental/datasets/__init__.pyi +0 -0
  109. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/__init__.pyi +0 -0
  110. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/aiohttp_client.pyi +0 -0
  111. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/flask.pyi +0 -0
  112. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/logging.pyi +0 -0
  113. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/psycopg.pyi +0 -0
  114. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/pydantic.pyi +0 -0
  115. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/redis.pyi +0 -0
  116. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/sqlalchemy.pyi +0 -0
  117. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/structlog.pyi +0 -0
  118. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/integrations/wsgi.pyi +0 -0
  119. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/py.typed +0 -0
  120. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/query_client.pyi +0 -0
  121. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/sampling/__init__.pyi +0 -0
  122. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/config.pyi +1 -1
  123. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/variables/local.pyi +0 -0
  124. {logfire_api-4.32.1 → logfire_api-4.34.0}/logfire_api/version.pyi +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: logfire-api
3
- Version: 4.32.1
3
+ Version: 4.34.0
4
4
  Summary: Shim for the Logfire SDK which does nothing unless Logfire is installed
5
5
  Author-email: Pydantic Team <engineering@pydantic.dev>, Samuel Colvin <samuel@pydantic.dev>, Hasan Ramezani <hasan@pydantic.dev>, Adrian Garcia Badaracco <adrian@pydantic.dev>, David Montague <david@pydantic.dev>, Marcelo Trylesinski <marcelo@pydantic.dev>, David Hewitt <david.hewitt@pydantic.dev>, Alex Hall <alex@pydantic.dev>
6
6
  License-Expression: MIT
7
- Requires-Python: >=3.8
7
+ Requires-Python: >=3.10
8
8
  Description-Content-Type: text/markdown
9
9
 
10
10
  # logfire-api
@@ -2,11 +2,11 @@ from __future__ import annotations
2
2
 
3
3
  import importlib
4
4
  import sys
5
- from contextlib import contextmanager, nullcontext
6
- from typing import Any, ContextManager, Literal, TYPE_CHECKING, Sequence
5
+ from collections.abc import Sequence
6
+ from contextlib import AbstractContextManager, contextmanager, nullcontext
7
+ from typing import TYPE_CHECKING, Any, Literal
7
8
  from unittest.mock import MagicMock
8
9
 
9
-
10
10
  try:
11
11
  logfire_module = importlib.import_module('logfire')
12
12
  sys.modules[__name__] = logfire_module
@@ -143,7 +143,7 @@ except ImportError:
143
143
  def instrument_wsgi(self, app, *args, **kwargs):
144
144
  return app
145
145
 
146
- def instrument_fastapi(self, *args, **kwargs) -> ContextManager[None]:
146
+ def instrument_fastapi(self, *args, **kwargs) -> AbstractContextManager[None]:
147
147
  return nullcontext()
148
148
 
149
149
  def instrument_pydantic(self, *args, **kwargs) -> None: ...
@@ -176,13 +176,13 @@ except ImportError:
176
176
 
177
177
  def instrument_asyncpg(self, *args, **kwargs) -> None: ...
178
178
 
179
- def instrument_anthropic(self, *args, **kwargs) -> ContextManager[None]:
179
+ def instrument_anthropic(self, *args, **kwargs) -> AbstractContextManager[None]:
180
180
  return nullcontext()
181
181
 
182
- def instrument_openai(self, *args, **kwargs) -> ContextManager[None]:
182
+ def instrument_openai(self, *args, **kwargs) -> AbstractContextManager[None]:
183
183
  return nullcontext()
184
184
 
185
- def instrument_print(self, *args, **kwargs) -> ContextManager[None]:
185
+ def instrument_print(self, *args, **kwargs) -> AbstractContextManager[None]:
186
186
  return nullcontext()
187
187
 
188
188
  def instrument_openai_agents(self, *args, **kwargs) -> None: ...
@@ -201,11 +201,17 @@ except ImportError:
201
201
 
202
202
  def instrument_mcp(self, *args, **kwargs) -> None: ...
203
203
 
204
- def instrument_claude_agent_sdk(self, *args, **kwargs) -> ContextManager[None]:
204
+ def instrument_claude_agent_sdk(self, *args, **kwargs) -> AbstractContextManager[None]:
205
205
  return nullcontext()
206
206
 
207
207
  def url_from_eval(self, *args, **kwargs) -> str | None: ...
208
208
 
209
+ def forward_export_request(self, *args, **kwargs) -> MagicMock:
210
+ return MagicMock()
211
+
212
+ async def forward_export_request_starlette(self, *args, **kwargs) -> MagicMock:
213
+ return MagicMock()
214
+
209
215
  def shutdown(self, *args, **kwargs) -> None: ...
210
216
 
211
217
 
@@ -262,6 +268,8 @@ except ImportError:
262
268
  shutdown = DEFAULT_LOGFIRE_INSTANCE.shutdown
263
269
  suppress_scopes = DEFAULT_LOGFIRE_INSTANCE.suppress_scopes
264
270
  url_from_eval = DEFAULT_LOGFIRE_INSTANCE.url_from_eval
271
+ forward_export_request = DEFAULT_LOGFIRE_INSTANCE.forward_export_request
272
+ forward_export_request_starlette = DEFAULT_LOGFIRE_INSTANCE.forward_export_request_starlette
265
273
 
266
274
  def loguru_handler() -> dict[str, Any]:
267
275
  return {}
@@ -316,11 +324,11 @@ except ImportError:
316
324
  def get_baggage(*args, **kwargs) -> dict[str, str]:
317
325
  return {}
318
326
 
319
- def set_baggage(*args, **kwargs) -> ContextManager[None]:
327
+ def set_baggage(*args, **kwargs) -> AbstractContextManager[None]:
320
328
  return nullcontext()
321
329
 
322
330
  def get_context(*args, **kwargs) -> dict[str, Any]:
323
331
  return {}
324
332
 
325
- def attach_context(*args, **kwargs)-> ContextManager[None]:
333
+ def attach_context(*args, **kwargs) -> AbstractContextManager[None]:
326
334
  return nullcontext()
@@ -16,7 +16,7 @@ from logfire.propagate import attach_context as attach_context, get_context as g
16
16
  from logfire.sampling import SamplingOptions as SamplingOptions
17
17
  from typing import Any
18
18
 
19
- __all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'warning', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_pydantic_ai', 'instrument_fastapi', 'instrument_openai', 'instrument_openai_agents', 'instrument_anthropic', 'instrument_google_genai', 'instrument_litellm', 'instrument_dspy', 'instrument_print', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_system_metrics', 'instrument_mcp', 'instrument_claude_agent_sdk', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'add_non_user_code_prefix', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions', 'VariablesOptions', 'LocalVariablesOptions', 'variables', 'var', 'variables_clear', 'variables_get', 'variables_push', 'variables_push_types', 'variables_validate', 'variables_push_config', 'variables_pull_config', 'variables_build_config', 'logfire_info', 'get_baggage', 'set_baggage', 'get_context', 'attach_context', 'url_from_eval']
19
+ __all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'warning', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_pydantic_ai', 'instrument_fastapi', 'instrument_openai', 'instrument_openai_agents', 'instrument_anthropic', 'instrument_google_genai', 'instrument_litellm', 'instrument_dspy', 'instrument_print', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_system_metrics', 'instrument_mcp', 'instrument_claude_agent_sdk', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'add_non_user_code_prefix', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions', 'VariablesOptions', 'LocalVariablesOptions', 'variables', 'var', 'variables_clear', 'variables_get', 'variables_push', 'variables_push_types', 'variables_validate', 'variables_push_config', 'variables_pull_config', 'variables_build_config', 'logfire_info', 'get_baggage', 'set_baggage', 'get_context', 'attach_context', 'url_from_eval', 'forward_export_request', 'forward_export_request_starlette']
20
20
 
21
21
  DEFAULT_LOGFIRE_INSTANCE = Logfire()
22
22
  span = DEFAULT_LOGFIRE_INSTANCE.span
@@ -61,6 +61,8 @@ shutdown = DEFAULT_LOGFIRE_INSTANCE.shutdown
61
61
  with_tags = DEFAULT_LOGFIRE_INSTANCE.with_tags
62
62
  with_settings = DEFAULT_LOGFIRE_INSTANCE.with_settings
63
63
  url_from_eval = DEFAULT_LOGFIRE_INSTANCE.url_from_eval
64
+ forward_export_request = DEFAULT_LOGFIRE_INSTANCE.forward_export_request
65
+ forward_export_request_starlette = DEFAULT_LOGFIRE_INSTANCE.forward_export_request_starlette
64
66
  log = DEFAULT_LOGFIRE_INSTANCE.log
65
67
  trace = DEFAULT_LOGFIRE_INSTANCE.trace
66
68
  debug = DEFAULT_LOGFIRE_INSTANCE.debug
@@ -2,8 +2,8 @@ from ..constants import ONE_SECOND_IN_NANOSECONDS as ONE_SECOND_IN_NANOSECONDS
2
2
  from ..main import Logfire as Logfire
3
3
  from .import_hook import LogfireFinder as LogfireFinder
4
4
  from .types import AutoTraceModule as AutoTraceModule
5
- from collections.abc import Sequence
6
- from typing import Callable, Literal
5
+ from collections.abc import Callable, Sequence
6
+ from typing import Literal
7
7
 
8
8
  def install_auto_tracing(logfire: Logfire, modules: Sequence[str] | Callable[[AutoTraceModule], bool], *, min_duration: float, check_imported_modules: Literal['error', 'warn', 'ignore'] = 'error') -> None:
9
9
  """Install automatic tracing.
@@ -2,12 +2,12 @@ from ..main import Logfire as Logfire
2
2
  from ..utils import log_internal_error as log_internal_error
3
3
  from .rewrite_ast import compile_source as compile_source
4
4
  from .types import AutoTraceModule as AutoTraceModule
5
- from collections.abc import Sequence
5
+ from collections.abc import Callable, Sequence
6
6
  from dataclasses import dataclass
7
7
  from importlib.abc import Loader, MetaPathFinder
8
8
  from importlib.machinery import ModuleSpec
9
9
  from types import ModuleType
10
- from typing import Any, Callable
10
+ from typing import Any
11
11
 
12
12
  @dataclass
13
13
  class LogfireFinder(MetaPathFinder):
@@ -1,9 +1,10 @@
1
1
  import ast
2
2
  from ..ast_utils import BaseTransformer as BaseTransformer, LogfireArgs as LogfireArgs
3
3
  from ..main import Logfire as Logfire
4
+ from collections.abc import Callable
4
5
  from contextlib import AbstractContextManager as AbstractContextManager
5
6
  from dataclasses import dataclass
6
- from typing import Any, Callable, TypeVar
7
+ from typing import Any, TypeVar
7
8
 
8
9
  def compile_source(tree: ast.AST, filename: str, module_name: str, logfire_instance: Logfire, min_duration: int) -> Callable[[dict[str, Any]], None]:
9
10
  """Compile a modified AST of the module's source code in the module's namespace.
@@ -1,5 +1,5 @@
1
1
  from _typeshed import Incomplete
2
- from collections.abc import Iterator
2
+ from collections.abc import Generator
3
3
  from contextlib import contextmanager
4
4
  from opentelemetry import context
5
5
  from opentelemetry.sdk.trace import Span, SpanProcessor
@@ -9,7 +9,7 @@ __all__ = ['get_baggage', 'set_baggage']
9
9
  get_baggage: Incomplete
10
10
 
11
11
  @contextmanager
12
- def set_baggage(**values: str) -> Iterator[None]:
12
+ def set_baggage(**values: str) -> Generator[None]:
13
13
  '''Context manager that attaches key/value pairs as OpenTelemetry baggage to the current context.
14
14
 
15
15
  See the [Baggage documentation](https://logfire.pydantic.dev/docs/reference/advanced/baggage/) for more details.
@@ -0,0 +1,32 @@
1
+ from collections.abc import Callable
2
+ from dataclasses import dataclass, field
3
+ from logfire._internal.utils import read_toml_file as read_toml_file
4
+ from logfire.exceptions import LogfireConfigError as LogfireConfigError
5
+ from pathlib import Path
6
+ from rich.console import Console
7
+ from typing import Any
8
+
9
+ LOCAL_TOKEN_PLACEHOLDER: str
10
+ LOGFIRE_MCP_TOML: str
11
+
12
+ @dataclass(frozen=True)
13
+ class AiToolIntegration:
14
+ name: str
15
+ display_name: str
16
+ binary: str
17
+ env: dict[str, str]
18
+ model_env: dict[str, str] = field(default_factory=dict[str, str])
19
+ setup: Callable[[str, str | None, Path, str], dict[str, str]] | None = ...
20
+ configure_mcp: Callable[[str, Console, bool], None] | None = ...
21
+ description: str = ...
22
+ notice: str = ...
23
+ def binary_path(self) -> str | None: ...
24
+ def build_gateway_env(self, *, proxy_base: str, model: str | None, workdir: Path, local_token: str) -> dict[str, str]: ...
25
+ def configure_mcp_server(self, *, mcp_url: str, console: Console, update: bool) -> None: ...
26
+
27
+ def gateway_template_values(proxy_base: str, local_token: str) -> dict[str, str]: ...
28
+ def resolve_ai_tool(name: str) -> AiToolIntegration: ...
29
+ def ai_tool_names() -> tuple[str, ...]: ...
30
+ def opencode_mcp_json(url: str) -> dict[str, Any]: ...
31
+
32
+ AI_TOOL_INTEGRATIONS: dict[str, AiToolIntegration]
@@ -0,0 +1,48 @@
1
+ import argparse
2
+ import httpx
3
+ from .ai_tools import AiToolIntegration as AiToolIntegration, LOCAL_TOKEN_PLACEHOLDER as LOCAL_TOKEN_PLACEHOLDER, ai_tool_names as ai_tool_names, gateway_template_values as gateway_template_values, resolve_ai_tool as resolve_ai_tool
4
+ from .gateway_auth import CimdOAuthClient as CimdOAuthClient, GATEWAY_CIMD_PATH as GATEWAY_CIMD_PATH, GatewayAuth as GatewayAuth, GatewayError as GatewayError, OAuthSession as OAuthSession, discover_oauth_metadata as discover_oauth_metadata
5
+ from _typeshed import Incomplete
6
+ from dataclasses import dataclass
7
+ from logfire.exceptions import LogfireConfigError as LogfireConfigError
8
+ from typing import Any, Literal
9
+
10
+ DEFAULT_PORT: int
11
+ DEFAULT_SCOPE: str
12
+ OAUTH_CALLBACK_PATH: str
13
+ console: Incomplete
14
+
15
+ @dataclass(frozen=True)
16
+ class GatewayRegion:
17
+ backend: str
18
+ gateway: str
19
+ client_id: str
20
+
21
+ GATEWAY_REGIONS: dict[str, GatewayRegion]
22
+
23
+ @dataclass(frozen=True)
24
+ class GatewayCommandContext:
25
+ raw_args: list[str]
26
+ region: str | None
27
+ logfire_url: str | None
28
+
29
+ @dataclass(frozen=True)
30
+ class GatewayCommand:
31
+ name: Literal['usage', 'launch', 'serve']
32
+ args: tuple[str, ...]
33
+
34
+ def filter_headers(headers: dict[str, str], *, direction: str) -> list[tuple[str, str]]: ...
35
+
36
+ @dataclass
37
+ class ProxyState:
38
+ auth: GatewayAuth
39
+ client: httpx.AsyncClient
40
+ gateway: str
41
+ region: str
42
+ local_token: str
43
+
44
+ def build_app(state: ProxyState) -> Any: ...
45
+ def parse_gateway_command(context: GatewayCommandContext) -> GatewayCommand: ...
46
+ def execute_gateway_command(command: GatewayCommand, context: GatewayCommandContext) -> int: ...
47
+ def parse_gateway(args: argparse.Namespace) -> None:
48
+ """Run a local OAuth proxy for the Logfire AI Gateway."""
@@ -0,0 +1,61 @@
1
+ import asyncio
2
+ from _typeshed import Incomplete
3
+ from dataclasses import dataclass, field
4
+ from typing import Any
5
+
6
+ REFRESH_MARGIN_SECONDS: float
7
+ console: Incomplete
8
+
9
+ class GatewayError(Exception):
10
+ """Expected gateway failure rendered to the user without a traceback."""
11
+
12
+ @dataclass(frozen=True)
13
+ class OAuthMetadata:
14
+ authorization_endpoint: str
15
+ token_endpoint: str
16
+ device_authorization_endpoint: str
17
+
18
+ async def discover_oauth_metadata(http: Any, backend: str) -> OAuthMetadata:
19
+ """Fetch the backend's OAuth authorization server metadata."""
20
+
21
+ GATEWAY_CIMD_PATH: str
22
+
23
+ class CimdOAuthClient:
24
+ """Public OAuth client identified by a CIMD URL."""
25
+ client_id: Incomplete
26
+ def __init__(self, http: Any, metadata: OAuthMetadata, *, client_id: str) -> None: ...
27
+ async def start_device_authorization(self, data: dict[str, str]) -> Any: ...
28
+ async def post_token(self, data: dict[str, str]) -> Any: ...
29
+
30
+ @dataclass
31
+ class AuthBootstrap:
32
+ redirect_uri: str
33
+ expected_state: str = ...
34
+ code_verifier: str = ...
35
+ received_code: str | None = ...
36
+ error: str | None = ...
37
+ event: asyncio.Event = field(default_factory=asyncio.Event)
38
+
39
+ @dataclass(frozen=True)
40
+ class OAuthCallbackResult:
41
+ title: str
42
+ body: str
43
+ status_code: int = ...
44
+
45
+ class OAuthSession:
46
+ """In-memory OAuth token state for the local gateway proxy."""
47
+ def __init__(self, client: CimdOAuthClient, metadata: OAuthMetadata, *, resource: str, scope: str) -> None: ...
48
+ async def auth_code_flow(self, bootstrap: AuthBootstrap) -> None: ...
49
+ async def device_flow(self) -> None: ...
50
+ async def refresh(self) -> None: ...
51
+ async def current_access_token(self) -> str: ...
52
+ async def force_refresh(self) -> str: ...
53
+
54
+ class GatewayAuth:
55
+ """OAuth control-plane for an authorized local gateway proxy session."""
56
+ def __init__(self, session: OAuthSession, *, redirect_uri: str, flow: str) -> None: ...
57
+ async def authorize(self) -> None: ...
58
+ async def current_access_token(self) -> str: ...
59
+ async def recover_after_rejection(self, *, use_reauth: bool) -> bool: ...
60
+ async def reauthorize(self) -> None: ...
61
+ def complete_browser_callback(self, *, error: str | None, error_description: str | None, code: str | None, state: str | None) -> OAuthCallbackResult: ...
@@ -0,0 +1,14 @@
1
+ import argparse
2
+ from _typeshed import Incomplete
3
+ from logfire._internal.cli.ai_tools import resolve_ai_tool as resolve_ai_tool
4
+ from logfire._internal.cli.auth import parse_auth as parse_auth
5
+ from logfire._internal.client import LogfireClient as LogfireClient
6
+ from logfire.exceptions import LogfireConfigError as LogfireConfigError
7
+
8
+ PROMPT_AI_TOOLS: Incomplete
9
+
10
+ def parse_prompt(args: argparse.Namespace) -> None:
11
+ """Creates a prompt to be used with your favorite LLM.
12
+
13
+ The prompt assumes you are using Logfire MCP.
14
+ """
@@ -1,4 +1,5 @@
1
1
  from .auth import UserToken as UserToken, UserTokenCollection as UserTokenCollection
2
+ from .server_response import ServerResponseCallback as ServerResponseCallback, install_logfire_response_hook as install_logfire_response_hook
2
3
  from .utils import UnexpectedResponse as UnexpectedResponse
3
4
  from _typeshed import Incomplete
4
5
  from logfire.exceptions import LogfireConfigError as LogfireConfigError
@@ -19,11 +20,13 @@ class LogfireClient:
19
20
 
20
21
  Args:
21
22
  user_token: The user token to use when authenticating against the API.
23
+ server_response_hook: Optional override for the API response hook (see
24
+ `AdvancedOptions.server_response_hook`).
22
25
  """
23
26
  base_url: Incomplete
24
- def __init__(self, user_token: UserToken) -> None: ...
27
+ def __init__(self, user_token: UserToken, server_response_hook: ServerResponseCallback | None = None) -> None: ...
25
28
  @classmethod
26
- def from_url(cls, base_url: str | None) -> Self:
29
+ def from_url(cls, base_url: str | None, server_response_hook: ServerResponseCallback | None = None) -> Self:
27
30
  """Create a client from the provided base URL.
28
31
 
29
32
  Args:
@@ -31,6 +34,8 @@ class LogfireClient:
31
34
  the user into selecting a token from the token collection (or, if only one available,
32
35
  use it directly). The token collection will be created from the `~/.logfire/default.toml`
33
36
  file (or an empty one if no such file exists).
37
+ server_response_hook: Optional override for the API response hook (see
38
+ `AdvancedOptions.server_response_hook`).
34
39
  """
35
40
  def get_user_organizations(self) -> list[dict[str, Any]]:
36
41
  """Get the organizations of the logged-in user."""
@@ -1,33 +1,35 @@
1
- import atexit
2
1
  import dataclasses
3
2
  import requests
4
3
  from ..propagate import NoExtractTraceContextPropagator as NoExtractTraceContextPropagator, WarnOnExtractTraceContextPropagator as WarnOnExtractTraceContextPropagator
5
4
  from ..types import ExceptionCallback as ExceptionCallback
6
5
  from .client import InvalidProjectName as InvalidProjectName, LogfireClient as LogfireClient, ProjectAlreadyExists as ProjectAlreadyExists
7
6
  from .config_params import ParamManager as ParamManager, PydanticPluginRecordValues as PydanticPluginRecordValues, normalize_token as normalize_token
8
- from .constants import LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL
7
+ from .constants import ATTRIBUTES_CONFIG as ATTRIBUTES_CONFIG, ATTRIBUTES_PACKAGE_VERSIONS as ATTRIBUTES_PACKAGE_VERSIONS, LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL, RESOURCE_ATTRIBUTES_VERSION as RESOURCE_ATTRIBUTES_VERSION
9
8
  from .exporters.console import ConsoleColorsValues as ConsoleColorsValues, ConsoleLogExporter as ConsoleLogExporter, IndentedConsoleSpanExporter as IndentedConsoleSpanExporter, ShowParentsConsoleSpanExporter as ShowParentsConsoleSpanExporter, SimpleConsoleSpanExporter as SimpleConsoleSpanExporter
10
9
  from .exporters.dynamic_batch import DynamicBatchSpanProcessor as DynamicBatchSpanProcessor
11
10
  from .exporters.logs import CheckSuppressInstrumentationLogProcessorWrapper as CheckSuppressInstrumentationLogProcessorWrapper, MainLogProcessorWrapper as MainLogProcessorWrapper
12
- from .exporters.otlp import BodySizeCheckingOTLPSpanExporter as BodySizeCheckingOTLPSpanExporter, OTLPExporterHttpSession as OTLPExporterHttpSession, QuietLogExporter as QuietLogExporter, QuietSpanExporter as QuietSpanExporter, RetryFewerSpansSpanExporter as RetryFewerSpansSpanExporter
11
+ from .exporters.otlp import BodySizeCheckingOTLPSpanExporter as BodySizeCheckingOTLPSpanExporter, OTLPExporterHttpSession as OTLPExporterHttpSession, QuietLogExporter as QuietLogExporter, QuietSpanExporter as QuietSpanExporter, RetryFewerSpansSpanExporter as RetryFewerSpansSpanExporter, cleanup_disk_retryers as cleanup_disk_retryers
13
12
  from .exporters.processor_wrapper import CheckSuppressInstrumentationProcessorWrapper as CheckSuppressInstrumentationProcessorWrapper, MainSpanProcessorWrapper as MainSpanProcessorWrapper
14
13
  from .exporters.quiet_metrics import QuietMetricExporter as QuietMetricExporter
15
14
  from .exporters.remove_pending import RemovePendingSpansExporter as RemovePendingSpansExporter
16
15
  from .exporters.test import TestExporter as TestExporter
16
+ from .forwarding import OTLPForwardingManager as OTLPForwardingManager
17
17
  from .integrations.executors import instrument_executors as instrument_executors
18
18
  from .logs import ProxyLoggerProvider as ProxyLoggerProvider
19
19
  from .main import Logfire as Logfire
20
20
  from .metrics import ProxyMeterProvider as ProxyMeterProvider
21
21
  from .scrubbing import BaseScrubber as BaseScrubber, NOOP_SCRUBBER as NOOP_SCRUBBER, Scrubber as Scrubber, ScrubbingOptions as ScrubbingOptions
22
+ from .server_response import ServerResponseCallback as ServerResponseCallback, install_logfire_response_hook as install_logfire_response_hook
22
23
  from .stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
23
24
  from .tracer import OPEN_SPANS as OPEN_SPANS, PendingSpanProcessor as PendingSpanProcessor, ProxyTracerProvider as ProxyTracerProvider
24
25
  from .utils import SeededRandomIdGenerator as SeededRandomIdGenerator, ensure_data_dir_exists as ensure_data_dir_exists, handle_internal_errors as handle_internal_errors, platform_is_emscripten as platform_is_emscripten, suppress_instrumentation as suppress_instrumentation
25
26
  from _typeshed import Incomplete
26
- from collections.abc import Sequence
27
+ from collections.abc import Callable, Sequence
27
28
  from dataclasses import dataclass, field
28
29
  from datetime import timedelta
29
30
  from logfire._internal.auth import PYDANTIC_LOGFIRE_TOKEN_PATTERN as PYDANTIC_LOGFIRE_TOKEN_PATTERN, REGIONS as REGIONS
30
31
  from logfire._internal.baggage import DirectBaggageAttributesSpanProcessor as DirectBaggageAttributesSpanProcessor
32
+ from logfire._internal.collect_system_info import collect_package_info as collect_package_info
31
33
  from logfire.exceptions import LogfireConfigError as LogfireConfigError
32
34
  from logfire.sampling import SamplingOptions as SamplingOptions
33
35
  from logfire.sampling._tail_sampling import TailSamplingProcessor as TailSamplingProcessor
@@ -40,7 +42,7 @@ from opentelemetry.sdk.metrics.view import View
40
42
  from opentelemetry.sdk.trace import SpanProcessor
41
43
  from opentelemetry.sdk.trace.id_generator import IdGenerator
42
44
  from pathlib import Path
43
- from typing import Any, Callable, ClassVar, Literal, TextIO, TypedDict
45
+ from typing import Any, ClassVar, Literal, TextIO, TypedDict
44
46
  from typing_extensions import Self, Unpack
45
47
 
46
48
  CREDENTIALS_FILENAME: str
@@ -68,6 +70,8 @@ class AdvancedOptions:
68
70
  ns_timestamp_generator: Callable[[], int] = ...
69
71
  log_record_processors: Sequence[LogRecordProcessor] = ...
70
72
  exception_callback: ExceptionCallback | None = ...
73
+ emit_configuration_span: bool | None = ...
74
+ server_response_hook: ServerResponseCallback | None = ...
71
75
  def generate_base_url(self, token: str) -> str: ...
72
76
 
73
77
  @dataclass
@@ -250,6 +254,8 @@ class LogfireConfig(_LogfireConfigData):
250
254
  Returns:
251
255
  Whether the flush of spans was successful.
252
256
  """
257
+ def shutdown(self, timeout_millis: int = 30000, flush: bool = True) -> bool:
258
+ """Shut down variables, forwarding, traces, logs, and metrics."""
253
259
  def get_tracer_provider(self) -> ProxyTracerProvider:
254
260
  """Get a tracer provider from this `LogfireConfig`.
255
261
 
@@ -289,8 +295,15 @@ class LogfireConfig(_LogfireConfigData):
289
295
  def warn_if_not_initialized(self, message: str): ...
290
296
  def suppress_scopes(self, *scopes: str) -> None: ...
291
297
 
292
- @atexit.register
298
+ @handle_internal_errors
299
+ def emit_configuration_span(config: LogfireConfig, logfire_instance: Logfire, *, local: bool) -> None:
300
+ """Emit a span describing the active Logfire configuration and installed packages.
301
+
302
+ Only runs when `advanced.emit_configuration_span` is `True`. Sends a curated set of
303
+ non-sensitive configuration fields.
304
+ """
293
305
  def exit_open_spans() -> None: ...
306
+ def shutdown_otlp_forwarding(timeout_millis: int = 30000) -> None: ...
294
307
 
295
308
  original_os_exit: Incomplete
296
309
 
@@ -3,18 +3,17 @@ from .constants import LevelName as LevelName
3
3
  from .exporters.console import ConsoleColorsValues as ConsoleColorsValues
4
4
  from .utils import read_toml_file as read_toml_file
5
5
  from _typeshed import Incomplete
6
- from collections.abc import Sequence
6
+ from collections.abc import Callable, Sequence
7
7
  from dataclasses import dataclass
8
8
  from functools import cached_property
9
9
  from logfire.exceptions import LogfireConfigError as LogfireConfigError
10
10
  from pathlib import Path
11
- from typing import Any, Callable, TypeVar
11
+ from typing import Any, TypeVar
12
12
 
13
13
  T = TypeVar('T')
14
- slots_true: Incomplete
15
14
  PydanticPluginRecordValues: Incomplete
16
15
 
17
- @dataclass(**slots_true)
16
+ @dataclass(slots=True)
18
17
  class ConfigParam:
19
18
  """A parameter that can be configured for a Logfire instance."""
20
19
  env_vars: list[str]
@@ -54,6 +53,7 @@ INSPECT_ARGUMENTS: Incomplete
54
53
  IGNORE_NO_CONFIG: Incomplete
55
54
  BASE_URL: Incomplete
56
55
  DISTRIBUTED_TRACING: Incomplete
56
+ EMIT_CONFIGURATION_SPAN: Incomplete
57
57
  HTTPX_CAPTURE_ALL: Incomplete
58
58
  AIOHTTP_CLIENT_CAPTURE_ALL: Incomplete
59
59
  CONFIG_PARAMS: Incomplete
@@ -22,7 +22,9 @@ ATTRIBUTES_LOGGING_ARGS_KEY: Incomplete
22
22
  ATTRIBUTES_LOGGING_NAME: Incomplete
23
23
  ATTRIBUTES_VALIDATION_ERROR_KEY: str
24
24
  ATTRIBUTES_SCRUBBED_KEY: Incomplete
25
- RESOURCE_ATTRIBUTES_PACKAGE_VERSIONS: str
25
+ ATTRIBUTES_CONFIG: str
26
+ ATTRIBUTES_PACKAGE_VERSIONS: str
27
+ RESOURCE_ATTRIBUTES_VERSION: str
26
28
  RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME: str
27
29
  RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION: str
28
30
  RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL: str
@@ -1,3 +1,4 @@
1
+ import atexit
1
2
  import requests
2
3
  from ..utils import logger as logger, platform_is_emscripten as platform_is_emscripten
3
4
  from .wrapper import WrapperLogExporter as WrapperLogExporter, WrapperSpanExporter as WrapperSpanExporter
@@ -14,6 +15,9 @@ from requests import Session
14
15
  from threading import Thread
15
16
  from typing import Any
16
17
 
18
+ @atexit.register
19
+ def cleanup_disk_retryers() -> None: ...
20
+
17
21
  class BodySizeCheckingOTLPSpanExporter(OTLPSpanExporter):
18
22
  max_body_size: Incomplete
19
23
  def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@@ -24,6 +28,7 @@ class OTLPExporterHttpSession(Session):
24
28
  def post(self, url: str, data: bytes, **kwargs: Any): ...
25
29
  @cached_property
26
30
  def retryer(self) -> DiskRetryer: ...
31
+ def close(self) -> None: ...
27
32
 
28
33
  def raise_for_retryable_status(response: requests.Response): ...
29
34
 
@@ -36,10 +41,12 @@ class DiskRetryer:
36
41
  thread: Thread | None
37
42
  tasks: deque[tuple[Path, dict[str, Any]]]
38
43
  total_size: int
44
+ closed: bool
39
45
  session: Incomplete
40
46
  dir: Incomplete
41
47
  last_log_time: Incomplete
42
48
  def __init__(self, headers: Mapping[str, str | bytes]) -> None: ...
49
+ def close(self) -> None: ...
43
50
  def add_task(self, data: bytes, kwargs: dict[str, Any]): ...
44
51
 
45
52
  class RetryFewerSpansSpanExporter(WrapperSpanExporter):
@@ -0,0 +1,85 @@
1
+ from _typeshed import Incomplete
2
+ from collections import deque
3
+ from collections.abc import Callable as Callable, Mapping, Sequence
4
+ from dataclasses import dataclass
5
+ from enum import Enum
6
+ from logfire._internal.exporters.otlp import OTLPExporterHttpSession as OTLPExporterHttpSession
7
+ from logfire._internal.server_response import install_logfire_response_hook as install_logfire_response_hook
8
+ from logfire._internal.utils import suppress_instrumentation as suppress_instrumentation
9
+ from logfire.experimental.forwarding import ForwardExportRequestResponse as ForwardExportRequestResponse
10
+ from logfire.types import ServerResponseCallback as ServerResponseCallback
11
+ from logfire.version import VERSION as VERSION
12
+ from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ExportLogsServiceResponse
13
+ from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import ExportMetricsServiceResponse
14
+ from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceResponse
15
+ from threading import Thread
16
+ from typing import Literal
17
+
18
+ OTLP_FORWARDING_MAX_QUEUED_BODY_BYTES: Incomplete
19
+ OTLP_FORWARDING_MAX_QUEUED_ITEMS: int
20
+ OTLP_FORWARDING_MAX_REQUEST_BODY_BYTES: Incomplete
21
+ ForwardingPath: Incomplete
22
+
23
+ @dataclass(frozen=True)
24
+ class ForwardingPathConfig:
25
+ timeout_env: str
26
+ default_timeout: float
27
+ partial_success_rejected_attribute: str
28
+ response_message_type: type[ExportTraceServiceResponse] | type[ExportLogsServiceResponse] | type[ExportMetricsServiceResponse]
29
+ def timeout(self) -> float: ...
30
+
31
+ FORWARDING_CONFIGS: dict[ForwardingPath, ForwardingPathConfig]
32
+
33
+ class ForwardingContentType(Enum):
34
+ PROTOBUF: str
35
+ JSON: str
36
+
37
+ @dataclass(frozen=True)
38
+ class ForwardingRequest:
39
+ path: ForwardingPath
40
+ body: bytes
41
+ content_type: ForwardingContentType
42
+ headers: Mapping[str, str]
43
+ @property
44
+ def path_config(self) -> ForwardingPathConfig: ...
45
+
46
+ @dataclass(frozen=True)
47
+ class ForwardingErrorResponse:
48
+ status_code: int
49
+ content: bytes
50
+
51
+ @dataclass(frozen=True)
52
+ class ForwardingAdmissionResult:
53
+ response: Literal['success', 'partial_success']
54
+ message: str | None
55
+
56
+ class OTLPForwardingPipeline:
57
+ base_url: Incomplete
58
+ session: Incomplete
59
+ max_queued_body_bytes: Incomplete
60
+ max_queued_items: Incomplete
61
+ queue: deque[ForwardingRequest]
62
+ worker: Thread | None
63
+ closed: bool
64
+ condition: Incomplete
65
+ tokens: list[str]
66
+ def __init__(self, *, base_url: str, session: OTLPExporterHttpSession, max_queued_body_bytes: int, max_queued_items: int = ...) -> None: ...
67
+ @property
68
+ def queued_body_bytes(self) -> int: ...
69
+ def enqueue(self, queued_request: ForwardingRequest) -> bool: ...
70
+ def force_flush(self, timeout_millis: int) -> bool: ...
71
+ def shutdown(self, timeout_millis: int, *, drain_queued: bool = True) -> bool: ...
72
+
73
+ class OTLPForwardingManager:
74
+ pipelines: dict[str, OTLPForwardingPipeline]
75
+ closed: bool
76
+ def __init__(self, destinations: Sequence[tuple[str, str]], *, server_response_hook: ServerResponseCallback | None = None) -> None: ...
77
+ def has_destinations(self) -> bool: ...
78
+ def submit(self, request: ForwardingRequest) -> ForwardingAdmissionResult: ...
79
+ def force_flush(self, timeout_millis: int) -> bool: ...
80
+ def shutdown(self, timeout_millis: int, *, drain_queued: bool = True) -> bool: ...
81
+
82
+ def parse_forwarding_content_type(content_type: str) -> ForwardingContentType | None: ...
83
+ def build_forwarding_request(*, path: str, headers: Mapping[str, str], body: bytes, max_body_size: int = ...) -> ForwardingRequest | ForwardingErrorResponse: ...
84
+ def build_success_response(request: ForwardingRequest) -> ForwardExportRequestResponse: ...
85
+ def build_partial_success_response(request: ForwardingRequest, *, message: str) -> ForwardExportRequestResponse: ...
@@ -1,12 +1,12 @@
1
- from .constants import ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY
1
+ from .constants import ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, LevelName as LevelName, log_level_attributes as log_level_attributes
2
2
  from .main import Logfire as Logfire
3
3
  from .stack_info import get_filepath_attribute as get_filepath_attribute
4
4
  from .utils import safe_repr as safe_repr, uniquify_sequence as uniquify_sequence
5
5
  from _typeshed import Incomplete
6
- from collections.abc import Iterable, Sequence
6
+ from collections.abc import Callable, Iterable, Sequence
7
7
  from contextlib import AbstractContextManager as AbstractContextManager
8
8
  from opentelemetry.util import types as otel_types
9
- from typing import Any, Callable, TypeVar
9
+ from typing import Any, TypeVar
10
10
  from typing_extensions import LiteralString, ParamSpec
11
11
 
12
12
  P = ParamSpec('P')
@@ -15,6 +15,6 @@ CONTEXTMANAGER_HELPER_CODE: Incomplete
15
15
  ASYNCCONTEXTMANAGER_HELPER_CODE: Incomplete
16
16
  GENERATOR_WARNING_MESSAGE: str
17
17
 
18
- def instrument(logfire: Logfire, tags: Sequence[str], msg_template: LiteralString | None, span_name: str | None, extract_args: bool | Iterable[str], record_return: bool, allow_generator: bool, new_trace: bool) -> Callable[[Callable[P, R]], Callable[P, R]]: ...
19
- def get_open_span(logfire: Logfire, attributes: dict[str, otel_types.AttributeValue], span_name: str | None, extract_args: bool | Iterable[str], func: Callable[P, R], new_trace: bool) -> Callable[P, AbstractContextManager[Any]]: ...
18
+ def instrument(logfire: Logfire, tags: Sequence[str], msg_template: LiteralString | None, span_name: str | None, extract_args: bool | Iterable[str], record_return: bool, allow_generator: bool, new_trace: bool, level: LevelName | int | None = None) -> Callable[[Callable[P, R]], Callable[P, R]]: ...
19
+ def get_open_span(logfire: Logfire, attributes: dict[str, otel_types.AttributeValue], span_name: str | None, extract_args: bool | Iterable[str], func: Callable[P, R], new_trace: bool, level: LevelName | int | None = None) -> Callable[P, AbstractContextManager[Any]]: ...
20
20
  def get_attributes(func: Any, msg_template: str | None, tags: Sequence[str] | None) -> dict[str, otel_types.AttributeValue]: ...