Skip to content

Commit

Permalink
add span stack trace to rendered causes
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed May 1, 2024
1 parent 142048e commit 02c3f03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-bikes-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

add span stack trace to rendered causes
4 changes: 4 additions & 0 deletions packages/effect/src/internal/cause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,11 @@ export const pretty = <E>(cause: Cause.Cause<E>): string => {
let current: Span | AnySpan | undefined = e.span
let i = 0
while (current && current._tag === "Span" && i < 10) {
const stack = current.attributes.get("code.stacktrace")
message += `\r\n at ${current.name}`
if (typeof stack === "string") {
message += `\r\n ${filterStack(stack)}`
}
current = Option.getOrUndefined(current.parent)
i++
}
Expand Down
2 changes: 2 additions & 0 deletions packages/effect/test/Effect/cause-rendering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe("Effect", () => {
)))
const rendered = Cause.pretty(cause)
assert.include(rendered, "spanA")
assert.include(rendered, "cause-rendering.test.ts:12")
assert.include(rendered, "spanB")
assert.include(rendered, "cause-rendering.test.ts:11")
}))
it.effect("catchTag should not invalidate traces", () =>
Effect.gen(function*($) {
Expand Down

0 comments on commit 02c3f03

Please sign in to comment.