logfire-sdk 5.3.0__py3-none-any.whl
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_sdk/logfire/.agents/skills/logfire-evals/SKILL.md +170 -0
- _logfire_sdk/logfire/.agents/skills/logfire-gateway/SKILL.md +156 -0
- _logfire_sdk/logfire/.agents/skills/logfire-infrastructure/SKILL.md +61 -0
- _logfire_sdk/logfire/.agents/skills/logfire-infrastructure/references/collector/host-and-infra-metrics.md +229 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/SKILL.md +292 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/auth.md +100 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/ai-sdk.md +145 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/cloudflare-and-deno.md +99 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/frameworks.md +22 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/installation-and-env.md +75 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/nextjs.md +78 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/node-runtime.md +132 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/patterns.md +184 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/project-detection.md +43 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/react-browser.md +18 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/verification-troubleshooting.md +68 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/python/integrations.md +104 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/python/logging-patterns.md +120 -0
- _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/rust/patterns.md +113 -0
- _logfire_sdk/logfire/.agents/skills/logfire-setup/SKILL.md +58 -0
- _logfire_sdk/logfire/.agents/skills/logfire-setup-offline.md +715 -0
- _logfire_sdk/logfire/__init__.py +226 -0
- _logfire_sdk/logfire/__main__.py +6 -0
- _logfire_sdk/logfire/_internal/__init__.py +14 -0
- _logfire_sdk/logfire/_internal/ast_utils.py +264 -0
- _logfire_sdk/logfire/_internal/async_.py +125 -0
- _logfire_sdk/logfire/_internal/auth.py +298 -0
- _logfire_sdk/logfire/_internal/auto_trace/__init__.py +74 -0
- _logfire_sdk/logfire/_internal/auto_trace/import_hook.py +137 -0
- _logfire_sdk/logfire/_internal/auto_trace/rewrite_ast.py +185 -0
- _logfire_sdk/logfire/_internal/auto_trace/types.py +44 -0
- _logfire_sdk/logfire/_internal/baggage.py +109 -0
- _logfire_sdk/logfire/_internal/cli/__init__.py +1081 -0
- _logfire_sdk/logfire/_internal/cli/ai_tools.py +231 -0
- _logfire_sdk/logfire/_internal/cli/auth.py +151 -0
- _logfire_sdk/logfire/_internal/cli/gateway.py +627 -0
- _logfire_sdk/logfire/_internal/cli/gateway_auth.py +313 -0
- _logfire_sdk/logfire/_internal/cli/prompt.py +50 -0
- _logfire_sdk/logfire/_internal/cli/run.py +590 -0
- _logfire_sdk/logfire/_internal/client.py +178 -0
- _logfire_sdk/logfire/_internal/collect_system_info.py +29 -0
- _logfire_sdk/logfire/_internal/config.py +2471 -0
- _logfire_sdk/logfire/_internal/config_params.py +343 -0
- _logfire_sdk/logfire/_internal/constants.py +185 -0
- _logfire_sdk/logfire/_internal/db_statement_summary.py +140 -0
- _logfire_sdk/logfire/_internal/exporters/__init__.py +1 -0
- _logfire_sdk/logfire/_internal/exporters/console.py +517 -0
- _logfire_sdk/logfire/_internal/exporters/dynamic_batch.py +49 -0
- _logfire_sdk/logfire/_internal/exporters/logs.py +30 -0
- _logfire_sdk/logfire/_internal/exporters/otlp.py +517 -0
- _logfire_sdk/logfire/_internal/exporters/processor_wrapper.py +652 -0
- _logfire_sdk/logfire/_internal/exporters/quiet_metrics.py +18 -0
- _logfire_sdk/logfire/_internal/exporters/remove_pending.py +45 -0
- _logfire_sdk/logfire/_internal/exporters/test.py +257 -0
- _logfire_sdk/logfire/_internal/exporters/wrapper.py +106 -0
- _logfire_sdk/logfire/_internal/formatter.py +379 -0
- _logfire_sdk/logfire/_internal/forwarding.py +585 -0
- _logfire_sdk/logfire/_internal/http_transport.py +193 -0
- _logfire_sdk/logfire/_internal/instrument.py +254 -0
- _logfire_sdk/logfire/_internal/integrations/__init__.py +1 -0
- _logfire_sdk/logfire/_internal/integrations/aiohttp_client.py +324 -0
- _logfire_sdk/logfire/_internal/integrations/aiohttp_server.py +22 -0
- _logfire_sdk/logfire/_internal/integrations/asgi.py +117 -0
- _logfire_sdk/logfire/_internal/integrations/asyncpg.py +21 -0
- _logfire_sdk/logfire/_internal/integrations/aws_lambda.py +36 -0
- _logfire_sdk/logfire/_internal/integrations/celery.py +20 -0
- _logfire_sdk/logfire/_internal/integrations/claude_agent_sdk.py +628 -0
- _logfire_sdk/logfire/_internal/integrations/django.py +41 -0
- _logfire_sdk/logfire/_internal/integrations/dspy.py +20 -0
- _logfire_sdk/logfire/_internal/integrations/executors.py +99 -0
- _logfire_sdk/logfire/_internal/integrations/fastapi.py +421 -0
- _logfire_sdk/logfire/_internal/integrations/flask.py +53 -0
- _logfire_sdk/logfire/_internal/integrations/google_genai.py +66 -0
- _logfire_sdk/logfire/_internal/integrations/httpx.py +577 -0
- _logfire_sdk/logfire/_internal/integrations/litellm.py +20 -0
- _logfire_sdk/logfire/_internal/integrations/litestar.py +77 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/anthropic.py +406 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/llm_provider.py +251 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/openai.py +892 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/semconv.py +194 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/types.py +36 -0
- _logfire_sdk/logfire/_internal/integrations/llm_providers/usage.py +89 -0
- _logfire_sdk/logfire/_internal/integrations/mcp.py +191 -0
- _logfire_sdk/logfire/_internal/integrations/monty.py +155 -0
- _logfire_sdk/logfire/_internal/integrations/mysql.py +34 -0
- _logfire_sdk/logfire/_internal/integrations/openai_agents.py +460 -0
- _logfire_sdk/logfire/_internal/integrations/print.py +176 -0
- _logfire_sdk/logfire/_internal/integrations/psycopg.py +126 -0
- _logfire_sdk/logfire/_internal/integrations/pydantic_ai.py +65 -0
- _logfire_sdk/logfire/_internal/integrations/pymongo.py +40 -0
- _logfire_sdk/logfire/_internal/integrations/pytest.py +648 -0
- _logfire_sdk/logfire/_internal/integrations/redis.py +57 -0
- _logfire_sdk/logfire/_internal/integrations/requests.py +34 -0
- _logfire_sdk/logfire/_internal/integrations/snowflake.py +162 -0
- _logfire_sdk/logfire/_internal/integrations/sqlalchemy.py +70 -0
- _logfire_sdk/logfire/_internal/integrations/sqlite3.py +29 -0
- _logfire_sdk/logfire/_internal/integrations/starlette.py +50 -0
- _logfire_sdk/logfire/_internal/integrations/surrealdb.py +137 -0
- _logfire_sdk/logfire/_internal/integrations/system_metrics.py +322 -0
- _logfire_sdk/logfire/_internal/integrations/wsgi.py +34 -0
- _logfire_sdk/logfire/_internal/interactive.py +115 -0
- _logfire_sdk/logfire/_internal/json_encoder.py +344 -0
- _logfire_sdk/logfire/_internal/json_formatter.py +350 -0
- _logfire_sdk/logfire/_internal/json_schema.py +455 -0
- _logfire_sdk/logfire/_internal/json_types.py +147 -0
- _logfire_sdk/logfire/_internal/logs.py +142 -0
- _logfire_sdk/logfire/_internal/main.py +3498 -0
- _logfire_sdk/logfire/_internal/metrics.py +283 -0
- _logfire_sdk/logfire/_internal/scrubbing.py +404 -0
- _logfire_sdk/logfire/_internal/server_response.py +44 -0
- _logfire_sdk/logfire/_internal/stack_info.py +147 -0
- _logfire_sdk/logfire/_internal/tracer.py +538 -0
- _logfire_sdk/logfire/_internal/ulid.py +40 -0
- _logfire_sdk/logfire/_internal/utils.py +550 -0
- _logfire_sdk/logfire/cli.py +3 -0
- _logfire_sdk/logfire/db_api.py +393 -0
- _logfire_sdk/logfire/exceptions.py +9 -0
- _logfire_sdk/logfire/experimental/__init__.py +0 -0
- _logfire_sdk/logfire/experimental/annotations.py +80 -0
- _logfire_sdk/logfire/experimental/api_client.py +1421 -0
- _logfire_sdk/logfire/integrations/__init__.py +4 -0
- _logfire_sdk/logfire/integrations/aiohttp_client.py +12 -0
- _logfire_sdk/logfire/integrations/flask.py +26 -0
- _logfire_sdk/logfire/integrations/httpx.py +49 -0
- _logfire_sdk/logfire/integrations/logging.py +153 -0
- _logfire_sdk/logfire/integrations/loguru.py +98 -0
- _logfire_sdk/logfire/integrations/psycopg.py +23 -0
- _logfire_sdk/logfire/integrations/pydantic.py +541 -0
- _logfire_sdk/logfire/integrations/redis.py +31 -0
- _logfire_sdk/logfire/integrations/sqlalchemy.py +12 -0
- _logfire_sdk/logfire/integrations/structlog.py +55 -0
- _logfire_sdk/logfire/integrations/wsgi.py +15 -0
- _logfire_sdk/logfire/propagate.py +161 -0
- _logfire_sdk/logfire/py.typed +0 -0
- _logfire_sdk/logfire/query_client.py +701 -0
- _logfire_sdk/logfire/sampling/__init__.py +9 -0
- _logfire_sdk/logfire/sampling/_tail_sampling.py +292 -0
- _logfire_sdk/logfire/testing.py +127 -0
- _logfire_sdk/logfire/types.py +303 -0
- _logfire_sdk/logfire/variables/__init__.py +154 -0
- _logfire_sdk/logfire/variables/_handlebars.py +77 -0
- _logfire_sdk/logfire/variables/abstract.py +2027 -0
- _logfire_sdk/logfire/variables/composition.py +430 -0
- _logfire_sdk/logfire/variables/config.py +694 -0
- _logfire_sdk/logfire/variables/local.py +134 -0
- _logfire_sdk/logfire/variables/remote.py +877 -0
- _logfire_sdk/logfire/variables/template_validation.py +208 -0
- _logfire_sdk/logfire/variables/variable.py +1299 -0
- _logfire_sdk/logfire/version.py +5 -0
- logfire/.agents/skills/logfire-evals/SKILL.md +170 -0
- logfire/.agents/skills/logfire-gateway/SKILL.md +156 -0
- logfire/.agents/skills/logfire-infrastructure/SKILL.md +61 -0
- logfire/.agents/skills/logfire-infrastructure/references/collector/host-and-infra-metrics.md +229 -0
- logfire/.agents/skills/logfire-instrumentation/SKILL.md +292 -0
- logfire/.agents/skills/logfire-instrumentation/references/auth.md +100 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/ai-sdk.md +145 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/cloudflare-and-deno.md +99 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/frameworks.md +22 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/installation-and-env.md +75 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/nextjs.md +78 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/node-runtime.md +132 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/patterns.md +184 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/project-detection.md +43 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/react-browser.md +18 -0
- logfire/.agents/skills/logfire-instrumentation/references/javascript/verification-troubleshooting.md +68 -0
- logfire/.agents/skills/logfire-instrumentation/references/python/integrations.md +104 -0
- logfire/.agents/skills/logfire-instrumentation/references/python/logging-patterns.md +120 -0
- logfire/.agents/skills/logfire-instrumentation/references/rust/patterns.md +113 -0
- logfire/.agents/skills/logfire-setup/SKILL.md +58 -0
- logfire/.agents/skills/logfire-setup-offline.md +715 -0
- logfire/__init__.py +226 -0
- logfire/__main__.py +6 -0
- logfire/_internal/__init__.py +14 -0
- logfire/_internal/ast_utils.py +264 -0
- logfire/_internal/async_.py +125 -0
- logfire/_internal/auth.py +298 -0
- logfire/_internal/auto_trace/__init__.py +74 -0
- logfire/_internal/auto_trace/import_hook.py +137 -0
- logfire/_internal/auto_trace/rewrite_ast.py +185 -0
- logfire/_internal/auto_trace/types.py +44 -0
- logfire/_internal/baggage.py +109 -0
- logfire/_internal/cli/__init__.py +1081 -0
- logfire/_internal/cli/ai_tools.py +231 -0
- logfire/_internal/cli/auth.py +151 -0
- logfire/_internal/cli/gateway.py +627 -0
- logfire/_internal/cli/gateway_auth.py +313 -0
- logfire/_internal/cli/prompt.py +50 -0
- logfire/_internal/cli/run.py +590 -0
- logfire/_internal/client.py +178 -0
- logfire/_internal/collect_system_info.py +29 -0
- logfire/_internal/config.py +2471 -0
- logfire/_internal/config_params.py +343 -0
- logfire/_internal/constants.py +185 -0
- logfire/_internal/db_statement_summary.py +140 -0
- logfire/_internal/exporters/__init__.py +1 -0
- logfire/_internal/exporters/console.py +517 -0
- logfire/_internal/exporters/dynamic_batch.py +49 -0
- logfire/_internal/exporters/logs.py +30 -0
- logfire/_internal/exporters/otlp.py +517 -0
- logfire/_internal/exporters/processor_wrapper.py +652 -0
- logfire/_internal/exporters/quiet_metrics.py +18 -0
- logfire/_internal/exporters/remove_pending.py +45 -0
- logfire/_internal/exporters/test.py +257 -0
- logfire/_internal/exporters/wrapper.py +106 -0
- logfire/_internal/formatter.py +379 -0
- logfire/_internal/forwarding.py +585 -0
- logfire/_internal/http_transport.py +193 -0
- logfire/_internal/instrument.py +254 -0
- logfire/_internal/integrations/__init__.py +1 -0
- logfire/_internal/integrations/aiohttp_client.py +324 -0
- logfire/_internal/integrations/aiohttp_server.py +22 -0
- logfire/_internal/integrations/asgi.py +117 -0
- logfire/_internal/integrations/asyncpg.py +21 -0
- logfire/_internal/integrations/aws_lambda.py +36 -0
- logfire/_internal/integrations/celery.py +20 -0
- logfire/_internal/integrations/claude_agent_sdk.py +628 -0
- logfire/_internal/integrations/django.py +41 -0
- logfire/_internal/integrations/dspy.py +20 -0
- logfire/_internal/integrations/executors.py +99 -0
- logfire/_internal/integrations/fastapi.py +421 -0
- logfire/_internal/integrations/flask.py +53 -0
- logfire/_internal/integrations/google_genai.py +66 -0
- logfire/_internal/integrations/httpx.py +577 -0
- logfire/_internal/integrations/litellm.py +20 -0
- logfire/_internal/integrations/litestar.py +77 -0
- logfire/_internal/integrations/llm_providers/anthropic.py +406 -0
- logfire/_internal/integrations/llm_providers/llm_provider.py +251 -0
- logfire/_internal/integrations/llm_providers/openai.py +892 -0
- logfire/_internal/integrations/llm_providers/semconv.py +194 -0
- logfire/_internal/integrations/llm_providers/types.py +36 -0
- logfire/_internal/integrations/llm_providers/usage.py +89 -0
- logfire/_internal/integrations/mcp.py +191 -0
- logfire/_internal/integrations/monty.py +155 -0
- logfire/_internal/integrations/mysql.py +34 -0
- logfire/_internal/integrations/openai_agents.py +460 -0
- logfire/_internal/integrations/print.py +176 -0
- logfire/_internal/integrations/psycopg.py +126 -0
- logfire/_internal/integrations/pydantic_ai.py +65 -0
- logfire/_internal/integrations/pymongo.py +40 -0
- logfire/_internal/integrations/pytest.py +648 -0
- logfire/_internal/integrations/redis.py +57 -0
- logfire/_internal/integrations/requests.py +34 -0
- logfire/_internal/integrations/snowflake.py +162 -0
- logfire/_internal/integrations/sqlalchemy.py +70 -0
- logfire/_internal/integrations/sqlite3.py +29 -0
- logfire/_internal/integrations/starlette.py +50 -0
- logfire/_internal/integrations/surrealdb.py +137 -0
- logfire/_internal/integrations/system_metrics.py +322 -0
- logfire/_internal/integrations/wsgi.py +34 -0
- logfire/_internal/interactive.py +115 -0
- logfire/_internal/json_encoder.py +344 -0
- logfire/_internal/json_formatter.py +350 -0
- logfire/_internal/json_schema.py +455 -0
- logfire/_internal/json_types.py +147 -0
- logfire/_internal/logs.py +142 -0
- logfire/_internal/main.py +3498 -0
- logfire/_internal/metrics.py +283 -0
- logfire/_internal/scrubbing.py +404 -0
- logfire/_internal/server_response.py +44 -0
- logfire/_internal/stack_info.py +147 -0
- logfire/_internal/tracer.py +538 -0
- logfire/_internal/ulid.py +40 -0
- logfire/_internal/utils.py +550 -0
- logfire/cli.py +3 -0
- logfire/db_api.py +393 -0
- logfire/exceptions.py +9 -0
- logfire/experimental/__init__.py +0 -0
- logfire/experimental/annotations.py +80 -0
- logfire/experimental/api_client.py +1421 -0
- logfire/integrations/__init__.py +4 -0
- logfire/integrations/aiohttp_client.py +12 -0
- logfire/integrations/flask.py +26 -0
- logfire/integrations/httpx.py +49 -0
- logfire/integrations/logging.py +153 -0
- logfire/integrations/loguru.py +98 -0
- logfire/integrations/psycopg.py +23 -0
- logfire/integrations/pydantic.py +541 -0
- logfire/integrations/redis.py +31 -0
- logfire/integrations/sqlalchemy.py +12 -0
- logfire/integrations/structlog.py +55 -0
- logfire/integrations/wsgi.py +15 -0
- logfire/propagate.py +161 -0
- logfire/py.typed +0 -0
- logfire/query_client.py +701 -0
- logfire/sampling/__init__.py +9 -0
- logfire/sampling/_tail_sampling.py +292 -0
- logfire/testing.py +127 -0
- logfire/types.py +303 -0
- logfire/variables/__init__.py +154 -0
- logfire/variables/_handlebars.py +77 -0
- logfire/variables/abstract.py +2027 -0
- logfire/variables/composition.py +430 -0
- logfire/variables/config.py +694 -0
- logfire/variables/local.py +134 -0
- logfire/variables/remote.py +877 -0
- logfire/variables/template_validation.py +208 -0
- logfire/variables/variable.py +1299 -0
- logfire/version.py +5 -0
- logfire_sdk-5.3.0.dist-info/METADATA +140 -0
- logfire_sdk-5.3.0.dist-info/RECORD +304 -0
- logfire_sdk-5.3.0.dist-info/WHEEL +4 -0
- logfire_sdk-5.3.0.dist-info/entry_points.txt +6 -0
- logfire_sdk-5.3.0.dist-info/licenses/LICENSE +21 -0
- logfire_sdk.pth +2 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Python Integration Reference
|
|
2
|
+
|
|
3
|
+
## Web Frameworks
|
|
4
|
+
|
|
5
|
+
| Framework | Instrumentor | Needs app instance | Extra |
|
|
6
|
+
|-----------|-------------|-------------------|-------|
|
|
7
|
+
| FastAPI | `logfire.instrument_fastapi(app)` | Yes | `fastapi` |
|
|
8
|
+
| Django | `logfire.instrument_django()` | No | `django` |
|
|
9
|
+
| Flask | `logfire.instrument_flask(app)` | Yes | `flask` |
|
|
10
|
+
| Starlette | `logfire.instrument_starlette(app)` | Yes | `starlette` |
|
|
11
|
+
| Any ASGI app | `app = logfire.instrument_asgi(app)` | Yes | `asgi` |
|
|
12
|
+
| Any WSGI app | `app = logfire.instrument_wsgi(app)` | Yes | `wsgi` |
|
|
13
|
+
|
|
14
|
+
## HTTP Clients
|
|
15
|
+
|
|
16
|
+
| Library | Instrumentor | Extra |
|
|
17
|
+
|---------|-------------|-------|
|
|
18
|
+
| httpx | `logfire.instrument_httpx()` | `httpx` |
|
|
19
|
+
| requests | `logfire.instrument_requests()` | `requests` |
|
|
20
|
+
| aiohttp (client) | `logfire.instrument_aiohttp_client()` | `aiohttp` or `aiohttp-client` |
|
|
21
|
+
| aiohttp (server) | `logfire.instrument_aiohttp_server()` | `aiohttp-server` |
|
|
22
|
+
|
|
23
|
+
## Databases
|
|
24
|
+
|
|
25
|
+
| Library | Instrumentor | Extra |
|
|
26
|
+
|---------|-------------|-------|
|
|
27
|
+
| asyncpg | `logfire.instrument_asyncpg()` | `asyncpg` |
|
|
28
|
+
| psycopg | `logfire.instrument_psycopg()` | `psycopg` |
|
|
29
|
+
| psycopg2 | `logfire.instrument_psycopg2()` | `psycopg2` |
|
|
30
|
+
| SQLAlchemy | `logfire.instrument_sqlalchemy()` | `sqlalchemy` |
|
|
31
|
+
| PyMongo | `logfire.instrument_pymongo()` | `pymongo` |
|
|
32
|
+
| MySQL | `logfire.instrument_mysql()` | `mysql` |
|
|
33
|
+
| SQLite3 | `logfire.instrument_sqlite3()` | `sqlite3` |
|
|
34
|
+
| Redis | `logfire.instrument_redis()` | `redis` |
|
|
35
|
+
| Snowflake | `logfire.instrument_snowflake()` | no extra (`snowflake-connector-python`) |
|
|
36
|
+
|
|
37
|
+
## AI/LLM Frameworks
|
|
38
|
+
|
|
39
|
+
PydanticAI, OpenAI, and Anthropic need **no Logfire extra** — install the library itself (`uv add pydantic-ai` / `uv add openai` / `uv add anthropic`); Logfire's own AI extras are `litellm`, `dspy`, and `google-genai`.
|
|
40
|
+
|
|
41
|
+
| Framework | Instrumentor | Requirement |
|
|
42
|
+
|-----------|-------------|-------|
|
|
43
|
+
| PydanticAI | `logfire.instrument_pydantic_ai()` | `pydantic-ai` installed (no extra) |
|
|
44
|
+
| OpenAI | `logfire.instrument_openai()` | `openai` installed (no extra) |
|
|
45
|
+
| OpenAI Agents SDK | `logfire.instrument_openai_agents()` | `openai-agents` installed; imports as `agents` (no extra) |
|
|
46
|
+
| Anthropic | `logfire.instrument_anthropic()` | `anthropic` installed (no extra) |
|
|
47
|
+
| Claude Agent SDK | `logfire.instrument_claude_agent_sdk()` | `claude_agent_sdk` installed (no extra) |
|
|
48
|
+
| LiteLLM | `logfire.instrument_litellm()` | `litellm` extra |
|
|
49
|
+
| DSPy | `logfire.instrument_dspy()` | `dspy` extra |
|
|
50
|
+
| Google GenAI | `logfire.instrument_google_genai()` | `google-genai` extra |
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import logfire
|
|
54
|
+
|
|
55
|
+
logfire.configure()
|
|
56
|
+
logfire.instrument_pydantic_ai() # captures agent runs, tool calls, LLM request/response
|
|
57
|
+
# or:
|
|
58
|
+
logfire.instrument_openai() # captures chat completions, embeddings, token counts
|
|
59
|
+
logfire.instrument_anthropic() # captures messages, token usage
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For PydanticAI, each agent run becomes a parent span containing child spans for every tool call and LLM request. See the main skill's Agent Frameworks table for coverage depth across other frameworks (LangChain, CrewAI, AutoGen, ...).
|
|
63
|
+
|
|
64
|
+
## Task Queues
|
|
65
|
+
|
|
66
|
+
| Framework | Instrumentor | Extra |
|
|
67
|
+
|-----------|-------------|-------|
|
|
68
|
+
| Celery | `logfire.instrument_celery()` | `celery` |
|
|
69
|
+
|
|
70
|
+
## Other
|
|
71
|
+
|
|
72
|
+
| Feature | Instrumentor | Requirement |
|
|
73
|
+
|---------|-------------|-------|
|
|
74
|
+
| System Metrics | `logfire.instrument_system_metrics()` | `system-metrics` extra |
|
|
75
|
+
| Pydantic model validation | `logfire.instrument_pydantic()` | no extra (distinct from `instrument_pydantic_ai()` above) |
|
|
76
|
+
| AWS Lambda | handler wrapper | `aws-lambda` extra |
|
|
77
|
+
| SurrealDB | `logfire.instrument_surrealdb()` | no extra |
|
|
78
|
+
| MCP (client and server) | `logfire.instrument_mcp()` (mcp 1 only; mcp 2 and fastmcp 4 emit spans by themselves, so `logfire.configure()` is enough and the call just warns) | no extra |
|
|
79
|
+
| `print()` redirection | `logfire.instrument_print()` | no extra |
|
|
80
|
+
|
|
81
|
+
`gateway`, `datasets`, and `variables` are extras too, but for separate product features, not app instrumentation: the AI Gateway proxy, the evals SDK (see the `logfire-evals` skill), and managed feature flags respectively.
|
|
82
|
+
|
|
83
|
+
## Gunicorn Configuration
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
# gunicorn.conf.py
|
|
87
|
+
import logfire
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def post_fork(server, worker):
|
|
91
|
+
logfire.configure()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def post_worker_init(worker):
|
|
95
|
+
logfire.instrument_flask(worker.wsgi)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This example is specific to Flask: configure Logfire in `post_fork`, then
|
|
99
|
+
instrument the loaded Flask application in `post_worker_init`. This preserves
|
|
100
|
+
Gunicorn's application-loading lifecycle when preload mode is disabled and
|
|
101
|
+
installs instrumentation in each worker when it is enabled. Other frameworks
|
|
102
|
+
have different call signatures and placement requirements; follow their row in
|
|
103
|
+
the table above and their integration documentation rather than mechanically
|
|
104
|
+
substituting another `instrument_*()` call here.
|
_logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/python/logging-patterns.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Python Logging Patterns
|
|
2
|
+
|
|
3
|
+
## Log Levels
|
|
4
|
+
|
|
5
|
+
From lowest to highest severity:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
logfire.trace("Detailed trace {detail}", detail=x)
|
|
9
|
+
logfire.debug("Debug info {state}", state=s)
|
|
10
|
+
logfire.info("Normal operation {event}", event=e)
|
|
11
|
+
logfire.notice("Notable event {event}", event=e)
|
|
12
|
+
logfire.warn("Warning {issue}", issue=i)
|
|
13
|
+
logfire.error("Error occurred {error}", error=err)
|
|
14
|
+
logfire.fatal("Fatal error {error}", error=err)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Nested Spans
|
|
18
|
+
|
|
19
|
+
Spans nest to create a tree visible in the Logfire UI. Use them to show the structure of an operation, not just that it happened:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
async def send_request(url: str):
|
|
23
|
+
with logfire.span("HTTP request {method} {url}", method="POST", url=url):
|
|
24
|
+
with logfire.span("Serialize payload"):
|
|
25
|
+
payload = model.model_dump_json()
|
|
26
|
+
with logfire.span("Send request"):
|
|
27
|
+
response = await client.post(url, content=payload)
|
|
28
|
+
logfire.info("Response {status}", status=response.status_code)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Exceptions
|
|
32
|
+
|
|
33
|
+
Use `logfire.exception()`, which automatically captures the traceback:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
async def handle_order(order_id: int):
|
|
37
|
+
try:
|
|
38
|
+
await process_order(order_id)
|
|
39
|
+
except Exception:
|
|
40
|
+
logfire.exception('Failed to process order {order_id}', order_id=order_id)
|
|
41
|
+
raise
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Standard Library Logging Integration
|
|
45
|
+
|
|
46
|
+
For projects that already use Python's `logging` module, route existing log calls through Logfire rather than rewriting them all:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from logging import getLogger
|
|
50
|
+
|
|
51
|
+
import logfire
|
|
52
|
+
|
|
53
|
+
logfire.configure()
|
|
54
|
+
getLogger().addHandler(logfire.LogfireLoggingHandler())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This explicitly adds the Logfire handler even when the application configured other root handlers first. Keep those handlers and the application's existing logging threshold unless the user asks to change them. Python's root logger defaults to `WARNING`; if the application has not chosen a threshold and should send `INFO` records, set the root logger to `INFO` alongside this handler. Do not lower an intentional threshold.
|
|
58
|
+
|
|
59
|
+
If the application already owns its complete `dictConfig`, add Logfire to that configuration. The `root.handlers` list replaces existing root handlers, so include every intended console, file, and Logfire handler there. This minimal example intentionally makes Logfire the only root handler:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from logging.config import dictConfig
|
|
63
|
+
|
|
64
|
+
import logfire
|
|
65
|
+
|
|
66
|
+
logfire.configure()
|
|
67
|
+
dictConfig({
|
|
68
|
+
'version': 1,
|
|
69
|
+
'disable_existing_loggers': False,
|
|
70
|
+
'handlers': {
|
|
71
|
+
'logfire': {'class': 'logfire.LogfireLoggingHandler'},
|
|
72
|
+
},
|
|
73
|
+
'root': {'level': 'INFO', 'handlers': ['logfire']},
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Suppressing Noisy Libraries
|
|
78
|
+
|
|
79
|
+
Some libraries emit excessive debug logs. Silence them at the `logging` level:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import logging
|
|
83
|
+
|
|
84
|
+
logging.getLogger('httpcore').setLevel(logging.WARNING)
|
|
85
|
+
logging.getLogger('httpx').setLevel(logging.WARNING)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Custom Metrics
|
|
89
|
+
|
|
90
|
+
For dashboards and alerting, create metrics:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
counter = logfire.metric_counter("orders_processed", unit="1")
|
|
94
|
+
counter.add(1, {"status": "success"})
|
|
95
|
+
|
|
96
|
+
histogram = logfire.metric_histogram("request_duration", unit="s")
|
|
97
|
+
histogram.record(0.123, {"endpoint": "/api/users"})
|
|
98
|
+
|
|
99
|
+
gauge = logfire.metric_gauge("active_connections")
|
|
100
|
+
gauge.set(42)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Testing with capfire
|
|
104
|
+
|
|
105
|
+
Use the `capfire` pytest fixture to assert on emitted spans without sending data to production:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from logfire.testing import CaptureLogfire
|
|
109
|
+
|
|
110
|
+
def test_order_processing(capfire: CaptureLogfire) -> None:
|
|
111
|
+
process_order(order_id=123)
|
|
112
|
+
|
|
113
|
+
spans = capfire.exporter.exported_spans_as_dict()
|
|
114
|
+
assert any(
|
|
115
|
+
span['attributes'].get('order_id') == 123
|
|
116
|
+
for span in spans
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Configure logfire with `send_to_logfire=False` in test fixtures to prevent production data leakage.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Rust Patterns
|
|
2
|
+
|
|
3
|
+
## Core Macros
|
|
4
|
+
|
|
5
|
+
The Rust SDK is built on `tracing` and `opentelemetry`. All `tracing` macros work automatically with Logfire.
|
|
6
|
+
|
|
7
|
+
### Events (log points)
|
|
8
|
+
|
|
9
|
+
```rust
|
|
10
|
+
logfire::trace!("Detailed trace {detail}", detail = x);
|
|
11
|
+
logfire::debug!("Debug info {state}", state = s);
|
|
12
|
+
logfire::info!("Normal operation {event}", event = e);
|
|
13
|
+
logfire::warn!("Warning {issue}", issue = i);
|
|
14
|
+
logfire::error!("Error occurred {err}", err = e);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Spans
|
|
18
|
+
|
|
19
|
+
```rust
|
|
20
|
+
// Scoped - span closes when closure completes
|
|
21
|
+
logfire::span!("Processing order {order_id}", order_id = id).in_scope(|| {
|
|
22
|
+
let items = fetch_items(id);
|
|
23
|
+
logfire::info!("Fetched {count} items", count = items.len());
|
|
24
|
+
process_items(items)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Guard-based - span closes when guard is dropped
|
|
28
|
+
let _guard = logfire::span!("Long operation {job_id}", job_id = id).entered();
|
|
29
|
+
do_work();
|
|
30
|
+
// span ends when _guard goes out of scope
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
```rust
|
|
36
|
+
use logfire;
|
|
37
|
+
|
|
38
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
39
|
+
let logfire = logfire::configure()
|
|
40
|
+
.finish()?;
|
|
41
|
+
let shutdown_handler = logfire.shutdown_guard();
|
|
42
|
+
|
|
43
|
+
// application code...
|
|
44
|
+
|
|
45
|
+
shutdown_handler.shutdown()?; // flush all pending spans
|
|
46
|
+
Ok(())
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Panic capture is enabled by default. Keep the shutdown guard on the main stack
|
|
51
|
+
so a panic still flushes. Call `.with_install_panic_handler(false)` before
|
|
52
|
+
`.finish()` only to disable the hook.
|
|
53
|
+
|
|
54
|
+
Set `LOGFIRE_TOKEN` in your environment or follow the
|
|
55
|
+
[authentication and project-selection flow](../auth.md), including `projects use`,
|
|
56
|
+
to create `.logfire/logfire_credentials.json` for the selected project.
|
|
57
|
+
|
|
58
|
+
## Tracing Crate Compatibility
|
|
59
|
+
|
|
60
|
+
Any library using `tracing` macros automatically sends data through Logfire:
|
|
61
|
+
|
|
62
|
+
```rust
|
|
63
|
+
use tracing;
|
|
64
|
+
|
|
65
|
+
tracing::info!("This also appears in Logfire");
|
|
66
|
+
|
|
67
|
+
#[tracing::instrument]
|
|
68
|
+
fn my_function(param: &str) {
|
|
69
|
+
// automatically creates a span with param as an attribute
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Log Crate Integration
|
|
74
|
+
|
|
75
|
+
The `log` crate is automatically captured and forwarded to Logfire. Libraries using `log::info!()`, `log::error!()`, etc. will appear in your Logfire dashboard without any additional configuration.
|
|
76
|
+
|
|
77
|
+
## Async Spans
|
|
78
|
+
|
|
79
|
+
```rust
|
|
80
|
+
use tracing::Instrument;
|
|
81
|
+
|
|
82
|
+
async fn process_order(order_id: u64) {
|
|
83
|
+
let span = logfire::span!("process order {order_id}", order_id = order_id);
|
|
84
|
+
async {
|
|
85
|
+
fetch_items(order_id).await;
|
|
86
|
+
logfire::info!("Order processed");
|
|
87
|
+
}
|
|
88
|
+
.instrument(span)
|
|
89
|
+
.await;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Shutdown
|
|
94
|
+
|
|
95
|
+
Always call `shutdown()` before program exit to flush pending data:
|
|
96
|
+
|
|
97
|
+
```rust
|
|
98
|
+
// In main()
|
|
99
|
+
let logfire = logfire::configure().finish()?;
|
|
100
|
+
let shutdown_handler = logfire.shutdown_guard();
|
|
101
|
+
|
|
102
|
+
// ... app runs ...
|
|
103
|
+
|
|
104
|
+
// Before exit
|
|
105
|
+
shutdown_handler.shutdown()?;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
For web servers using `tokio`, handle shutdown via signal:
|
|
109
|
+
|
|
110
|
+
```rust
|
|
111
|
+
tokio::signal::ctrl_c().await?;
|
|
112
|
+
shutdown_handler.shutdown()?;
|
|
113
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: logfire-setup
|
|
3
|
+
description: Route broad requests to set up Pydantic Logfire across application instrumentation, infrastructure, evals, frontend observability, Gateway, or coding agents. Use for "set up Logfire", "add Logfire to my project", "get me set up properly with Logfire", "send as much data as would be useful", mentions of Logfire without specific scope, or multi-surface requests; use the matching specialist directly for an already scoped request.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Set Up Logfire
|
|
7
|
+
|
|
8
|
+
Route each explicitly requested surface to its specialist below; leave installation
|
|
9
|
+
and verification to those specialists. Do not expand an otherwise scoped request.
|
|
10
|
+
|
|
11
|
+
Proceed through ordinary, reversible setup with short updates without asking
|
|
12
|
+
approval; no clean tree, branch, commits, or plan is required. Pause for browser
|
|
13
|
+
auth, unresolved app/project ambiguity, material production cost or telemetry
|
|
14
|
+
increases, deploy/infra changes, or destructive/unrelated work, then ask one
|
|
15
|
+
concrete question. Report only
|
|
16
|
+
verification observed in this session.
|
|
17
|
+
|
|
18
|
+
## Step 1: Authenticate and Select the Exact Project
|
|
19
|
+
|
|
20
|
+
If the request is already scoped to frontend observability, application Gateway,
|
|
21
|
+
coding-agent setup, querying, or opening the UI, load that specialist from the
|
|
22
|
+
table below first. Its credential requirements differ from ordinary SDK
|
|
23
|
+
instrumentation; do not create a project write token merely to route the request.
|
|
24
|
+
|
|
25
|
+
For ordinary SDK instrumentation, confirm the exact project with `whoami`
|
|
26
|
+
before inspecting or running application files.
|
|
27
|
+
|
|
28
|
+
Use [Authenticate and Select the Exact Project](https://pydantic.dev/.well-known/agent-skills/logfire-instrumentation/references/auth.md) to derive the CLI target from the supplied Logfire URL and run its target-aware `whoami` check with a verified CLI path — for JS/TS projects without `uv`, use the external-prefix npm fallback instead of plain `npx`, which can execute a repository-local binary. Skip to Step 2 if that already reports the right project and resolved `--region` or `--base-url` target; otherwise, continue through the full authentication and project-selection sequence there.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Step 2: Understand the Repo
|
|
32
|
+
|
|
33
|
+
Read `AGENTS.md`/`CLAUDE.md`/`README.md` and skim the language, runtime, and package manager. Then match what you find against the table below to decide what to fetch next:
|
|
34
|
+
|
|
35
|
+
| Surface | Covers | Skill |
|
|
36
|
+
|---------|--------|-------|
|
|
37
|
+
| App instrumentation | Traces, logs, metrics, and AI/agent spans from application code — Python, JavaScript/TypeScript, Rust, or any OpenTelemetry language | [`logfire-instrumentation`](https://pydantic.dev/.well-known/agent-skills/logfire-instrumentation/SKILL.md) |
|
|
38
|
+
| Frontend observability | Browser errors, RUM, Web Vitals, and session replays | [`logfire-frontend`](https://pydantic.dev/.well-known/agent-skills/logfire-frontend/SKILL.md) |
|
|
39
|
+
| Infrastructure monitoring | Hosts, Docker, Kubernetes, database/queue/cache servers, cloud-provider metrics — no application code | [`logfire-infrastructure`](https://pydantic.dev/.well-known/agent-skills/logfire-infrastructure/SKILL.md) |
|
|
40
|
+
| Evals | Set up and run AI/agent evaluations against test-case datasets in Python or Node.js | [`logfire-evals`](https://pydantic.dev/.well-known/agent-skills/logfire-evals/SKILL.md) |
|
|
41
|
+
| Querying telemetry | Search traces/logs/spans/metrics, summarize errors, find root cause | [`logfire-query`](https://pydantic.dev/.well-known/agent-skills/logfire-query/SKILL.md) |
|
|
42
|
+
| Live UI | Open project pages, the live view, trace links, or the Explore page in a browser | [`logfire-ui`](https://pydantic.dev/.well-known/agent-skills/logfire-ui/SKILL.md) |
|
|
43
|
+
| Feature flags | Runtime-managed variables (`logfire.var()`, `logfire.template_var()`) | no dedicated skill yet — see the product's own docs |
|
|
44
|
+
| Application Gateway | Route an application's model calls through Pydantic AI Gateway | [`logfire-gateway`](https://pydantic.dev/.well-known/agent-skills/logfire-gateway/SKILL.md) |
|
|
45
|
+
| Coding agents | Record Claude/Codex sessions or configure coding-agent Gateway routing | [`logfire-coding-agents`](https://pydantic.dev/.well-known/agent-skills/logfire-coding-agents/SKILL.md) |
|
|
46
|
+
|
|
47
|
+
- With no specific scope, get one representative application service to verified first data. Incidental Docker/eval files do not expand the task. Route infrastructure-only repositories to `logfire-infrastructure`.
|
|
48
|
+
- A request already scoped to one surface ("monitor my Postgres server", "set up evals for this agent") → fetch that skill directly, skipping the rest of this table.
|
|
49
|
+
- Genuinely ambiguous between two adjacent surfaces (e.g. "watch my Postgres" could mean Collector-level infrastructure metrics or app-level query instrumentation)? Ask one clarifying question rather than guessing — loading the wrong skill wastes the user's time reading instructions for a job they didn't ask for.
|
|
50
|
+
|
|
51
|
+
## Step 3: Fetch the Right Skill(s)
|
|
52
|
+
|
|
53
|
+
Load the selected skill and follow its credential workflow. SDK specialists
|
|
54
|
+
verify the project with `whoami`; CLI specialists preserve prepared handoffs,
|
|
55
|
+
and query/UI skills can use existing native MCP access. Do not force one
|
|
56
|
+
authentication method across all surfaces.
|
|
57
|
+
|
|
58
|
+
Never print, log, hard-code, commit, or echo a token, in any of these skills, at any point. The one exception — reading `.logfire/logfire_credentials.json`'s `token` key programmatically to hand a non-native-SDK application its write token, never to display it — is in [auth.md](https://pydantic.dev/.well-known/agent-skills/logfire-instrumentation/references/auth.md#if-the-calling-skill-needs-a-write-token-not-just-a-cli-session).
|