Skip to content

Add Trace.WithContext#741

Merged
catostrophe merged 4 commits intomasterfrom
trace-span-context
Apr 27, 2022
Merged

Add Trace.WithContext#741
catostrophe merged 4 commits intomasterfrom
trace-span-context

Conversation

@janstenpickle
Copy link
Copy Markdown
Collaborator

Adds the ability to obtain a span context from a Trace typeclass. This has been added as a more powerful typeclass so compatibility with Natchez can be preserved.

An obivious question may be, why not just use Ask here? Obtaining the context this way means that we don't have to either pass another type parameter for F on Span[F] when using Ask[G, Span[F]] or making users manually provide an Ask[G, SpanContext] instance using zoom.

Adds the ability to obtain a span context from a `Trace` typeclass.
This has been added as a more powerful typeclass so compatibility
with Natchez can be preserved.
type G[x] = Kleisli[IO, Env[IO], x]
implicit val gHasLocalSpan: Local[G, Span[IO]] = Local[G, Env[IO]].focus(Env.span)
implicitly[Trace[G]]
implicitly[Trace.WithContext[G]]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add summon tests for EitherT and EitherT ∘ Kleisli instances?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, they were missing before

}

object Trace extends TraceInstancesLowPriority {
trait WithContext[F[_]] extends Trace[F] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think IOLocal instance also should be enhanced?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, forgot that PR got merged

@catostrophe catostrophe merged commit b3ad01d into master Apr 27, 2022
@catostrophe catostrophe deleted the trace-span-context branch April 27, 2022 04:16
@catostrophe catostrophe added the enhancement New feature or request label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants