PropagatorConverters

org.typelevel.otel4s.java.context.propagation.PropagatorConverters

This object provides extension methods that convert between Scala and Java TextMapGetters, TextMapPropagators, and ContextPropagators using asScala and asJava extension methods.

For the rare instances where they are needed, explicit conversion methods are defined in org.typelevel.otel4s.java.context.propagation.convert.PropagatorConverters.

import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator
import org.typelevel.otel4s.context.propagation.TextMapPropagator
import org.typelevel.otel4s.java.context.Context
import org.typelevel.otel4s.java.context.propagation.TextMapOperatorConverters._

val propagator: TextMapPropagator[Context] = W3CTraceContextPropagator.getInstance().asScala

The conversions return wrappers for the TextMap operators, and converting from a source type to a target type and back again will return the original source object. For example:

import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator
import org.typelevel.otel4s.context.propagation.TextMapPropagator
import org.typelevel.otel4s.java.context.Context
import org.typelevel.otel4s.java.context.propagation.TextMapOperatorConverters._

val source: W3CTraceContextPropagator = W3CTraceContextPropagator.getInstance()
val target: TextMapPropagator[Context] = source.asScala
val other: io.opentelemetry.context.propagation.TextMapPropagator = target.asJava
assert(source eq other)

Currently, ContextPropagators for both Java and Scala are simple wrappers around a TextMapPropagator instance of the corresponding type. Consequently, conversions between ContextPropagators convert the TextMapPropagator and do not use a custom wrapper.

Attributes

Source
PropagatorConverters.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited classlikes

Attributes

Inherited from:
AsJavaExtensions
Source
AsJavaExtensions.scala
Supertypes
class Object
trait Matchable
class Any
implicit class ContextPropagatorsHasAsScala(cp: ContextPropagators)

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala
Supertypes
class Object
trait Matchable
class Any
implicit class TextMapGetterHasAsJava[A](getter: TextMapGetter[A])

Attributes

Inherited from:
AsJavaExtensions
Source
AsJavaExtensions.scala
Supertypes
class Object
trait Matchable
class Any
implicit class TextMapGetterHasAsScala[A](getter: TextMapGetter[A])

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Inherited from:
AsJavaExtensions
Source
AsJavaExtensions.scala
Supertypes
class Object
trait Matchable
class Any
implicit class TextMapPropagatorHasAsScala(propagator: TextMapPropagator)

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala
Supertypes
class Object
trait Matchable
class Any

Implicits

Inherited implicits

final implicit def ContextPropagatorsHasAsScala(cp: ContextPropagators): ContextPropagatorsHasAsScala

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala
final implicit def TextMapGetterHasAsJava[A](getter: TextMapGetter[A]): TextMapGetterHasAsJava[A]

Attributes

Inherited from:
AsJavaExtensions
Source
AsJavaExtensions.scala
final implicit def TextMapGetterHasAsScala[A](getter: TextMapGetter[A]): TextMapGetterHasAsScala[A]

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala
final implicit def TextMapPropagatorHasAsScala(propagator: TextMapPropagator): TextMapPropagatorHasAsScala

Attributes

Inherited from:
AsScalaExtensions
Source
AsScalaExtensions.scala