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.
Files changed (304) hide show
  1. _logfire_sdk/logfire/.agents/skills/logfire-evals/SKILL.md +170 -0
  2. _logfire_sdk/logfire/.agents/skills/logfire-gateway/SKILL.md +156 -0
  3. _logfire_sdk/logfire/.agents/skills/logfire-infrastructure/SKILL.md +61 -0
  4. _logfire_sdk/logfire/.agents/skills/logfire-infrastructure/references/collector/host-and-infra-metrics.md +229 -0
  5. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/SKILL.md +292 -0
  6. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/auth.md +100 -0
  7. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/ai-sdk.md +145 -0
  8. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/cloudflare-and-deno.md +99 -0
  9. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/frameworks.md +22 -0
  10. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/installation-and-env.md +75 -0
  11. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/nextjs.md +78 -0
  12. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/node-runtime.md +132 -0
  13. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/patterns.md +184 -0
  14. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/project-detection.md +43 -0
  15. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/react-browser.md +18 -0
  16. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/javascript/verification-troubleshooting.md +68 -0
  17. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/python/integrations.md +104 -0
  18. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/python/logging-patterns.md +120 -0
  19. _logfire_sdk/logfire/.agents/skills/logfire-instrumentation/references/rust/patterns.md +113 -0
  20. _logfire_sdk/logfire/.agents/skills/logfire-setup/SKILL.md +58 -0
  21. _logfire_sdk/logfire/.agents/skills/logfire-setup-offline.md +715 -0
  22. _logfire_sdk/logfire/__init__.py +226 -0
  23. _logfire_sdk/logfire/__main__.py +6 -0
  24. _logfire_sdk/logfire/_internal/__init__.py +14 -0
  25. _logfire_sdk/logfire/_internal/ast_utils.py +264 -0
  26. _logfire_sdk/logfire/_internal/async_.py +125 -0
  27. _logfire_sdk/logfire/_internal/auth.py +298 -0
  28. _logfire_sdk/logfire/_internal/auto_trace/__init__.py +74 -0
  29. _logfire_sdk/logfire/_internal/auto_trace/import_hook.py +137 -0
  30. _logfire_sdk/logfire/_internal/auto_trace/rewrite_ast.py +185 -0
  31. _logfire_sdk/logfire/_internal/auto_trace/types.py +44 -0
  32. _logfire_sdk/logfire/_internal/baggage.py +109 -0
  33. _logfire_sdk/logfire/_internal/cli/__init__.py +1081 -0
  34. _logfire_sdk/logfire/_internal/cli/ai_tools.py +231 -0
  35. _logfire_sdk/logfire/_internal/cli/auth.py +151 -0
  36. _logfire_sdk/logfire/_internal/cli/gateway.py +627 -0
  37. _logfire_sdk/logfire/_internal/cli/gateway_auth.py +313 -0
  38. _logfire_sdk/logfire/_internal/cli/prompt.py +50 -0
  39. _logfire_sdk/logfire/_internal/cli/run.py +590 -0
  40. _logfire_sdk/logfire/_internal/client.py +178 -0
  41. _logfire_sdk/logfire/_internal/collect_system_info.py +29 -0
  42. _logfire_sdk/logfire/_internal/config.py +2471 -0
  43. _logfire_sdk/logfire/_internal/config_params.py +343 -0
  44. _logfire_sdk/logfire/_internal/constants.py +185 -0
  45. _logfire_sdk/logfire/_internal/db_statement_summary.py +140 -0
  46. _logfire_sdk/logfire/_internal/exporters/__init__.py +1 -0
  47. _logfire_sdk/logfire/_internal/exporters/console.py +517 -0
  48. _logfire_sdk/logfire/_internal/exporters/dynamic_batch.py +49 -0
  49. _logfire_sdk/logfire/_internal/exporters/logs.py +30 -0
  50. _logfire_sdk/logfire/_internal/exporters/otlp.py +517 -0
  51. _logfire_sdk/logfire/_internal/exporters/processor_wrapper.py +652 -0
  52. _logfire_sdk/logfire/_internal/exporters/quiet_metrics.py +18 -0
  53. _logfire_sdk/logfire/_internal/exporters/remove_pending.py +45 -0
  54. _logfire_sdk/logfire/_internal/exporters/test.py +257 -0
  55. _logfire_sdk/logfire/_internal/exporters/wrapper.py +106 -0
  56. _logfire_sdk/logfire/_internal/formatter.py +379 -0
  57. _logfire_sdk/logfire/_internal/forwarding.py +585 -0
  58. _logfire_sdk/logfire/_internal/http_transport.py +193 -0
  59. _logfire_sdk/logfire/_internal/instrument.py +254 -0
  60. _logfire_sdk/logfire/_internal/integrations/__init__.py +1 -0
  61. _logfire_sdk/logfire/_internal/integrations/aiohttp_client.py +324 -0
  62. _logfire_sdk/logfire/_internal/integrations/aiohttp_server.py +22 -0
  63. _logfire_sdk/logfire/_internal/integrations/asgi.py +117 -0
  64. _logfire_sdk/logfire/_internal/integrations/asyncpg.py +21 -0
  65. _logfire_sdk/logfire/_internal/integrations/aws_lambda.py +36 -0
  66. _logfire_sdk/logfire/_internal/integrations/celery.py +20 -0
  67. _logfire_sdk/logfire/_internal/integrations/claude_agent_sdk.py +628 -0
  68. _logfire_sdk/logfire/_internal/integrations/django.py +41 -0
  69. _logfire_sdk/logfire/_internal/integrations/dspy.py +20 -0
  70. _logfire_sdk/logfire/_internal/integrations/executors.py +99 -0
  71. _logfire_sdk/logfire/_internal/integrations/fastapi.py +421 -0
  72. _logfire_sdk/logfire/_internal/integrations/flask.py +53 -0
  73. _logfire_sdk/logfire/_internal/integrations/google_genai.py +66 -0
  74. _logfire_sdk/logfire/_internal/integrations/httpx.py +577 -0
  75. _logfire_sdk/logfire/_internal/integrations/litellm.py +20 -0
  76. _logfire_sdk/logfire/_internal/integrations/litestar.py +77 -0
  77. _logfire_sdk/logfire/_internal/integrations/llm_providers/anthropic.py +406 -0
  78. _logfire_sdk/logfire/_internal/integrations/llm_providers/llm_provider.py +251 -0
  79. _logfire_sdk/logfire/_internal/integrations/llm_providers/openai.py +892 -0
  80. _logfire_sdk/logfire/_internal/integrations/llm_providers/semconv.py +194 -0
  81. _logfire_sdk/logfire/_internal/integrations/llm_providers/types.py +36 -0
  82. _logfire_sdk/logfire/_internal/integrations/llm_providers/usage.py +89 -0
  83. _logfire_sdk/logfire/_internal/integrations/mcp.py +191 -0
  84. _logfire_sdk/logfire/_internal/integrations/monty.py +155 -0
  85. _logfire_sdk/logfire/_internal/integrations/mysql.py +34 -0
  86. _logfire_sdk/logfire/_internal/integrations/openai_agents.py +460 -0
  87. _logfire_sdk/logfire/_internal/integrations/print.py +176 -0
  88. _logfire_sdk/logfire/_internal/integrations/psycopg.py +126 -0
  89. _logfire_sdk/logfire/_internal/integrations/pydantic_ai.py +65 -0
  90. _logfire_sdk/logfire/_internal/integrations/pymongo.py +40 -0
  91. _logfire_sdk/logfire/_internal/integrations/pytest.py +648 -0
  92. _logfire_sdk/logfire/_internal/integrations/redis.py +57 -0
  93. _logfire_sdk/logfire/_internal/integrations/requests.py +34 -0
  94. _logfire_sdk/logfire/_internal/integrations/snowflake.py +162 -0
  95. _logfire_sdk/logfire/_internal/integrations/sqlalchemy.py +70 -0
  96. _logfire_sdk/logfire/_internal/integrations/sqlite3.py +29 -0
  97. _logfire_sdk/logfire/_internal/integrations/starlette.py +50 -0
  98. _logfire_sdk/logfire/_internal/integrations/surrealdb.py +137 -0
  99. _logfire_sdk/logfire/_internal/integrations/system_metrics.py +322 -0
  100. _logfire_sdk/logfire/_internal/integrations/wsgi.py +34 -0
  101. _logfire_sdk/logfire/_internal/interactive.py +115 -0
  102. _logfire_sdk/logfire/_internal/json_encoder.py +344 -0
  103. _logfire_sdk/logfire/_internal/json_formatter.py +350 -0
  104. _logfire_sdk/logfire/_internal/json_schema.py +455 -0
  105. _logfire_sdk/logfire/_internal/json_types.py +147 -0
  106. _logfire_sdk/logfire/_internal/logs.py +142 -0
  107. _logfire_sdk/logfire/_internal/main.py +3498 -0
  108. _logfire_sdk/logfire/_internal/metrics.py +283 -0
  109. _logfire_sdk/logfire/_internal/scrubbing.py +404 -0
  110. _logfire_sdk/logfire/_internal/server_response.py +44 -0
  111. _logfire_sdk/logfire/_internal/stack_info.py +147 -0
  112. _logfire_sdk/logfire/_internal/tracer.py +538 -0
  113. _logfire_sdk/logfire/_internal/ulid.py +40 -0
  114. _logfire_sdk/logfire/_internal/utils.py +550 -0
  115. _logfire_sdk/logfire/cli.py +3 -0
  116. _logfire_sdk/logfire/db_api.py +393 -0
  117. _logfire_sdk/logfire/exceptions.py +9 -0
  118. _logfire_sdk/logfire/experimental/__init__.py +0 -0
  119. _logfire_sdk/logfire/experimental/annotations.py +80 -0
  120. _logfire_sdk/logfire/experimental/api_client.py +1421 -0
  121. _logfire_sdk/logfire/integrations/__init__.py +4 -0
  122. _logfire_sdk/logfire/integrations/aiohttp_client.py +12 -0
  123. _logfire_sdk/logfire/integrations/flask.py +26 -0
  124. _logfire_sdk/logfire/integrations/httpx.py +49 -0
  125. _logfire_sdk/logfire/integrations/logging.py +153 -0
  126. _logfire_sdk/logfire/integrations/loguru.py +98 -0
  127. _logfire_sdk/logfire/integrations/psycopg.py +23 -0
  128. _logfire_sdk/logfire/integrations/pydantic.py +541 -0
  129. _logfire_sdk/logfire/integrations/redis.py +31 -0
  130. _logfire_sdk/logfire/integrations/sqlalchemy.py +12 -0
  131. _logfire_sdk/logfire/integrations/structlog.py +55 -0
  132. _logfire_sdk/logfire/integrations/wsgi.py +15 -0
  133. _logfire_sdk/logfire/propagate.py +161 -0
  134. _logfire_sdk/logfire/py.typed +0 -0
  135. _logfire_sdk/logfire/query_client.py +701 -0
  136. _logfire_sdk/logfire/sampling/__init__.py +9 -0
  137. _logfire_sdk/logfire/sampling/_tail_sampling.py +292 -0
  138. _logfire_sdk/logfire/testing.py +127 -0
  139. _logfire_sdk/logfire/types.py +303 -0
  140. _logfire_sdk/logfire/variables/__init__.py +154 -0
  141. _logfire_sdk/logfire/variables/_handlebars.py +77 -0
  142. _logfire_sdk/logfire/variables/abstract.py +2027 -0
  143. _logfire_sdk/logfire/variables/composition.py +430 -0
  144. _logfire_sdk/logfire/variables/config.py +694 -0
  145. _logfire_sdk/logfire/variables/local.py +134 -0
  146. _logfire_sdk/logfire/variables/remote.py +877 -0
  147. _logfire_sdk/logfire/variables/template_validation.py +208 -0
  148. _logfire_sdk/logfire/variables/variable.py +1299 -0
  149. _logfire_sdk/logfire/version.py +5 -0
  150. logfire/.agents/skills/logfire-evals/SKILL.md +170 -0
  151. logfire/.agents/skills/logfire-gateway/SKILL.md +156 -0
  152. logfire/.agents/skills/logfire-infrastructure/SKILL.md +61 -0
  153. logfire/.agents/skills/logfire-infrastructure/references/collector/host-and-infra-metrics.md +229 -0
  154. logfire/.agents/skills/logfire-instrumentation/SKILL.md +292 -0
  155. logfire/.agents/skills/logfire-instrumentation/references/auth.md +100 -0
  156. logfire/.agents/skills/logfire-instrumentation/references/javascript/ai-sdk.md +145 -0
  157. logfire/.agents/skills/logfire-instrumentation/references/javascript/cloudflare-and-deno.md +99 -0
  158. logfire/.agents/skills/logfire-instrumentation/references/javascript/frameworks.md +22 -0
  159. logfire/.agents/skills/logfire-instrumentation/references/javascript/installation-and-env.md +75 -0
  160. logfire/.agents/skills/logfire-instrumentation/references/javascript/nextjs.md +78 -0
  161. logfire/.agents/skills/logfire-instrumentation/references/javascript/node-runtime.md +132 -0
  162. logfire/.agents/skills/logfire-instrumentation/references/javascript/patterns.md +184 -0
  163. logfire/.agents/skills/logfire-instrumentation/references/javascript/project-detection.md +43 -0
  164. logfire/.agents/skills/logfire-instrumentation/references/javascript/react-browser.md +18 -0
  165. logfire/.agents/skills/logfire-instrumentation/references/javascript/verification-troubleshooting.md +68 -0
  166. logfire/.agents/skills/logfire-instrumentation/references/python/integrations.md +104 -0
  167. logfire/.agents/skills/logfire-instrumentation/references/python/logging-patterns.md +120 -0
  168. logfire/.agents/skills/logfire-instrumentation/references/rust/patterns.md +113 -0
  169. logfire/.agents/skills/logfire-setup/SKILL.md +58 -0
  170. logfire/.agents/skills/logfire-setup-offline.md +715 -0
  171. logfire/__init__.py +226 -0
  172. logfire/__main__.py +6 -0
  173. logfire/_internal/__init__.py +14 -0
  174. logfire/_internal/ast_utils.py +264 -0
  175. logfire/_internal/async_.py +125 -0
  176. logfire/_internal/auth.py +298 -0
  177. logfire/_internal/auto_trace/__init__.py +74 -0
  178. logfire/_internal/auto_trace/import_hook.py +137 -0
  179. logfire/_internal/auto_trace/rewrite_ast.py +185 -0
  180. logfire/_internal/auto_trace/types.py +44 -0
  181. logfire/_internal/baggage.py +109 -0
  182. logfire/_internal/cli/__init__.py +1081 -0
  183. logfire/_internal/cli/ai_tools.py +231 -0
  184. logfire/_internal/cli/auth.py +151 -0
  185. logfire/_internal/cli/gateway.py +627 -0
  186. logfire/_internal/cli/gateway_auth.py +313 -0
  187. logfire/_internal/cli/prompt.py +50 -0
  188. logfire/_internal/cli/run.py +590 -0
  189. logfire/_internal/client.py +178 -0
  190. logfire/_internal/collect_system_info.py +29 -0
  191. logfire/_internal/config.py +2471 -0
  192. logfire/_internal/config_params.py +343 -0
  193. logfire/_internal/constants.py +185 -0
  194. logfire/_internal/db_statement_summary.py +140 -0
  195. logfire/_internal/exporters/__init__.py +1 -0
  196. logfire/_internal/exporters/console.py +517 -0
  197. logfire/_internal/exporters/dynamic_batch.py +49 -0
  198. logfire/_internal/exporters/logs.py +30 -0
  199. logfire/_internal/exporters/otlp.py +517 -0
  200. logfire/_internal/exporters/processor_wrapper.py +652 -0
  201. logfire/_internal/exporters/quiet_metrics.py +18 -0
  202. logfire/_internal/exporters/remove_pending.py +45 -0
  203. logfire/_internal/exporters/test.py +257 -0
  204. logfire/_internal/exporters/wrapper.py +106 -0
  205. logfire/_internal/formatter.py +379 -0
  206. logfire/_internal/forwarding.py +585 -0
  207. logfire/_internal/http_transport.py +193 -0
  208. logfire/_internal/instrument.py +254 -0
  209. logfire/_internal/integrations/__init__.py +1 -0
  210. logfire/_internal/integrations/aiohttp_client.py +324 -0
  211. logfire/_internal/integrations/aiohttp_server.py +22 -0
  212. logfire/_internal/integrations/asgi.py +117 -0
  213. logfire/_internal/integrations/asyncpg.py +21 -0
  214. logfire/_internal/integrations/aws_lambda.py +36 -0
  215. logfire/_internal/integrations/celery.py +20 -0
  216. logfire/_internal/integrations/claude_agent_sdk.py +628 -0
  217. logfire/_internal/integrations/django.py +41 -0
  218. logfire/_internal/integrations/dspy.py +20 -0
  219. logfire/_internal/integrations/executors.py +99 -0
  220. logfire/_internal/integrations/fastapi.py +421 -0
  221. logfire/_internal/integrations/flask.py +53 -0
  222. logfire/_internal/integrations/google_genai.py +66 -0
  223. logfire/_internal/integrations/httpx.py +577 -0
  224. logfire/_internal/integrations/litellm.py +20 -0
  225. logfire/_internal/integrations/litestar.py +77 -0
  226. logfire/_internal/integrations/llm_providers/anthropic.py +406 -0
  227. logfire/_internal/integrations/llm_providers/llm_provider.py +251 -0
  228. logfire/_internal/integrations/llm_providers/openai.py +892 -0
  229. logfire/_internal/integrations/llm_providers/semconv.py +194 -0
  230. logfire/_internal/integrations/llm_providers/types.py +36 -0
  231. logfire/_internal/integrations/llm_providers/usage.py +89 -0
  232. logfire/_internal/integrations/mcp.py +191 -0
  233. logfire/_internal/integrations/monty.py +155 -0
  234. logfire/_internal/integrations/mysql.py +34 -0
  235. logfire/_internal/integrations/openai_agents.py +460 -0
  236. logfire/_internal/integrations/print.py +176 -0
  237. logfire/_internal/integrations/psycopg.py +126 -0
  238. logfire/_internal/integrations/pydantic_ai.py +65 -0
  239. logfire/_internal/integrations/pymongo.py +40 -0
  240. logfire/_internal/integrations/pytest.py +648 -0
  241. logfire/_internal/integrations/redis.py +57 -0
  242. logfire/_internal/integrations/requests.py +34 -0
  243. logfire/_internal/integrations/snowflake.py +162 -0
  244. logfire/_internal/integrations/sqlalchemy.py +70 -0
  245. logfire/_internal/integrations/sqlite3.py +29 -0
  246. logfire/_internal/integrations/starlette.py +50 -0
  247. logfire/_internal/integrations/surrealdb.py +137 -0
  248. logfire/_internal/integrations/system_metrics.py +322 -0
  249. logfire/_internal/integrations/wsgi.py +34 -0
  250. logfire/_internal/interactive.py +115 -0
  251. logfire/_internal/json_encoder.py +344 -0
  252. logfire/_internal/json_formatter.py +350 -0
  253. logfire/_internal/json_schema.py +455 -0
  254. logfire/_internal/json_types.py +147 -0
  255. logfire/_internal/logs.py +142 -0
  256. logfire/_internal/main.py +3498 -0
  257. logfire/_internal/metrics.py +283 -0
  258. logfire/_internal/scrubbing.py +404 -0
  259. logfire/_internal/server_response.py +44 -0
  260. logfire/_internal/stack_info.py +147 -0
  261. logfire/_internal/tracer.py +538 -0
  262. logfire/_internal/ulid.py +40 -0
  263. logfire/_internal/utils.py +550 -0
  264. logfire/cli.py +3 -0
  265. logfire/db_api.py +393 -0
  266. logfire/exceptions.py +9 -0
  267. logfire/experimental/__init__.py +0 -0
  268. logfire/experimental/annotations.py +80 -0
  269. logfire/experimental/api_client.py +1421 -0
  270. logfire/integrations/__init__.py +4 -0
  271. logfire/integrations/aiohttp_client.py +12 -0
  272. logfire/integrations/flask.py +26 -0
  273. logfire/integrations/httpx.py +49 -0
  274. logfire/integrations/logging.py +153 -0
  275. logfire/integrations/loguru.py +98 -0
  276. logfire/integrations/psycopg.py +23 -0
  277. logfire/integrations/pydantic.py +541 -0
  278. logfire/integrations/redis.py +31 -0
  279. logfire/integrations/sqlalchemy.py +12 -0
  280. logfire/integrations/structlog.py +55 -0
  281. logfire/integrations/wsgi.py +15 -0
  282. logfire/propagate.py +161 -0
  283. logfire/py.typed +0 -0
  284. logfire/query_client.py +701 -0
  285. logfire/sampling/__init__.py +9 -0
  286. logfire/sampling/_tail_sampling.py +292 -0
  287. logfire/testing.py +127 -0
  288. logfire/types.py +303 -0
  289. logfire/variables/__init__.py +154 -0
  290. logfire/variables/_handlebars.py +77 -0
  291. logfire/variables/abstract.py +2027 -0
  292. logfire/variables/composition.py +430 -0
  293. logfire/variables/config.py +694 -0
  294. logfire/variables/local.py +134 -0
  295. logfire/variables/remote.py +877 -0
  296. logfire/variables/template_validation.py +208 -0
  297. logfire/variables/variable.py +1299 -0
  298. logfire/version.py +5 -0
  299. logfire_sdk-5.3.0.dist-info/METADATA +140 -0
  300. logfire_sdk-5.3.0.dist-info/RECORD +304 -0
  301. logfire_sdk-5.3.0.dist-info/WHEEL +4 -0
  302. logfire_sdk-5.3.0.dist-info/entry_points.txt +6 -0
  303. logfire_sdk-5.3.0.dist-info/licenses/LICENSE +21 -0
  304. 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.
@@ -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).