Skip to content

Add Trace.fromIOLocal for building a Trace[IO] from an existing IOLocal#1336

Open
kubukoz wants to merge 1 commit into
mainfrom
add-trace-fromiolocal
Open

Add Trace.fromIOLocal for building a Trace[IO] from an existing IOLocal#1336
kubukoz wants to merge 1 commit into
mainfrom
add-trace-fromiolocal

Conversation

@kubukoz

@kubukoz kubukoz commented Jul 3, 2026

Copy link
Copy Markdown
Member

What

Adds a public Trace.fromIOLocal(local: IOLocal[Span[IO]]): Trace[IO] constructor by extracting the anonymous IOLocal-backed instance that previously lived inside ioTrace. ioTrace now delegates to it:

def ioTrace(rootSpan: Span[IO]): IO[Trace[IO]] =
  IOLocal(rootSpan).map(fromIOLocal)

Why

Instances built via Trace.ioTrace / Trace.ioTraceForEntryPoint fully encapsulate their IOLocal[Span[IO]], so there is no way to reach the underlying current Span[IO] (or dump it to a ThreadLocal with typelevel/cats-effect#3636).

🤖 Generated with Claude Code

Extracts the anonymous IOLocal-backed instance out of `ioTrace` into a
public `fromIOLocal` constructor that takes a pre-constructed
`IOLocal[Span[IO]]` and returns a `Trace[IO]` directly (no `IO`).

This lets callers retain ownership of the `IOLocal`, so the current
`Span[IO]` remains accessible via `local.get`. `ioTrace` now delegates
to `fromIOLocal`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mergify mergify Bot added the core label Jul 3, 2026
@kubukoz kubukoz marked this pull request as ready for review July 3, 2026 22:13
@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant