Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/fix-error-span-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@effect-messaging/amqp": patch
"@effect-messaging/nats": patch
---

Fix error span attributes for Datadog error tracking

- Changed `tag` to `_tag` property check to correctly extract error type from Effect's TaggedError
- Wrapped `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
10 changes: 5 additions & 5 deletions packages/amqp/src/AMQPSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ const subscribe = (
span.attribute(ATTR_MESSAGING_OPERATION_NAME, "nack")
span.attribute(
"error.type",
Cause.squashWith(
String(Cause.squashWith(
cause,
(_) => Predicate.hasProperty(_, "tag") ? _.tag : _ instanceof Error ? _.name : `${_}`
)
(_) => Predicate.hasProperty(_, "_tag") ? _._tag : _ instanceof Error ? _.name : `${_}`
))
)
span.attribute("error.stack", Cause.pretty(cause))
span.attribute(
"error.message",
Cause.squashWith(
String(Cause.squashWith(
cause,
(_) => Predicate.hasProperty(_, "reason") ? _.reason : _ instanceof Error ? _.message : `${_}`
)
))
)
yield* channel.nack(message, false, false)
})
Expand Down
8 changes: 4 additions & 4 deletions packages/nats/src/JetStreamSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ const subscribe = (
span.attribute(ATTR_MESSAGING_OPERATION_NAME, "nak")
span.attribute(
"error.type",
Cause.squashWith(cause, (_) =>
Predicate.hasProperty(_, "tag") ? _.tag : _ instanceof Error ? _.name : `${_}`)
String(Cause.squashWith(cause, (_) =>
Predicate.hasProperty(_, "_tag") ? _._tag : _ instanceof Error ? _.name : `${_}`))
)
span.attribute("error.stack", Cause.pretty(cause))
span.attribute(
"error.message",
Cause.squashWith(cause, (_) =>
Predicate.hasProperty(_, "reason") ? _.reason : _ instanceof Error ? _.message : `${_}`)
String(Cause.squashWith(cause, (_) =>
Predicate.hasProperty(_, "reason") ? _.reason : _ instanceof Error ? _.message : `${_}`))
)
yield* message.nak()
})
Expand Down
10 changes: 5 additions & 5 deletions packages/nats/src/NATSSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ const subscribe = (
span.attribute(ATTR_MESSAGING_OPERATION_NAME, "error")
span.attribute(
"error.type",
Cause.squashWith(
String(Cause.squashWith(
cause,
(_) => Predicate.hasProperty(_, "tag") ? _.tag : _ instanceof Error ? _.name : `${_}`
)
(_) => Predicate.hasProperty(_, "_tag") ? _._tag : _ instanceof Error ? _.name : `${_}`
))
)
span.attribute("error.stack", Cause.pretty(cause))
span.attribute(
"error.message",
Cause.squashWith(
String(Cause.squashWith(
cause,
(_) => Predicate.hasProperty(_, "reason") ? _.reason : _ instanceof Error ? _.message : `${_}`
)
))
)
})
}),
Expand Down
Loading