Skip to content

Commit c781e7f

Browse files
icecrasher321claude
andcommitted
feat(logfire): add Pydantic Logfire block, tools, and docs
Four read-token tools over Logfire's query API: structured span/log search, raw SQL against records/metrics, full-trace fetch by ID, and read-token introspection. Plus the block, icon, registry wiring, and generated docs. Requests go to /v2/query with the region resolved from the token's pylf_v{n}_{region}_ prefix, overridable by an explicit region or a self-hosted host (public HTTPS only, per the tool executor's URL policy). Structured filters are emitted as escaped SQL literals, using DataFusion contains() so %/_ in user input stay literal. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 998fd5a commit c781e7f

22 files changed

Lines changed: 2309 additions & 0 deletions

apps/docs/components/icons.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8758,3 +8758,21 @@ export function RocketlaneIcon(props: SVGProps<SVGSVGElement>) {
87588758
</svg>
87598759
)
87608760
}
8761+
8762+
/**
8763+
* Pydantic Logfire. Single-fill mark drawn with `fill='currentColor'` so it
8764+
* takes white on its brand tile and the block's `iconColor` when rendered bare.
8765+
*/
8766+
export function LogfireIcon(props: SVGProps<SVGSVGElement>) {
8767+
return (
8768+
<svg
8769+
{...props}
8770+
viewBox='0 0 138 120'
8771+
fill='currentColor'
8772+
role='img'
8773+
xmlns='http://www.w3.org/2000/svg'
8774+
>
8775+
<path d='M137.041 90.563 73.326 2.241c-2.005-2.757-6.628-2.757-8.613 0L.998 90.563A5.32 5.32 0 0 0 0 93.664a5.331 5.331 0 0 0 3.641 5.05l63.715 20.851h.01a5.306 5.306 0 0 0 3.292 0h.01l63.715-20.85a5.265 5.265 0 0 0 3.392-3.406 5.247 5.247 0 0 0-.749-4.746h.015ZM69.022 14.412 94.56 49.815l-23.882-7.813c-.185-.06-.38-.05-.564-.094a3.484 3.484 0 0 0-.548-.09c-.185-.025-.36-.095-.544-.095-.185 0-.354.07-.539.095-.184.02-.369.05-.548.09-.19.035-.384.035-.554.094L43.644 49.77l-.15.05L69.032 14.41h-.01ZM32.94 64.438l27.802-9.104 2.968-.967v52.838L13.86 90.887 32.94 64.438Zm41.399 42.757V54.367l30.77 10.071 19.079 26.434-49.854 16.323h.005Z' />
8776+
</svg>
8777+
)
8778+
}

apps/docs/components/ui/icon-mapping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ import {
133133
LinkedInIcon,
134134
LinkupIcon,
135135
LinqIcon,
136+
LogfireIcon,
136137
LoopsIcon,
137138
LumaIcon,
138139
MailchimpIcon,
@@ -403,6 +404,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
403404
linkedin: LinkedInIcon,
404405
linkup: LinkupIcon,
405406
linq: LinqIcon,
407+
logfire: LogfireIcon,
406408
logs: Library,
407409
logs_v2: Library,
408410
loops: LoopsIcon,
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: Logfire
3+
description: Query traces, logs, and metrics in Pydantic Logfire
4+
---
5+
6+
import { BlockInfoCard } from "@/components/ui/block-info-card"
7+
8+
<BlockInfoCard
9+
type="logfire"
10+
color="#E520E9"
11+
/>
12+
13+
{/* MANUAL-CONTENT-START:intro */}
14+
[Pydantic Logfire](https://pydantic.dev/logfire) is an observability platform built on OpenTelemetry. It collects the traces, logs, and metrics your services emit, stores every span in a queryable `records` table, and exposes that table through a read-only SQL API.
15+
16+
With Logfire, you can:
17+
18+
- **Search spans and logs**: Filter by message text, service, span name, severity, deployment environment, and whether an exception was recorded — no SQL required.
19+
- **Run SQL directly**: Query the `records` and `metrics` tables with PostgreSQL-compatible syntax for aggregations like error rates and latency percentiles.
20+
- **Reconstruct a request**: Pull every span in a trace, ordered earliest to latest, and walk the parent-child tree to see where time went and where it failed.
21+
- **Confirm a credential**: Resolve which organization and project a read token targets before querying it.
22+
23+
Sim's Logfire integration lets agents read production telemetry as part of a run. Use it to triage errors against a live service, attach a root-cause summary to an incident ticket, or watch latency between deploys and page when it regresses.
24+
25+
Authentication uses a Logfire **read token**, which you create per project under Settings → Read tokens. The region is detected from the token's prefix, so Cloud users on US and EU need no extra configuration. Self-hosted instances set the Host field to their own base URL, which must be reachable over HTTPS at a publicly resolvable domain.
26+
{/* MANUAL-CONTENT-END */}
27+
28+
29+
## Usage Instructions
30+
31+
Integrate Pydantic Logfire into workflows. Run SQL over your observability data, search spans and logs with structured filters, pull an entire trace by ID, and confirm which project a read token targets.
32+
33+
34+
35+
## Actions
36+
37+
### `logfire_query`
38+
39+
Run a read-only SQL query against Logfire traces, logs, and metrics. Reads the records and metrics tables using PostgreSQL-compatible syntax.
40+
41+
#### Input
42+
43+
| Parameter | Type | Required | Description |
44+
| --------- | ---- | -------- | ----------- |
45+
| `apiKey` | string | Yes | Logfire read token |
46+
| `region` | string | No | Logfire data region: auto, us, or eu. Auto reads the region from the token. |
47+
| `host` | string | No | Base URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud. |
48+
| `sql` | string | Yes | SQL SELECT query to run against the records or metrics table |
49+
| `minTimestamp` | string | No | ISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted. |
50+
| `maxTimestamp` | string | No | ISO 8601 upper bound on start_timestamp |
51+
| `limit` | number | No | Maximum rows to return. Logfire defaults to 100 and caps at 10000. |
52+
| `timezone` | string | No | IANA timezone used to evaluate the query, for example Europe/Paris |
53+
| `environment` | string | No | Restrict results to a single deployment environment |
54+
55+
#### Output
56+
57+
| Parameter | Type | Description |
58+
| --------- | ---- | ----------- |
59+
| `rows` | array | Result rows. Row fields depend on the query projection. |
60+
| `columns` | array | Column metadata for the result set |
61+
|`name` | string | Column name |
62+
|`datatype` | json | Arrow datatype of the column |
63+
|`nullable` | boolean | Whether the column is nullable |
64+
| `rowCount` | number | Number of rows returned |
65+
66+
### `logfire_search_records`
67+
68+
Search Logfire spans and logs using structured filters for message text, service, span name, severity, environment, and exceptions. Returns the most recent matches first without writing SQL.
69+
70+
#### Input
71+
72+
| Parameter | Type | Required | Description |
73+
| --------- | ---- | -------- | ----------- |
74+
| `apiKey` | string | Yes | Logfire read token |
75+
| `region` | string | No | Logfire data region: auto, us, or eu. Auto reads the region from the token. |
76+
| `host` | string | No | Base URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud. |
77+
| `query` | string | No | Case-insensitive text to match within the record message |
78+
| `service` | string | No | Exact service name to filter on |
79+
| `spanName` | string | No | Exact span name to filter on |
80+
| `minLevel` | string | No | Minimum severity to include: trace, debug, info, notice, warn, error, or fatal |
81+
| `exceptionsOnly` | boolean | No | Only return records that recorded an exception |
82+
| `environment` | string | No | Restrict results to a single deployment environment |
83+
| `minTimestamp` | string | No | ISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted. |
84+
| `maxTimestamp` | string | No | ISO 8601 upper bound on start_timestamp |
85+
| `limit` | number | No | Maximum records to return. Logfire defaults to 100 and caps at 10000. |
86+
87+
#### Output
88+
89+
| Parameter | Type | Description |
90+
| --------- | ---- | ----------- |
91+
| `rows` | array | Matching spans and logs, most recent first |
92+
|`startTimestamp` | string | UTC time the span started |
93+
|`endTimestamp` | string | UTC time the span ended |
94+
|`duration` | number | Span duration in seconds. Null for logs. |
95+
|`level` | string | Severity name, such as info, warn, or error |
96+
|`message` | string | Human-readable message |
97+
|`spanName` | string | Template label for similar records |
98+
|`kind` | string | Record kind: span, log, or span_event |
99+
|`serviceName` | string | Service that emitted the record |
100+
|`deploymentEnvironment` | string | Deployment environment of the record |
101+
|`traceId` | string | Trace this record belongs to |
102+
|`spanId` | string | Identifier of this span |
103+
|`parentSpanId` | string | Parent span identifier |
104+
|`isException` | boolean | Whether an exception was recorded on the span |
105+
|`exceptionType` | string | Fully qualified exception class name |
106+
|`exceptionMessage` | string | Exception message |
107+
| `rowCount` | number | Number of rows returned |
108+
| `sql` | string | SQL query that was executed against Logfire |
109+
110+
### `logfire_get_trace`
111+
112+
Fetch every span and log belonging to a Logfire trace, ordered from earliest to latest, so a single request can be reconstructed end to end.
113+
114+
#### Input
115+
116+
| Parameter | Type | Required | Description |
117+
| --------- | ---- | -------- | ----------- |
118+
| `apiKey` | string | Yes | Logfire read token |
119+
| `region` | string | No | Logfire data region: auto, us, or eu. Auto reads the region from the token. |
120+
| `host` | string | No | Base URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud. |
121+
| `traceId` | string | Yes | 32-character hexadecimal trace identifier |
122+
| `minTimestamp` | string | No | ISO 8601 lower bound on start_timestamp. Defaults to 2020-01-01T00:00:00Z when omitted. |
123+
| `maxTimestamp` | string | No | ISO 8601 upper bound on start_timestamp |
124+
| `limit` | number | No | Maximum spans to return. Logfire defaults to 100 and caps at 10000. |
125+
126+
#### Output
127+
128+
| Parameter | Type | Description |
129+
| --------- | ---- | ----------- |
130+
| `rows` | array | Spans and logs in the trace, earliest first |
131+
|`startTimestamp` | string | UTC time the span started |
132+
|`endTimestamp` | string | UTC time the span ended |
133+
|`duration` | number | Span duration in seconds. Null for logs. |
134+
|`level` | string | Severity name, such as info, warn, or error |
135+
|`message` | string | Human-readable message |
136+
|`spanName` | string | Template label for similar records |
137+
|`kind` | string | Record kind: span, log, or span_event |
138+
|`serviceName` | string | Service that emitted the record |
139+
|`deploymentEnvironment` | string | Deployment environment of the record |
140+
|`traceId` | string | Trace this record belongs to |
141+
|`spanId` | string | Identifier of this span |
142+
|`parentSpanId` | string | Parent span identifier |
143+
|`isException` | boolean | Whether an exception was recorded on the span |
144+
|`exceptionType` | string | Fully qualified exception class name |
145+
|`exceptionMessage` | string | Exception message |
146+
| `rowCount` | number | Number of rows returned |
147+
| `sql` | string | SQL query that was executed against Logfire |
148+
149+
### `logfire_get_token_info`
150+
151+
Resolve which Logfire organization and project a read token belongs to. Useful for confirming a credential targets the expected project before querying it.
152+
153+
#### Input
154+
155+
| Parameter | Type | Required | Description |
156+
| --------- | ---- | -------- | ----------- |
157+
| `apiKey` | string | Yes | Logfire read token |
158+
| `region` | string | No | Logfire data region: auto, us, or eu. Auto reads the region from the token. |
159+
| `host` | string | No | Base URL of a self-hosted Logfire instance, e.g. https://logfire.example.com. Overrides region. Leave blank for Logfire Cloud. |
160+
161+
#### Output
162+
163+
| Parameter | Type | Description |
164+
| --------- | ---- | ----------- |
165+
| `organizationName` | string | Logfire organization the read token belongs to |
166+
| `projectName` | string | Logfire project the read token belongs to |
167+
168+

apps/docs/content/docs/en/integrations/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"linkedin",
141141
"linkup",
142142
"linq",
143+
"logfire",
143144
"logs",
144145
"loops",
145146
"luma",

0 commit comments

Comments
 (0)