Repository navigation
Add experimental exception_callback configuration - #1355
Conversation
Deploying logfire-docs with
|
| 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 |
There was a problem hiding this comment.
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
ExceptionCallbacktype andExceptionCallbackHelperclass 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.
exception_callback configuration
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
…nerate a fingerprint by default
… into alex/exception-callback
There was a problem hiding this comment.
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_NUMBERSimport appears to be incomplete since the code changes show it was previously used in the test. Verify that this import removal is correct and thatLEVEL_NUMBERSis 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.
Also fixes some minor issues in how exceptions were being recorded