Skip to content

feat(logfire): add Pydantic Logfire block, docs - #6075

Merged
icecrasher321 merged 1 commit into
stagingfrom
staging-v14
Jul 30, 2026
Merged

feat(logfire): add Pydantic Logfire block, docs#6075
icecrasher321 merged 1 commit into
stagingfrom
staging-v14

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Adds a Logfire block with four read-token tools — structured span/log search, raw SQL over records/metrics, full-trace fetch, and token introspection — plus icon, registry wiring, and docs.
Queries go to /v2/query with the region auto-detected from the token prefix, overridable by region or a self-hosted host (public HTTPS only); all filter input is escaped as SQL literals.

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@gitguardian

gitguardian Bot commented Jul 30, 2026

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 30, 2026 1:04am

Request Review

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Workflows handle read tokens and may send LLM- or user-authored SQL to Logfire; injection is mitigated for generated search/trace SQL but not for the free-form query operation.

Overview
Adds a Pydantic Logfire observability integration so workflows and agents can read traces, logs, and metrics with a project read token.

The new logfire block exposes four operations: structured Search Records, user/LLM Run SQL Query (with optional wand SQL generation), Get Trace by ID, and Get Token Info. Shared tooling posts to Logfire /v2/query (and /v1/read-token-info), picks US/EU cloud hosts from the token prefix or explicit region, and supports a self-hosted Host override.

Search and trace paths build SQL from filters with escaped literals; the raw query tool forwards caller SQL unchanged. Docs, integrations.json, LogfireIcon, block registry/meta (templates and agent skills), and Vitest coverage for URL routing, query bodies, escaping, and response normalization are included.

Reviewed by Cursor Bugbot for commit c781e7f. Configure here.

Comment thread apps/sim/tools/logfire/utils.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a Pydantic Logfire block with four tools (search records, SQL query, get trace, get token info), shared URL/SQL helpers, registry/icon wiring, and docs.

  • Region resolution validates explicit and token-derived regions against known cloud hosts before building URLs.
  • Self-hosted host normalization rejects query/fragment/userinfo; filter values are SQL-literal escaped.

Confidence Score: 5/5

Safe to merge; the previously reported invalid-region URL issue is fixed and no blocking failures remain.

No blocking failure remains. Explicit non-us/eu regions and unknown token regions throw clear errors instead of building undefined URLs, covered by regression tests.

Important Files Changed

Filename Overview
apps/sim/tools/logfire/utils.ts Shared base URL, host normalization, SQL helpers, and query body builders with invalid-region guards and tests.
apps/sim/tools/logfire/query.ts Raw SQL query tool posting to /v2/query with read-token auth.
apps/sim/tools/logfire/search_records.ts Structured span/log search built as escaped SQL over records.
apps/sim/tools/logfire/get_trace.ts Trace fetch by trace_id with chronological ordering.
apps/sim/tools/logfire/get_token_info.ts Read-token introspection mapped to organization/project outputs.
apps/sim/blocks/blocks/logfire.ts Block UI, operation switch, param mapping, templates, and skills.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Logfire block params] --> B{host set?}
  B -->|yes| C[normalizeHost]
  B -->|no| D{region auto?}
  D -->|no| E{isCloudRegion}
  E -->|yes| F[REGION_BASE_URLS]
  E -->|no| G[throw invalid region]
  D -->|yes| H[token prefix region]
  H --> I{isCloudRegion}
  I -->|yes| F
  I -->|no| J[throw or default US]
  C --> K[logfireUrl + path]
  F --> K
  K --> L["/v2/query or /v1/read-token-info"]
Loading

Reviews (4): Last reviewed commit: "feat(logfire): add Pydantic Logfire bloc..." | Re-trigger Greptile

Comment thread apps/sim/tools/logfire/utils.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f3e3440. Configure here.

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>
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c781e7f. Configure here.

@icecrasher321
icecrasher321 merged commit f78367c into staging Jul 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant