Skip to content

Add experimental exception_callback configuration - #1355

Merged
alexmojaki merged 21 commits into
mainfrom
alex/exception-callback
Oct 3, 2025
Merged

alexmojaki merged 21 commits into
mainfrom
alex/exception-callback

Conversation

@alexmojaki

@alexmojaki alexmojaki commented Aug 26, 2025 •

Copy link
Copy Markdown
Contributor

Also fixes some minor issues in how exceptions were being recorded

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 26, 2025 •

Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e737305
Status: ✅  Deploy successful!
Preview URL: https://a9e3d397.logfire-docs.pages.dev
Branch Preview URL: https://alex-exception-callback.logfire-docs.pages.dev

View logs

@alexmojaki
alexmojaki marked this pull request as ready for review August 27, 2025 14:56
Comment thread logfire/_internal/main.py Resolved
Comment thread logfire/_internal/main.py Resolved
@alexmojaki
alexmojaki requested a review from Copilot August 27, 2025 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements an exception callback system that allows users to customize how exceptions are handled when recorded on spans. The changes add an experimental ExceptionCallback feature that provides control over exception recording behavior, issue creation, and fingerprinting.

  • Adds a new ExceptionCallback type and ExceptionCallbackHelper class to customize exception handling
  • Removes duplicate patches in tests and refactors to use a centralized exception recording mechanism
  • Updates timing-related test assertions to use fixed timestamps instead of dynamic values

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
logfire/types.py Introduces new types for exception callback functionality including SpanLevel, ExceptionCallbackHelper, and ExceptionCallback
logfire/_internal/config.py Adds exception_callback field to AdvancedOptions configuration
logfire/_internal/tracer.py Integrates exception callback into span creation and exception recording logic
logfire/_internal/main.py Updates method signatures and removes direct calls to standalone record_exception function
logfire/sampling/_tail_sampling.py Refactors to use the new SpanLevel class from types.py instead of local implementation
tests/test_exceptions.py Adds comprehensive tests for the new exception callback functionality
tests/test_canonicalize_exception.py Adds test for exception canonicalization when traceback is None
tests/test_logfire.py Removes duplicate patches and updates test assertions with fixed timestamps
tests/otel_integrations/test_openai_agents.py Updates test assertions with fixed timestamps and removes unused import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@alexmojaki alexmojaki changed the title ExceptionCallback Add experimental exception_callback configuration Aug 27, 2025
@alexmojaki
alexmojaki requested a review from dmontagu August 27, 2025 14:58
Comment thread logfire/_internal/config.py Resolved
@alexmojaki
alexmojaki requested a review from Copilot October 3, 2025 11:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

tests/otel_integrations/test_fastapi.py:1

  • The removal of LEVEL_NUMBERS import appears to be incomplete since the code changes show it was previously used in the test. Verify that this import removal is correct and that LEVEL_NUMBERS is not referenced elsewhere in the file.
from __future__ import annotations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread logfire/_internal/tracer.py Resolved
@alexmojaki
alexmojaki requested a review from dmontagu October 3, 2025 11:18
@alexmojaki
alexmojaki enabled auto-merge (squash) October 3, 2025 13:17
@alexmojaki
alexmojaki merged commit df8f36d into main Oct 3, 2025
@alexmojaki
alexmojaki deleted the alex/exception-callback branch October 3, 2025 13:21
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.

3 participants