logfire-logging

Rules for using Logfire, a logging and observability service for recording application events and measuring operation timing. They define when to use messages and timed spans and how to name them.

In plain words
What is it for?
Use them when adding Logfire logs or spans around tasks such as data processing, order synchronization, strategy execution, or report generation.
Why use it?
They make logs more consistent and useful for debugging, performance analysis, and tracing nested operations.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/technickai/claude_telemetry/logfire-logging
Clone the repo
git clone --depth 1 https://github.com/TechNickAI/claude_telemetry

Made for: Cursor.

Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 487 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00009 $0.00487
Opus 5 $0.00005 $0.00244
Sonnet 5 $0.00002 $0.00097
Haiku 4.5 $0.00001 $0.00049

Measured 2d ago against content hash 833ad7f1a957, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

logfire-logging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/observability/logfire-logging.mdc · 93 lines

How it starts

The opening of the file, as written. The whole thing — 93 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Logfire Logging

Core Pattern

from helpers.observability import logfire

# Basic logging
logfire.info("Operation completed",
             operation="data_processing",
             item_count=123)

# Spans for duration tracking
with logfire.span("Processing batch", batch_id=batch.id):
    result = process_batch(batch)
    logfire.info("Batch complete", items_processed=result.count)

When to Use Spans

We use spans for operations that have duration to track, nested sub-operations, or need grouped logs for easier debugging.

Span Naming

Create specific, human-readable span names:

with logfire.span(
    f"Processing {strategy_name} for {item.name}",
    item_id=item.id,
    strategy_name=strategy_name,
    operation="strategy_processing"
):
    execute_strategy()

with logfire.span(
    f"Syncing orders for {customer.email}",
    customer_id=customer.id,
    order_count=len(orders),
    operation="order_sync"
):
    sync_all_orders(orders)

with logfire.span(
    f"Generating report for {date.isoformat()}",
    report_type="daily_sales",
    date=date.isoformat()
):
    generate_daily_report(date)

Span names should immediately tell you what's happening. Include key identifiers to make debugging easier.

Logging Levels

  • logfire.info() - Normal operations, important events
  • logfire.error() - Serious problems
  • logfire.warning() - Concerning but recoverable
  • logfire.debug() - Detailed info for development

Context Attributes

Include searchable, meaningful attributes:

logfire.info(
    "Order processed successfully",
    order_id=order.id,
    customer_id=customer.id,
    total_amount=float(order.total),
    operation="order_processing"
)

What NOT to Log

We skip sensitive data (API keys, passwords), high-frequency noise (every loop iteration), obvious operations ("Starting function"), and debugging artifacts (use debug level for raw responses).

Best Practices

We make the first line immediately useful, include specific values (not just "processing"), use consistent attribute naming (snake_case), convert Decimals to floats, and stay thoughtful about volume.

Read the full file on GitHub · 93 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 93 lines · 9 tokens per session scan A 833ad7f1a957

Subscribe to this mod's changes

logfire-logging is a cursor rule published in the GitHub repository TechNickAI/claude_telemetry (30 stars, last pushed 10mo ago), licensed MIT. It adds 9 tokens to every session and 487 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.