Skip to content

fix: correct error span attributes for Datadog error tracking#120

Merged
wewelll merged 1 commit intomainfrom
fix/error-span-attributes
Jan 21, 2026
Merged

fix: correct error span attributes for Datadog error tracking#120
wewelll merged 1 commit intomainfrom
fix/error-span-attributes

Conversation

@wewelll
Copy link
Contributor

@wewelll wewelll commented Jan 21, 2026

Summary

  • Fix error.type extraction by changing tag to _tag property check to correctly handle Effect TaggedError
  • Wrap Cause.squashWith calls in String() to ensure span attributes are always strings
  • This ensures error.type, error.message, and error.stack are properly set for Datadog error tracking

Problem

When a handler in a subscriber returned an error, the onFailure handler was not correctly setting the error.type and error.stack span attributes for Datadog. Only error.message was being set.

The root cause was that the code checked for a tag property, but Effect TaggedError uses _tag as the property name.

Changes

  • packages/amqp/src/AMQPSubscriber.ts
  • packages/nats/src/JetStreamSubscriber.ts
  • packages/nats/src/NATSSubscriber.ts

Copy link

Copilot AI left a comment

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 fixes error span attributes for Datadog error tracking by correcting the property check for Effect's TaggedError and ensuring span attributes are always strings.

Changes:

  • Changed property check from tag to _tag to correctly extract error type from Effect TaggedError
  • Wrapped Cause.squashWith calls in String() to ensure span attributes are always strings
  • Updated error handling in AMQP and NATS subscribers

Reviewed changes

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

File Description
packages/nats/src/NATSSubscriber.ts Fixed error.type extraction and wrapped error attributes in String()
packages/nats/src/JetStreamSubscriber.ts Fixed error.type extraction and wrapped error attributes in String()
packages/amqp/src/AMQPSubscriber.ts Fixed error.type extraction and wrapped error attributes in String()
.changeset/fix-error-span-attributes.md Added changeset documentation for the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wewelll wewelll added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit d439eed Jan 21, 2026
11 checks passed
@wewelll wewelll deleted the fix/error-span-attributes branch January 21, 2026 18:04
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
@thibautsa
Copy link

Nice thanks @wewelll !

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.

2 participants