logfire-api 5.3.0__tar.gz → 5.5.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.
- {logfire_api-5.3.0 → logfire_api-5.5.0}/PKG-INFO +1 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/__init__.py +11 -2
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/__init__.pyi +7 -2
- logfire_api-5.5.0/logfire_api/_internal/agent_sandboxes.pyi +42 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/run.pyi +15 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/config.pyi +25 -19
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/config_params.pyi +1 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/db_statement_summary.pyi +5 -0
- logfire_api-5.5.0/logfire_api/_internal/exporters/api_key_gate.pyi +40 -0
- logfire_api-5.5.0/logfire_api/_internal/fleet.pyi +30 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/formatter.pyi +1 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/executors.pyi +2 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/snowflake.pyi +1 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/main.pyi +74 -7
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/tracer.pyi +1 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/utils.pyi +13 -0
- logfire_api-5.5.0/logfire_api/fleet/__init__.pyi +3 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/logging.pyi +4 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/propagate.pyi +4 -3
- {logfire_api-5.3.0 → logfire_api-5.5.0}/pyproject.toml +1 -1
- {logfire_api-5.3.0 → logfire_api-5.5.0}/.gitignore +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/README.md +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/ast_utils.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/async_.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/auth.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/auto_trace/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/auto_trace/import_hook.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/auto_trace/rewrite_ast.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/auto_trace/types.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/baggage.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/ai_tools.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/auth.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/gateway.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/gateway_auth.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli/prompt.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/cli.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/collect_system_info.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/constants.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/console.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/dynamic_batch.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/logs.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/otlp.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/processor_wrapper.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/quiet_metrics.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/remove_pending.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/tail_sampling.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/wrapper.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/forwarding.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/http_transport.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/instrument.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/aiohttp_server.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/asgi.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/asyncpg.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/aws_lambda.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/celery.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/django.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/dspy.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/fastapi.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/flask.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/google_genai.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/httpx.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/litellm.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/litestar.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/mcp.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/monty.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/mysql.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/openai_agents.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/print.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/psycopg.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/pydantic_ai.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/pymongo.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/pytest.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/redis.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/requests.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/sqlite3.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/starlette.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/surrealdb.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/system_metrics.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/wsgi.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/interactive.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/json_encoder.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/json_formatter.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/json_schema.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/json_types.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/logs.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/metrics.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/scrubbing.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/server_response.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/stack_info.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/ulid.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/cli.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/db_api.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/exceptions.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/experimental/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/experimental/annotations.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/experimental/api_client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/experimental/datasets/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/experimental/query_client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/flask.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/httpx.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/loguru.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/psycopg.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/pydantic.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/redis.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/structlog.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/integrations/wsgi.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/py.typed +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/query_client.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/sampling/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/sampling/_tail_sampling.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/types.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/__init__.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/_handlebars.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/abstract.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/composition.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/config.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/local.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/remote.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/template_validation.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/variables/variable.pyi +0 -0
- {logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/version.pyi +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: logfire-api
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.5.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
|
|
@@ -17,7 +17,10 @@ except ImportError:
|
|
|
17
17
|
VERSION = '0.0.0'
|
|
18
18
|
METRICS_PREFERRED_TEMPORALITY = {}
|
|
19
19
|
|
|
20
|
-
def configure(*args, **kwargs):
|
|
20
|
+
def configure(*args, **kwargs) -> Logfire:
|
|
21
|
+
if kwargs.get('local'):
|
|
22
|
+
return Logfire()
|
|
23
|
+
return DEFAULT_LOGFIRE_INSTANCE
|
|
21
24
|
|
|
22
25
|
class LogfireSpan:
|
|
23
26
|
def __getattr__(self, attr):
|
|
@@ -155,6 +158,11 @@ except ImportError:
|
|
|
155
158
|
|
|
156
159
|
def instrument_monty(self, *args, **kwargs) -> None: ...
|
|
157
160
|
|
|
161
|
+
def agent_sandboxes(self, *args, **kwargs) -> Any:
|
|
162
|
+
raise RuntimeError(
|
|
163
|
+
"`logfire.agent_sandboxes()` requires the `logfire` package, install it with `pip install 'logfire[agent-sandboxes]'`"
|
|
164
|
+
)
|
|
165
|
+
|
|
158
166
|
def instrument_pymongo(self, *args, **kwargs) -> None: ...
|
|
159
167
|
|
|
160
168
|
def instrument_sqlalchemy(self, *args, **kwargs) -> None: ...
|
|
@@ -247,6 +255,7 @@ except ImportError:
|
|
|
247
255
|
instrument_pydantic = DEFAULT_LOGFIRE_INSTANCE.instrument_pydantic
|
|
248
256
|
instrument_pydantic_ai = DEFAULT_LOGFIRE_INSTANCE.instrument_pydantic_ai
|
|
249
257
|
instrument_monty = DEFAULT_LOGFIRE_INSTANCE.instrument_monty
|
|
258
|
+
agent_sandboxes = DEFAULT_LOGFIRE_INSTANCE.agent_sandboxes
|
|
250
259
|
instrument_fastapi = DEFAULT_LOGFIRE_INSTANCE.instrument_fastapi
|
|
251
260
|
instrument_openai = DEFAULT_LOGFIRE_INSTANCE.instrument_openai
|
|
252
261
|
instrument_openai_agents = DEFAULT_LOGFIRE_INSTANCE.instrument_openai_agents
|
|
@@ -283,7 +292,7 @@ except ImportError:
|
|
|
283
292
|
forward_export_request = DEFAULT_LOGFIRE_INSTANCE.forward_export_request
|
|
284
293
|
forward_export_request_starlette = DEFAULT_LOGFIRE_INSTANCE.forward_export_request_starlette
|
|
285
294
|
|
|
286
|
-
def loguru_handler() -> dict[str, Any]:
|
|
295
|
+
def loguru_handler(*, console_log: bool = True) -> dict[str, Any]:
|
|
287
296
|
return {}
|
|
288
297
|
|
|
289
298
|
def no_auto_trace(x):
|
|
@@ -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_monty', '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_litestar', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_snowflake', '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', 'template_var', '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']
|
|
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_monty', 'agent_sandboxes', '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_litestar', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_snowflake', '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', 'template_var', '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
|
|
@@ -27,6 +27,7 @@ install_auto_tracing = DEFAULT_LOGFIRE_INSTANCE.install_auto_tracing
|
|
|
27
27
|
instrument_pydantic = DEFAULT_LOGFIRE_INSTANCE.instrument_pydantic
|
|
28
28
|
instrument_pydantic_ai = DEFAULT_LOGFIRE_INSTANCE.instrument_pydantic_ai
|
|
29
29
|
instrument_monty = DEFAULT_LOGFIRE_INSTANCE.instrument_monty
|
|
30
|
+
agent_sandboxes = DEFAULT_LOGFIRE_INSTANCE.agent_sandboxes
|
|
30
31
|
instrument_asgi = DEFAULT_LOGFIRE_INSTANCE.instrument_asgi
|
|
31
32
|
instrument_wsgi = DEFAULT_LOGFIRE_INSTANCE.instrument_wsgi
|
|
32
33
|
instrument_fastapi = DEFAULT_LOGFIRE_INSTANCE.instrument_fastapi
|
|
@@ -86,9 +87,13 @@ variables_push_config = DEFAULT_LOGFIRE_INSTANCE.variables_push_config
|
|
|
86
87
|
variables_pull_config = DEFAULT_LOGFIRE_INSTANCE.variables_pull_config
|
|
87
88
|
variables_build_config = DEFAULT_LOGFIRE_INSTANCE.variables_build_config
|
|
88
89
|
|
|
89
|
-
def loguru_handler() -> Any:
|
|
90
|
+
def loguru_handler(*, console_log: bool = True) -> Any:
|
|
90
91
|
"""Create a **Logfire** handler for Loguru.
|
|
91
92
|
|
|
93
|
+
Args:
|
|
94
|
+
console_log: Whether Logfire also prints these logs to the console.
|
|
95
|
+
Set to `False` to keep Loguru's own console output without duplicates.
|
|
96
|
+
|
|
92
97
|
Returns:
|
|
93
98
|
A dictionary with the handler and format for Loguru.
|
|
94
99
|
"""
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from collections.abc import Awaitable as Awaitable, Callable, Mapping
|
|
2
|
+
from contextlib import AbstractAsyncContextManager
|
|
3
|
+
from logfire import Logfire as Logfire
|
|
4
|
+
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
5
|
+
from logfire.propagate import get_context as get_context
|
|
6
|
+
from pydantic_monty import AsyncMontyRemote, AsyncMontySession as AsyncMontySession, ExternalModule as ExternalModule, OSPolicy, ResourceLimits, TypeCheckFormat
|
|
7
|
+
from typing import Any
|
|
8
|
+
from typing_extensions import TypedDict, Unpack
|
|
9
|
+
|
|
10
|
+
class AgentSandboxCheckoutOptions(TypedDict, total=False):
|
|
11
|
+
"""Keyword options forwarded unchanged to AsyncMontyRemote.checkout."""
|
|
12
|
+
script_name: str
|
|
13
|
+
limits: ResourceLimits | None
|
|
14
|
+
type_check: bool
|
|
15
|
+
type_check_stubs: str | None
|
|
16
|
+
type_check_format: TypeCheckFormat | None
|
|
17
|
+
type_check_color: bool
|
|
18
|
+
assert_message_annotations: bool | int
|
|
19
|
+
print_flush_interval: float | None
|
|
20
|
+
os_policy: OSPolicy | None
|
|
21
|
+
external_modules: Mapping[str, ExternalModule | Callable[[], Awaitable[ExternalModule]]] | None
|
|
22
|
+
ephemeral: bool | None
|
|
23
|
+
profile: str | None
|
|
24
|
+
|
|
25
|
+
class AgentSandboxPool:
|
|
26
|
+
"""An async Monty remote pool that adds Logfire hints when checkout is refused.
|
|
27
|
+
|
|
28
|
+
Monty's native pool and refusal exception cannot be subclassed. Hinted refusals raise
|
|
29
|
+
RuntimeError, with the original MontyRefusedError available as the chained cause.
|
|
30
|
+
"""
|
|
31
|
+
def __init__(self, pool: AsyncMontyRemote) -> None: ...
|
|
32
|
+
async def __aenter__(self) -> AgentSandboxPool: ...
|
|
33
|
+
async def __aexit__(self, *args: Any) -> None: ...
|
|
34
|
+
def checkout(self, **kwargs: Unpack[AgentSandboxCheckoutOptions]) -> AbstractAsyncContextManager[AsyncMontySession]:
|
|
35
|
+
"""Check out a session with the options and defaults of AsyncMontyRemote.checkout."""
|
|
36
|
+
|
|
37
|
+
def agent_sandboxes_url(base_url: str) -> str:
|
|
38
|
+
"""Validate and normalize a supplied or derived Logfire Agent Sandboxes URL.
|
|
39
|
+
|
|
40
|
+
The client opens its gRPC stream at the root of this URL, so the base URL must not have a path.
|
|
41
|
+
"""
|
|
42
|
+
def create_agent_sandboxes(logfire_instance: Logfire, *, api_key: str | None, url: str | None, metadata: Callable[[], Mapping[str, str]] | None = None, connect_headers: Callable[[], Mapping[str, str]] | None = None, **kwargs: Any) -> AgentSandboxPool: ...
|
|
@@ -4,6 +4,7 @@ from collections.abc import Callable, Collection, Generator, Mapping
|
|
|
4
4
|
from contextlib import contextmanager
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from logfire._internal.utils import get_version as get_version
|
|
7
|
+
from opentelemetry.instrumentation.dependencies import DependencyConflict
|
|
7
8
|
from rich.console import Console
|
|
8
9
|
from rich.text import Text
|
|
9
10
|
|
|
@@ -48,9 +49,23 @@ def is_uv_installed() -> bool:
|
|
|
48
49
|
def instrument_packages(installed_otel_packages: set[str], instrument_pkg_map: dict[str, str]) -> list[str]:
|
|
49
50
|
"""Call every `logfire.instrument_x()` we can based on what's installed.
|
|
50
51
|
|
|
52
|
+
Packages without a Logfire method fall back to their own OpenTelemetry instrumentors.
|
|
53
|
+
|
|
51
54
|
Returns a list of packages that were successfully instrumented.
|
|
52
55
|
"""
|
|
53
56
|
def instrument_package(import_name: str, *args: str) -> None: ...
|
|
57
|
+
def warn_on_version_conflict(source: str, conflict: DependencyConflict) -> None:
|
|
58
|
+
"""Warn when an instrumented library is installed at a version its instrumentation doesn't support.
|
|
59
|
+
|
|
60
|
+
A library that isn't installed at all is skipped quietly, as `opentelemetry-instrument` does.
|
|
61
|
+
"""
|
|
62
|
+
def instrument_with_entry_points(otel_pkg_name: str) -> bool:
|
|
63
|
+
"""Call the `opentelemetry_instrumentor` entry points registered by an OpenTelemetry instrumentation package.
|
|
64
|
+
|
|
65
|
+
This follows `opentelemetry-instrument`, but passes Logfire's providers and warns on every failure,
|
|
66
|
+
including a missing module, where `opentelemetry-instrument` raises or only logs.
|
|
67
|
+
Returns whether at least one instrumentor was activated.
|
|
68
|
+
"""
|
|
54
69
|
def find_recommended_instrumentations_to_install(instrument_pkg_map: dict[str, str], installed_otel_pkgs: set[str], installed_pkgs: set[str], installed_versions: Mapping[str, str] | None = None) -> set[InstrumentationRecommendation]:
|
|
55
70
|
"""Determine which OpenTelemetry instrumentation packages are recommended for installation.
|
|
56
71
|
|
|
@@ -6,6 +6,7 @@ from ..types import ExceptionCallback as ExceptionCallback
|
|
|
6
6
|
from .client import InvalidProjectName as InvalidProjectName, LogfireClient as LogfireClient, ProjectAlreadyExists as ProjectAlreadyExists
|
|
7
7
|
from .config_params import CompressionValues as CompressionValues, ParamManager as ParamManager, PydanticPluginRecordValues as PydanticPluginRecordValues, normalize_token as normalize_token
|
|
8
8
|
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
|
+
from .exporters.api_key_gate import ApiKeyGatedLogExporter as ApiKeyGatedLogExporter, ApiKeyGatedMetricExporter as ApiKeyGatedMetricExporter, ApiKeyGatedSpanExporter as ApiKeyGatedSpanExporter, ApiKeyWriteAccess as ApiKeyWriteAccess
|
|
9
10
|
from .exporters.console import ConsoleColorsValues as ConsoleColorsValues, ConsoleLogExporter as ConsoleLogExporter, IndentedConsoleSpanExporter as IndentedConsoleSpanExporter, ShowParentsConsoleSpanExporter as ShowParentsConsoleSpanExporter, SimpleConsoleSpanExporter as SimpleConsoleSpanExporter
|
|
10
11
|
from .exporters.dynamic_batch import DynamicBatchSpanProcessor as DynamicBatchSpanProcessor
|
|
11
12
|
from .exporters.logs import CheckSuppressInstrumentationLogProcessorWrapper as CheckSuppressInstrumentationLogProcessorWrapper, MainLogProcessorWrapper as MainLogProcessorWrapper
|
|
@@ -14,6 +15,7 @@ from .exporters.processor_wrapper import CheckSuppressInstrumentationProcessorWr
|
|
|
14
15
|
from .exporters.quiet_metrics import QuietMetricExporter as QuietMetricExporter
|
|
15
16
|
from .exporters.remove_pending import RemovePendingSpansExporter as RemovePendingSpansExporter
|
|
16
17
|
from .exporters.test import TestExporter as TestExporter
|
|
18
|
+
from .fleet import FleetOptions as FleetOptions, LogfireFleetWarning as LogfireFleetWarning, load_fleet as load_fleet
|
|
17
19
|
from .forwarding import OTLPForwardingManager as OTLPForwardingManager
|
|
18
20
|
from .http_transport import install_connection_policy as install_connection_policy
|
|
19
21
|
from .integrations.executors import instrument_executors as instrument_executors
|
|
@@ -53,6 +55,7 @@ from typing_extensions import Self
|
|
|
53
55
|
|
|
54
56
|
CREDENTIALS_FILENAME: str
|
|
55
57
|
COMMON_REQUEST_HEADERS: Incomplete
|
|
58
|
+
API_KEY_CANNOT_WRITE_HINT: str
|
|
56
59
|
PROJECT_NAME_PATTERN: str
|
|
57
60
|
METRICS_PREFERRED_TEMPORALITY: Incomplete
|
|
58
61
|
|
|
@@ -145,7 +148,7 @@ class LocalVariablesOptions:
|
|
|
145
148
|
instrument: bool = ...
|
|
146
149
|
template_mismatch_policy: TemplateMismatchPolicy = ...
|
|
147
150
|
|
|
148
|
-
def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | list[str] | None = None, api_key: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, resource_attributes: Mapping[str, Any] | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | str | None = None, data_dir: Path | str | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, variables: VariablesOptions | LocalVariablesOptions | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None) -> Logfire:
|
|
151
|
+
def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | list[str] | None = None, api_key: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, resource_attributes: Mapping[str, Any] | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | str | None = None, data_dir: Path | str | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, code_source: CodeSource | None = None, variables: VariablesOptions | LocalVariablesOptions | None = None, distributed_tracing: bool | None = None, fleet: bool | FleetOptions | None = None, advanced: AdvancedOptions | None = None) -> Logfire:
|
|
149
152
|
"""Configure the logfire SDK.
|
|
150
153
|
|
|
151
154
|
Args:
|
|
@@ -165,6 +168,10 @@ def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-
|
|
|
165
168
|
|
|
166
169
|
If not provided, will be loaded from the `LOGFIRE_API_KEY` environment variable.
|
|
167
170
|
|
|
171
|
+
If no write token or project credentials file is found, the API key is also used to send
|
|
172
|
+
telemetry, unless `send_to_logfire` is `False`. This requires a project API key with the
|
|
173
|
+
`project:write_otlp` scope. Otherwise Logfire warns that the key cannot send telemetry.
|
|
174
|
+
|
|
168
175
|
service_name: Name of this service.
|
|
169
176
|
|
|
170
177
|
Defaults to the `LOGFIRE_SERVICE_NAME` environment variable.
|
|
@@ -221,12 +228,20 @@ def configure(*, local: bool = False, send_to_logfire: bool | Literal['if-token-
|
|
|
221
228
|
See the [Baggage documentation](https://logfire.pydantic.dev/docs/reference/advanced/baggage/) for more details.
|
|
222
229
|
code_source: Settings for the source code of the project.
|
|
223
230
|
variables: Options related to managed variables.
|
|
224
|
-
distributed_tracing: By default, incoming
|
|
231
|
+
distributed_tracing: By default, incoming context is extracted, but generates a warning.
|
|
225
232
|
Set to `True` to disable the warning.
|
|
226
|
-
Set to `False` to suppress extraction of incoming
|
|
233
|
+
Set to `False` to suppress extraction of all incoming context, preserving local context.
|
|
227
234
|
See [Unintentional Distributed Tracing](https://logfire.pydantic.dev/docs/how-to-guides/distributed-tracing/#unintentional-distributed-tracing)
|
|
228
235
|
for more information.
|
|
229
236
|
This setting always applies globally, and the last value set is used, including the default value.
|
|
237
|
+
fleet: Whether to manage this SDK from Logfire Fleet: the Fleet policy then applies to everything it sends
|
|
238
|
+
(sampling, which signals are sent, log levels, redaction and volume limits, the console included).
|
|
239
|
+
`True` takes the Fleet server from the `OTEL_OPAMP_*` environment variables; a
|
|
240
|
+
[`FleetOptions`][logfire.fleet.FleetOptions] gives it in code. Needs the 'fleet' extra.
|
|
241
|
+
It never blocks or raises: until Fleet answers, the last policy saved is in force, else the SDK's own
|
|
242
|
+
settings, and where Fleet can't be joined it warns and the SDK runs unmanaged.
|
|
243
|
+
|
|
244
|
+
Defaults to the `LOGFIRE_FLEET` environment variable, otherwise `False`.
|
|
230
245
|
advanced: Advanced options primarily used for testing by Logfire developers.
|
|
231
246
|
"""
|
|
232
247
|
|
|
@@ -259,17 +274,18 @@ class _LogfireConfigData:
|
|
|
259
274
|
code_source: CodeSource | None
|
|
260
275
|
variables: VariablesOptions | LocalVariablesOptions | None
|
|
261
276
|
distributed_tracing: bool | None
|
|
277
|
+
fleet: FleetOptions | Literal[False]
|
|
262
278
|
advanced: AdvancedOptions
|
|
263
279
|
|
|
264
280
|
class LogfireConfig(_LogfireConfigData):
|
|
265
|
-
def __init__(self, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | list[str] | None = None, api_key: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, resource_attributes: Mapping[str, Any] | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | None = None, data_dir: Path | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, variables: VariablesOptions | None = None, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None) -> None:
|
|
281
|
+
def __init__(self, send_to_logfire: bool | Literal['if-token-present'] | None = None, token: str | list[str] | None = None, api_key: str | None = None, service_name: str | None = None, service_version: str | None = None, environment: str | None = None, resource_attributes: Mapping[str, Any] | None = None, console: ConsoleOptions | Literal[False] | None = None, config_dir: Path | None = None, data_dir: Path | None = None, additional_span_processors: Sequence[SpanProcessor] | None = None, metrics: MetricsOptions | Literal[False] | None = None, scrubbing: ScrubbingOptions | Literal[False] | None = None, inspect_arguments: bool | None = None, sampling: SamplingOptions | None = None, min_level: int | LevelName | None = None, add_baggage_to_attributes: bool = True, variables: VariablesOptions | None = None, code_source: CodeSource | None = None, distributed_tracing: bool | None = None, advanced: AdvancedOptions | None = None, fleet: bool | FleetOptions | None = None) -> None:
|
|
266
282
|
"""Create a new LogfireConfig.
|
|
267
283
|
|
|
268
284
|
Users should never need to call this directly, instead use `logfire.configure`.
|
|
269
285
|
|
|
270
286
|
See `_LogfireConfigData` for parameter documentation.
|
|
271
287
|
"""
|
|
272
|
-
def configure(self, send_to_logfire: bool | Literal['if-token-present'] | None, token: str | list[str] | None, api_key: str | None, service_name: str | None, service_version: str | None, environment: str | None, resource_attributes: Mapping[str, Any] | None, console: ConsoleOptions | Literal[False] | None, config_dir: Path | None, data_dir: Path | None, additional_span_processors: Sequence[SpanProcessor] | None, metrics: MetricsOptions | Literal[False] | None, scrubbing: ScrubbingOptions | Literal[False] | None, inspect_arguments: bool | None, sampling: SamplingOptions | None, min_level: int | LevelName | None, add_baggage_to_attributes: bool, code_source: CodeSource | None, variables: VariablesOptions | LocalVariablesOptions | None, distributed_tracing: bool | None, advanced: AdvancedOptions | None) -> None: ...
|
|
288
|
+
def configure(self, send_to_logfire: bool | Literal['if-token-present'] | None, token: str | list[str] | None, api_key: str | None, service_name: str | None, service_version: str | None, environment: str | None, resource_attributes: Mapping[str, Any] | None, console: ConsoleOptions | Literal[False] | None, config_dir: Path | None, data_dir: Path | None, additional_span_processors: Sequence[SpanProcessor] | None, metrics: MetricsOptions | Literal[False] | None, scrubbing: ScrubbingOptions | Literal[False] | None, inspect_arguments: bool | None, sampling: SamplingOptions | None, min_level: int | LevelName | None, add_baggage_to_attributes: bool, code_source: CodeSource | None, variables: VariablesOptions | LocalVariablesOptions | None, distributed_tracing: bool | None, fleet: bool | FleetOptions | None, advanced: AdvancedOptions | None) -> None: ...
|
|
273
289
|
def initialize(self) -> None:
|
|
274
290
|
"""Configure internals to start exporting traces and metrics."""
|
|
275
291
|
def force_flush(self, timeout_millis: int = 30000) -> bool:
|
|
@@ -359,13 +375,16 @@ class LogfireCredentials:
|
|
|
359
375
|
LogfireConfigError: If the credentials file exists but is invalid.
|
|
360
376
|
"""
|
|
361
377
|
@classmethod
|
|
362
|
-
def from_token(cls, token: str, session: requests.Session, base_url: str) -> Self | None:
|
|
378
|
+
def from_token(cls, token: str, session: requests.Session, base_url: str, *, rejected_hint: str | None = None, on_rejected: Callable[[], None] | None = None) -> Self | None:
|
|
363
379
|
"""Check that the token is valid.
|
|
364
380
|
|
|
365
381
|
Issue a warning if the Logfire API is unreachable, or we get a response other than 200 or 401.
|
|
366
382
|
|
|
367
383
|
We continue unless we get a 401. If something is wrong, we'll later store data locally for back-fill.
|
|
368
384
|
|
|
385
|
+
`rejected_hint` is appended to the warning when the API rejects the token with a 401.
|
|
386
|
+
`on_rejected` is called for that 401 too.
|
|
387
|
+
|
|
369
388
|
Raises:
|
|
370
389
|
LogfireConfigError: If the token is invalid.
|
|
371
390
|
"""
|
|
@@ -407,19 +426,6 @@ class LogfireCredentials:
|
|
|
407
426
|
Raises:
|
|
408
427
|
LogfireConfigError: If there was an error creating projects.
|
|
409
428
|
"""
|
|
410
|
-
@classmethod
|
|
411
|
-
def initialize_project(cls, *, client: LogfireClient) -> Self:
|
|
412
|
-
"""Create a new project or use an existing project on logfire.dev requesting the given project name.
|
|
413
|
-
|
|
414
|
-
Args:
|
|
415
|
-
client: The Logfire client to use when making requests.
|
|
416
|
-
|
|
417
|
-
Returns:
|
|
418
|
-
The new credentials.
|
|
419
|
-
|
|
420
|
-
Raises:
|
|
421
|
-
LogfireConfigError: If there was an error on creating/configuring the project.
|
|
422
|
-
"""
|
|
423
429
|
def write_creds_file(self, creds_dir: Path) -> None:
|
|
424
430
|
"""Write a credentials file to the given path."""
|
|
425
431
|
def print_token_summary(self) -> None:
|
|
@@ -26,6 +26,11 @@ def summarize_query(db_statement: str) -> str | None:
|
|
|
26
26
|
|
|
27
27
|
"""
|
|
28
28
|
def select(expr: str, table: str, *, match_end: int, db_statement: str, ctes: str | None = None, sub_query: str | None = None) -> str: ...
|
|
29
|
+
def outside_parentheses(s: str) -> str:
|
|
30
|
+
"""Remove everything inside parentheses, including the parentheses themselves.
|
|
31
|
+
|
|
32
|
+
Parentheses inside quoted strings or identifiers don't change the nesting depth.
|
|
33
|
+
"""
|
|
29
34
|
def truncate(s: str, length: int) -> str: ...
|
|
30
35
|
|
|
31
36
|
FALLBACK_HALF: Incomplete
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from .wrapper import WrapperLogExporter as WrapperLogExporter, WrapperMetricExporter as WrapperMetricExporter, WrapperSpanExporter as WrapperSpanExporter
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from opentelemetry.sdk._logs import ReadableLogRecord as ReadableLogRecord
|
|
5
|
+
from opentelemetry.sdk._logs.export import LogRecordExportResult, LogRecordExporter
|
|
6
|
+
from opentelemetry.sdk.metrics.export import MetricExportResult, MetricExporter, MetricsData
|
|
7
|
+
from opentelemetry.sdk.trace import ReadableSpan as ReadableSpan
|
|
8
|
+
from opentelemetry.sdk.trace.export import SpanExportResult, SpanExporter
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
VERDICT_TIMEOUT_SECONDS: int
|
|
12
|
+
|
|
13
|
+
class ApiKeyWriteAccess:
|
|
14
|
+
"""The result of the token check for an API key that is used as a write token."""
|
|
15
|
+
def __init__(self) -> None: ...
|
|
16
|
+
def reject(self) -> None:
|
|
17
|
+
"""Record that Logfire rejected the API key as a write token."""
|
|
18
|
+
def settle(self) -> None:
|
|
19
|
+
"""Record that the check finished. A key that the check did not reject stays allowed."""
|
|
20
|
+
def allows_export(self) -> bool:
|
|
21
|
+
"""Wait for the check, then tell if exports can use the key.
|
|
22
|
+
|
|
23
|
+
If the check does not finish in time, the export continues.
|
|
24
|
+
The exporters then report any failure as they do for a write token.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
class ApiKeyGatedSpanExporter(WrapperSpanExporter):
|
|
28
|
+
access: Incomplete
|
|
29
|
+
def __init__(self, exporter: SpanExporter, access: ApiKeyWriteAccess) -> None: ...
|
|
30
|
+
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult: ...
|
|
31
|
+
|
|
32
|
+
class ApiKeyGatedLogExporter(WrapperLogExporter):
|
|
33
|
+
access: Incomplete
|
|
34
|
+
def __init__(self, exporter: LogRecordExporter, access: ApiKeyWriteAccess) -> None: ...
|
|
35
|
+
def export(self, batch: Sequence[ReadableLogRecord]) -> LogRecordExportResult: ...
|
|
36
|
+
|
|
37
|
+
class ApiKeyGatedMetricExporter(WrapperMetricExporter):
|
|
38
|
+
access: Incomplete
|
|
39
|
+
def __init__(self, exporter: MetricExporter, access: ApiKeyWriteAccess, **kwargs: Any) -> None: ...
|
|
40
|
+
def export(self, metrics_data: MetricsData, timeout_millis: float = 10000, **kwargs: Any) -> MetricExportResult: ...
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
from .stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
3
|
+
from .utils import platform_is_emscripten as platform_is_emscripten
|
|
4
|
+
from collections.abc import Mapping
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
from logfire_fleet_otel import LogfireFleet
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
FLEET_CONTRACT: int
|
|
10
|
+
|
|
11
|
+
@dataclasses.dataclass
|
|
12
|
+
class FleetOptions:
|
|
13
|
+
"""Options for joining Logfire Fleet.
|
|
14
|
+
|
|
15
|
+
Each one left as `None` comes from its environment variable, which is what the Fleet setup page
|
|
16
|
+
in Logfire gives you.
|
|
17
|
+
"""
|
|
18
|
+
endpoint: str | None = ...
|
|
19
|
+
headers: Mapping[str, str] | None = ...
|
|
20
|
+
state_dir: str | Path | None = ...
|
|
21
|
+
heartbeat_interval: float | timedelta | None = ...
|
|
22
|
+
|
|
23
|
+
class LogfireFleetWarning(UserWarning):
|
|
24
|
+
"""The SDK couldn't join Logfire Fleet, so it runs unmanaged."""
|
|
25
|
+
|
|
26
|
+
def load_fleet(options: FleetOptions) -> LogfireFleet | None:
|
|
27
|
+
"""The Fleet client's hook for `options`, or `None` (with a warning) where it can't run.
|
|
28
|
+
|
|
29
|
+
It never raises: telemetry is sent either way, under the SDK's own settings.
|
|
30
|
+
"""
|
|
@@ -28,7 +28,7 @@ class ChunksFormatter(Formatter):
|
|
|
28
28
|
chunks_formatter: Incomplete
|
|
29
29
|
|
|
30
30
|
def logfire_format(format_string: str, kwargs: dict[str, Any], scrubber: BaseScrubber) -> str: ...
|
|
31
|
-
def logfire_format_with_magic(format_string:
|
|
31
|
+
def logfire_format_with_magic(format_string: Any, kwargs: dict[str, Any], scrubber: BaseScrubber, fstring_frame: types.FrameType | None = None) -> tuple[str, dict[str, Any], str]: ...
|
|
32
32
|
@lru_cache
|
|
33
33
|
def compile_formatted_value(node: ast.FormattedValue, ex_source: executing.Source) -> tuple[str, CodeType, CodeType]:
|
|
34
34
|
"""Returns three things that can be expensive to compute.
|
|
@@ -2,9 +2,11 @@ from ..stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
|
2
2
|
from _typeshed import Incomplete
|
|
3
3
|
from collections.abc import Callable
|
|
4
4
|
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
|
|
5
|
+
from contextvars import ContextVar as ContextVar
|
|
5
6
|
from logfire.propagate import ContextCarrier as ContextCarrier, attach_context as attach_context, get_context as get_context
|
|
6
7
|
from typing import Any
|
|
7
8
|
|
|
9
|
+
THREAD_CONTEXTVARS: list[ContextVar[Any]]
|
|
8
10
|
submit_t_orig: Incomplete
|
|
9
11
|
submit_p_orig: Incomplete
|
|
10
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from logfire import Logfire as Logfire
|
|
2
2
|
from logfire._internal.stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
3
|
-
from logfire._internal.utils import handle_internal_errors as handle_internal_errors
|
|
3
|
+
from logfire._internal.utils import get_version as get_version, handle_internal_errors as handle_internal_errors
|
|
4
4
|
from snowflake.connector.connection import SnowflakeConnection
|
|
5
5
|
from types import ModuleType
|
|
6
6
|
|
|
@@ -16,10 +16,11 @@ from ..integrations.sqlalchemy import CommenterOptions as SQLAlchemyCommenterOpt
|
|
|
16
16
|
from ..integrations.wsgi import RequestHook as WSGIRequestHook, ResponseHook as WSGIResponseHook
|
|
17
17
|
from ..variables import ResolveFunction as ResolveFunction, TemplateVariable as TemplateVariable, ValidationReport as ValidationReport, Variable as Variable, VariablesConfig as VariablesConfig
|
|
18
18
|
from ..version import VERSION as VERSION
|
|
19
|
+
from .agent_sandboxes import AgentSandboxPool as AgentSandboxPool
|
|
19
20
|
from .auto_trace import AutoTraceModule as AutoTraceModule, install_auto_tracing as install_auto_tracing
|
|
20
21
|
from .config import GLOBAL_CONFIG as GLOBAL_CONFIG, LogfireConfig as LogfireConfig, TemplateMismatchPolicy as TemplateMismatchPolicy
|
|
21
22
|
from .config_params import PydanticPluginRecordValues as PydanticPluginRecordValues
|
|
22
|
-
from .constants import ATTRIBUTES_JSON_SCHEMA_KEY as ATTRIBUTES_JSON_SCHEMA_KEY, ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, DISABLE_CONSOLE_KEY as DISABLE_CONSOLE_KEY,
|
|
23
|
+
from .constants import ATTRIBUTES_JSON_SCHEMA_KEY as ATTRIBUTES_JSON_SCHEMA_KEY, ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, DISABLE_CONSOLE_KEY as DISABLE_CONSOLE_KEY, LevelName as LevelName, OTLP_MAX_INT_SIZE as OTLP_MAX_INT_SIZE, log_level_attributes as log_level_attributes
|
|
23
24
|
from .formatter import logfire_format as logfire_format, logfire_format_with_magic as logfire_format_with_magic
|
|
24
25
|
from .forwarding import ForwardExportRequestResponse as ForwardExportRequestResponse
|
|
25
26
|
from .instrument import instrument as instrument
|
|
@@ -34,12 +35,13 @@ from .json_encoder import logfire_json_dumps as logfire_json_dumps
|
|
|
34
35
|
from .json_schema import JsonSchemaProperties as JsonSchemaProperties, attributes_json_schema as attributes_json_schema, attributes_json_schema_properties as attributes_json_schema_properties, create_json_schema as create_json_schema
|
|
35
36
|
from .metrics import ProxyMeterProvider as ProxyMeterProvider
|
|
36
37
|
from .stack_info import get_user_stack_info as get_user_stack_info
|
|
37
|
-
from .tracer import ProxyTracerProvider as ProxyTracerProvider, _ProxyTracer
|
|
38
|
+
from .tracer import ProxyTracerProvider as ProxyTracerProvider, _ProxyTracer
|
|
38
39
|
from .utils import SysExcInfo as SysExcInfo, get_version as get_version, handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, uniquify_sequence as uniquify_sequence
|
|
39
40
|
from anthropic.lib.bedrock import AnthropicBedrock as _AnthropicBedrock, AsyncAnthropicBedrock as _AsyncAnthropicBedrock
|
|
40
41
|
from collections.abc import Iterable, Mapping, Sequence
|
|
41
42
|
from contextlib import AbstractContextManager
|
|
42
43
|
from django.http import HttpRequest as HttpRequest, HttpResponse as HttpResponse
|
|
44
|
+
from enum import Enum
|
|
43
45
|
from fastapi import FastAPI
|
|
44
46
|
from flask.app import Flask
|
|
45
47
|
from litestar import Litestar
|
|
@@ -69,6 +71,9 @@ ExcInfo = SysExcInfo | BaseException | bool | None
|
|
|
69
71
|
T = TypeVar('T')
|
|
70
72
|
InputsT = TypeVar('InputsT')
|
|
71
73
|
|
|
74
|
+
class _Unset(Enum):
|
|
75
|
+
UNSET: str
|
|
76
|
+
|
|
72
77
|
class Logfire:
|
|
73
78
|
"""The main logfire class."""
|
|
74
79
|
def __init__(self, *, config: LogfireConfig = ..., sample_rate: float | None = None, tags: Sequence[str] = (), console_log: bool = True, otel_scope: str = 'logfire') -> None: ...
|
|
@@ -244,7 +249,8 @@ class Logfire:
|
|
|
244
249
|
```
|
|
245
250
|
|
|
246
251
|
Args:
|
|
247
|
-
msg_template:
|
|
252
|
+
msg_template: A string template for the span message. Passing another type emits a formatting
|
|
253
|
+
warning and uses its `str()` representation without interpolating it.
|
|
248
254
|
_span_name: The span name. If not provided, the `msg_template` will be used.
|
|
249
255
|
_tags: An optional sequence of tags to include in the span.
|
|
250
256
|
_level: An optional log level name.
|
|
@@ -313,7 +319,8 @@ class Logfire:
|
|
|
313
319
|
|
|
314
320
|
Args:
|
|
315
321
|
level: The level of the log.
|
|
316
|
-
msg_template:
|
|
322
|
+
msg_template: A string message or template. Passing another type emits a formatting warning
|
|
323
|
+
and uses its `str()` representation without interpolating it.
|
|
317
324
|
attributes: The attributes to bind to the log.
|
|
318
325
|
tags: An optional sequence of tags to include in the log.
|
|
319
326
|
exc_info: Set to an exception or a tuple as returned by [`sys.exc_info()`][sys.exc_info]
|
|
@@ -520,6 +527,66 @@ class Logfire:
|
|
|
520
527
|
It records Monty sessions, executed code, inputs, outputs, external calls,
|
|
521
528
|
exceptions, printed text, and pool metrics. Recorded values are subject to Logfire's configured scrubbing.
|
|
522
529
|
"""
|
|
530
|
+
def agent_sandboxes(self, *, api_key: str | None = None, url: str | None = None, max_processes: int | None | _Unset = ..., checkout_timeout: float | None | _Unset = ..., request_timeout: float | None | _Unset = ..., metadata: Callable[[], Mapping[str, str]] | None | _Unset = ..., connect_headers: Callable[[], Mapping[str, str]] | None | _Unset = ..., feed_duration_limit_grace: float | None | _Unset = ..., turn_duration_limit_grace: float | None | _Unset = ..., auto_resume: bool | _Unset = ..., **kwargs: Any) -> AgentSandboxPool:
|
|
531
|
+
"""Connect to Logfire Agent Sandboxes, remote Pydantic Monty workers hosted by Logfire.
|
|
532
|
+
|
|
533
|
+
Requires the `agent-sandboxes` extra, e.g. `pip install 'logfire[agent-sandboxes]'`.
|
|
534
|
+
|
|
535
|
+
Returns a wrapper around a [`pydantic_monty.AsyncMontyRemote`][pydantic_monty.AsyncMontyRemote] pool;
|
|
536
|
+
use it as an async context manager and check out sessions from it:
|
|
537
|
+
|
|
538
|
+
```py
|
|
539
|
+
import logfire
|
|
540
|
+
|
|
541
|
+
logfire.configure()
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
async def main():
|
|
545
|
+
async with logfire.agent_sandboxes() as pool:
|
|
546
|
+
async with pool.checkout() as session:
|
|
547
|
+
result = await session.feed_run('1 + 1')
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
No connection is made until a session is checked out.
|
|
551
|
+
|
|
552
|
+
Checkout accepts the same options and yields the same Monty sessions as `AsyncMontyRemote`.
|
|
553
|
+
Authentication and capacity refusals raise `RuntimeError` with Logfire hints, chained from
|
|
554
|
+
the original `MontyRefusedError`. Other errors pass through unchanged.
|
|
555
|
+
|
|
556
|
+
The Logfire platform records sandbox usage itself. The current trace context is sent
|
|
557
|
+
with each session so those spans join the caller's trace.
|
|
558
|
+
|
|
559
|
+
Omitted pool options use the defaults of the installed `pydantic-monty-client` version.
|
|
560
|
+
The defaults described below are the currently assumed defaults and may change in future versions.
|
|
561
|
+
|
|
562
|
+
Args:
|
|
563
|
+
api_key: A Logfire project API key (not a personal key) with the
|
|
564
|
+
`project:execute_agent_sandboxes` scope. Agent Sandboxes must be enabled for the project.
|
|
565
|
+
Defaults to the `api_key` passed to [`configure()`][logfire.configure],
|
|
566
|
+
then the `LOGFIRE_API_KEY` environment variable.
|
|
567
|
+
url: The `https://` URL of the sandboxes server.
|
|
568
|
+
Defaults to the Logfire region the API key belongs to. Must not contain a path,
|
|
569
|
+
query, or fragment. `/monty-ws/` was the old path and must be removed.
|
|
570
|
+
max_processes: Cap on concurrent sandbox sessions. Defaults to `None`, which uses
|
|
571
|
+
the CPU count; checkouts beyond it wait.
|
|
572
|
+
checkout_timeout: Seconds `checkout()` waits for capacity before raising `TimeoutError`.
|
|
573
|
+
Defaults to `None`, which waits forever.
|
|
574
|
+
request_timeout: Hard per-turn deadline in seconds. A sandbox that exceeds it has its
|
|
575
|
+
session closed and the call raises `MontyCrashedError`. Must be finite;
|
|
576
|
+
`None` raises `LogfireConfigError` because hosted sandboxes require a deadline.
|
|
577
|
+
Defaults to `10.0`. Raise this when installing dependencies in a sandbox.
|
|
578
|
+
metadata: Called once per session to produce extra request metadata for its gRPC
|
|
579
|
+
stream. Names are lowercased and values must be ASCII. These are merged with the
|
|
580
|
+
`authorization` entry and win on conflicts.
|
|
581
|
+
connect_headers: The deprecated name of `metadata`.
|
|
582
|
+
Defaults to `None`, which adds no extra headers beyond Logfire authentication.
|
|
583
|
+
feed_duration_limit_grace: Seconds to wait past a feed's `max_feed_duration_secs`
|
|
584
|
+
before closing the sandbox. Defaults to `1.0`; `None` disables this backstop.
|
|
585
|
+
turn_duration_limit_grace: The same, for `max_turn_duration_secs`. Defaults to `1.0`.
|
|
586
|
+
auto_resume: When the server drains a stored session, transparently resume it on
|
|
587
|
+
another server instead of raising `MontyShutdown`. Defaults to `True`.
|
|
588
|
+
kwargs: Additional keyword arguments passed to `AsyncMontyRemote` for future compatibility.
|
|
589
|
+
"""
|
|
523
590
|
def instrument_fastapi(self, app: FastAPI, *, capture_headers: bool = False, request_attributes_mapper: Callable[[Request | WebSocket, dict[str, Any]], dict[str, Any] | None] | None = None, excluded_urls: str | Iterable[str] | None = None, record_send_receive: bool = False, extra_spans: bool = False, **opentelemetry_kwargs: Any) -> AbstractContextManager[None]:
|
|
524
591
|
"""Instrument a FastAPI app so that spans and logs are automatically created for each request.
|
|
525
592
|
|
|
@@ -590,7 +657,7 @@ class Logfire:
|
|
|
590
657
|
logfire.instrument_openai(client)
|
|
591
658
|
|
|
592
659
|
response = client.chat.completions.create(
|
|
593
|
-
model=\'gpt-
|
|
660
|
+
model=\'gpt-5-mini\',
|
|
594
661
|
messages=[
|
|
595
662
|
{\'role\': \'system\', \'content\': \'You are a helpful assistant.\'},
|
|
596
663
|
{\'role\': \'user\', \'content\': \'What is four plus five?\'},
|
|
@@ -641,7 +708,7 @@ class Logfire:
|
|
|
641
708
|
|
|
642
709
|
- [`client.messages.create`](https://docs.anthropic.com/en/api/messages)
|
|
643
710
|
- [`client.messages.stream`](https://docs.anthropic.com/en/api/messages-streaming)
|
|
644
|
-
- [`client.beta.
|
|
711
|
+
- [`client.beta.messages.create`](https://docs.anthropic.com/en/docs/tool-use)
|
|
645
712
|
|
|
646
713
|
When `stream=True` a second span is created to instrument the streamed response.
|
|
647
714
|
|
|
@@ -658,7 +725,7 @@ class Logfire:
|
|
|
658
725
|
logfire.instrument_anthropic(client)
|
|
659
726
|
|
|
660
727
|
response = client.messages.create(
|
|
661
|
-
model=\'claude-
|
|
728
|
+
model=\'claude-haiku-5-5\',
|
|
662
729
|
system=\'You are a helpful assistant.\',
|
|
663
730
|
messages=[
|
|
664
731
|
{\'role\': \'user\', \'content\': \'What is four plus five?\'},
|
|
@@ -2,7 +2,7 @@ import opentelemetry.trace as trace_api
|
|
|
2
2
|
from ..types import ExceptionCallback as ExceptionCallback
|
|
3
3
|
from .config import LogfireConfig as LogfireConfig
|
|
4
4
|
from .constants import ATTRIBUTES_EXCEPTION_FINGERPRINT_KEY as ATTRIBUTES_EXCEPTION_FINGERPRINT_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY as ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_VALIDATION_ERROR_KEY as ATTRIBUTES_VALIDATION_ERROR_KEY, log_level_attributes as log_level_attributes
|
|
5
|
-
from .utils import handle_internal_errors as handle_internal_errors, is_instrumentation_suppressed as is_instrumentation_suppressed, sha256_string as sha256_string
|
|
5
|
+
from .utils import handle_internal_errors as handle_internal_errors, is_instrumentation_suppressed as is_instrumentation_suppressed, safe_str as safe_str, safe_type_name as safe_type_name, sha256_string as sha256_string
|
|
6
6
|
from _typeshed import Incomplete
|
|
7
7
|
from collections.abc import Callable, Mapping, Sequence
|
|
8
8
|
from dataclasses import dataclass, field
|
|
@@ -32,6 +32,19 @@ def uniquify_sequence(seq: Sequence[T]) -> tuple[T, ...]:
|
|
|
32
32
|
"""Remove duplicates from a sequence preserving order."""
|
|
33
33
|
def safe_repr(obj: Any) -> str:
|
|
34
34
|
"""Return some kind of non-empty string representation of an object, catching exceptions."""
|
|
35
|
+
def safe_str(obj: Any) -> str:
|
|
36
|
+
"""Return `str(obj)`, or a placeholder if calling `str()` itself raises.
|
|
37
|
+
|
|
38
|
+
Some objects (notably exceptions that were never fully initialised) raise from `__str__`.
|
|
39
|
+
Callers on the telemetry path must never let that abort their own work, so the placeholder
|
|
40
|
+
deliberately avoids looking anything up on the object or its class.
|
|
41
|
+
"""
|
|
42
|
+
def safe_type_name(obj: Any) -> str:
|
|
43
|
+
"""Return the bare class name of `obj`, or a placeholder if that lookup raises.
|
|
44
|
+
|
|
45
|
+
A metaclass can turn `__name__` into a property that raises, so even reading the class
|
|
46
|
+
name is not safe on the telemetry path.
|
|
47
|
+
"""
|
|
35
48
|
Truncatable = TypeVar('Truncatable', str, bytes, 'list[Any]', 'tuple[Any, ...]')
|
|
36
49
|
|
|
37
50
|
def truncate_string(s: str, *, max_length: int, middle: str = '...') -> str:
|
|
@@ -15,11 +15,14 @@ class LogfireLoggingHandler(LoggingHandler):
|
|
|
15
15
|
level: The threshold level for this handler. Logging messages which are less severe than *level* will be ignored.
|
|
16
16
|
fallback: A fallback handler to use when [instrumentation is suppressed](../../how-to-guides/suppress.md#suppress-instrumentation).
|
|
17
17
|
logfire_instance: The Logfire instance to use when emitting logs. Defaults to the default global instance.
|
|
18
|
+
console_log: Whether logs from this handler are also printed to the console by Logfire.
|
|
19
|
+
Set to `False` if another handler already prints them, to avoid duplicates.
|
|
20
|
+
Defaults to the setting of `logfire_instance`.
|
|
18
21
|
"""
|
|
19
22
|
custom_scope_suffix: ClassVar[str]
|
|
20
23
|
fallback: Incomplete
|
|
21
24
|
logfire_instance: Incomplete
|
|
22
|
-
def __init__(self, level: int | str = ..., fallback: LoggingHandler = ..., logfire_instance: Logfire | None = None) -> None: ...
|
|
25
|
+
def __init__(self, level: int | str = ..., fallback: LoggingHandler = ..., logfire_instance: Logfire | None = None, console_log: bool | None = None) -> None: ...
|
|
23
26
|
def emit(self, record: LogRecord) -> None:
|
|
24
27
|
"""Send the log to Logfire.
|
|
25
28
|
|
|
@@ -61,15 +61,16 @@ class WrapperPropagator(TextMapPropagator):
|
|
|
61
61
|
def fields(self): ...
|
|
62
62
|
|
|
63
63
|
class NoExtractTraceContextPropagator(WrapperPropagator):
|
|
64
|
-
"""A propagator that ignores
|
|
64
|
+
"""A propagator that ignores all incoming context and preserves local context.
|
|
65
65
|
|
|
66
|
-
Used when `logfire.configure(distributed_tracing=False)` is called.
|
|
66
|
+
Used when `logfire.configure(distributed_tracing=False)` is called. Extraction returns the
|
|
67
|
+
supplied context, or the current context if none is supplied, without calling the wrapped propagator.
|
|
67
68
|
"""
|
|
68
69
|
def extract(self, carrier: Any, context: otel_context.Context | None = None, *args: Any, **kwargs: Any) -> otel_context.Context: ...
|
|
69
70
|
|
|
70
71
|
@dataclass
|
|
71
72
|
class WarnOnExtractTraceContextPropagator(WrapperPropagator):
|
|
72
|
-
"""A propagator that warns the first time that
|
|
73
|
+
"""A propagator that warns the first time that incoming context is extracted by the wrapped propagator.
|
|
73
74
|
|
|
74
75
|
Used when `logfire.configure(distributed_tracing=None)` is called. This is the default behavior.
|
|
75
76
|
"""
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "logfire-api"
|
|
7
|
-
version = "5.
|
|
7
|
+
version = "5.5.0"
|
|
8
8
|
description = "Shim for the Logfire SDK which does nothing unless Logfire is installed"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Pydantic Team", email = "engineering@pydantic.dev" },
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/exporters/processor_wrapper.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/aiohttp_client.pyi
RENAMED
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/aiohttp_server.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/openai_agents.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.3.0 → logfire_api-5.5.0}/logfire_api/_internal/integrations/system_metrics.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|