Skip to content

Record exceptions on spans when callbacks throw or reject#102

Merged
petyosi merged 3 commits into
mainfrom
fix/span-record-exceptions
Apr 9, 2026
Merged

Record exceptions on spans when callbacks throw or reject#102
petyosi merged 3 commits into
mainfrom
fix/span-record-exceptions

Conversation

@petyosi

@petyosi petyosi commented Apr 9, 2026

Copy link
Copy Markdown
Member

Summary

  • span() now catches sync throws and async rejections from real Promise results, recording the exception on the span before re-throwing
  • Keeps span() defensive around arbitrary thenables: lazy thenables are returned untouched rather than eagerly subscribing via .then(), while preserving the existing finally() fallback for the zone.js promise case
  • Adds recordSpanException helper that calls recordException, sets ERROR status, upgrades log level, and computes a fingerprint
  • Matches the Python SDK's LogfireSpan.__exit__ behavior for synchronous throws and promise rejections

Fixes #101

petyosi added 3 commits April 9, 2026 10:25
The span() function now catches sync throws and async rejections,
recording the exception event, setting ERROR status, upgrading the
log level, and computing a fingerprint — matching the Python SDK's
behavior.

Fixes #101
@petyosi
petyosi merged commit 894cf8e into main Apr 9, 2026
2 checks passed
@petyosi
petyosi deleted the fix/span-record-exceptions branch April 9, 2026 08:13
jgpruitt added a commit to timescale/memory-engine that referenced this pull request Apr 9, 2026
Upstream fix (pydantic/logfire-js#102) makes span() automatically record
exceptions and set ERROR status on throw/reject, matching the Python SDK.

- Upgrade @pydantic/logfire-node ^0.13.0 → ^0.13.1
- Delete 5 identical telemetry.ts workaround files
- Switch all span() imports to @pydantic/logfire-node
- Drop unused direct @opentelemetry/api dependencies
jgpruitt added a commit to timescale/memory-engine that referenced this pull request Apr 9, 2026
Upstream fix (pydantic/logfire-js#102) makes span() automatically record
exceptions and set ERROR status on throw/reject, matching the Python SDK.

- Upgrade @pydantic/logfire-node ^0.13.0 → ^0.13.1
- Delete 5 identical telemetry.ts workaround files
- Switch all span() imports to @pydantic/logfire-node
- Drop unused direct @opentelemetry/api dependencies
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.

span() should record exceptions like the Python SDK does

1 participant