Skip to content

Commit

Permalink
fixup! Add PassThroughPropagator
Browse files Browse the repository at this point in the history
review tweaks
  • Loading branch information
NthPortal committed Nov 28, 2023
1 parent 6d938e8 commit 1d9d185
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.typelevel.otel4s.context
package propagation

import cats.Foldable
import cats.effect.SyncIO
import org.typelevel.otel4s.context.syntax._

Expand Down Expand Up @@ -44,7 +45,8 @@ final class PassThroughPropagator[Ctx, K[X] <: Key[X]] private (
.getOrElse(entriesKey, Nil)
.foldLeft(carrier) { case (c, k -> v) => updater.updated(c, k, v) }

override def toString: String = s"PassThroughPropagator{fields=$fields}"
override def toString: String =
s"PassThroughPropagator{fields=${fields.mkString("[", ", ", "]")}}"
}

object PassThroughPropagator {
Expand All @@ -71,9 +73,10 @@ object PassThroughPropagator {
forDistinctFields(fields.distinct)

/** Creates a `PassThroughPropagator` that propagates the given fields. */
def apply[Ctx, K[X] <: Key[X]](fields: IterableOnce[String])(implicit
def apply[F[_], Ctx, K[X] <: Key[X]](fields: F[String])(implicit
F: Foldable[F],
c: Contextual.Keyed[Ctx, K],
kp: Key.Provider[SyncIO, K]
): TextMapPropagator[Ctx] =
forDistinctFields(fields.iterator.distinct.toSeq)
forDistinctFields(F.toList(fields).distinct)
}

0 comments on commit 1d9d185

Please sign in to comment.