Tracing

zio.telemetry.opentelemetry.tracing.Tracing
See theTracing companion object
trait Tracing

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

object aspects

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
aspects.type

Value members

Abstract methods

def addEvent(name: String)(implicit trace: Trace): UIO[Unit]

Adds an event to the current span.

Adds an event to the current span.

Attributes

def addEventWithAttributes(name: String, attributes: Attributes)(implicit trace: Trace): UIO[Unit]

Adds an event with attributes to the current span.

Adds an event with attributes to the current span.

Value parameters

attributes

event attributes

Attributes

def extractSpan[C, R, E, E1 <: E, A, A1 <: A](propagator: TraceContextPropagator, carrier: IncomingContextCarrier[C], spanName: String, spanKind: SpanKind, attributes: Attributes, statusMapper: StatusMapper[E, A], links: Seq[SpanContext])(zio: => ZIO[R, E1, A1])(implicit trace: Trace): ZIO[R, E1, A1]

Extracts the span from carrier C and set its child span with name 'spanName' as the current span.

Extracts the span from carrier C and set its child span with name 'spanName' as the current span.

Ends the span when the effect finishes.

Type parameters

C

carrier

Value parameters

carrier

mutable data from which the parent span is extracted

links

spanContexts of the linked Spans

propagator

implementation of zio.telemetry.opentelemetry.tracing.propagation.TraceContextPropagator

spanKind

kind of the child span

spanName

name of the child span

statusMapper

status mapper

zio

body of the child span

Attributes

def extractSpanUnsafe[C](propagator: TraceContextPropagator, carrier: IncomingContextCarrier[C], spanName: String, spanKind: SpanKind, attributes: Attributes, links: Seq[SpanContext])(implicit trace: Trace): UIO[(Span, UIO[Any])]

Extracts the span from carrier C and unsafely set its child span with name 'spanName' as the current span.

Extracts the span from carrier C and unsafely set its child span with name 'spanName' as the current span.

You need to make sure to call the finalize effect to end the span.

Primarily useful for interop.

Type parameters

C

carrier

Value parameters

carrier

mutable data from which the parent span is extracted

propagator

implementation of zio.telemetry.opentelemetry.tracing.propagation.TraceContextPropagator

spanKind

kind of the child span

spanName

name of the child span

Attributes

def getCurrentContextUnsafe(implicit trace: Trace): UIO[Context]

Gets the current Context

Gets the current Context

Attributes

Gets the current SpanContext.

Gets the current SpanContext.

Attributes

def getCurrentSpanUnsafe(implicit trace: Trace): UIO[Span]

Gets the current Span.

Gets the current Span.

Attributes

def inSpan[R, E, E1 <: E, A, A1 <: A](span: Span, spanName: String, spanKind: SpanKind, attributes: Attributes, statusMapper: StatusMapper[E, A], links: Seq[SpanContext])(zio: => ZIO[R, E1, A1])(implicit trace: Trace): ZIO[R, E1, A1]

Mark this effect as the child of an externally provided span. Ends the span when the effect finishes. zio-opentelemetry will mark the span as being the child of the external one.

Mark this effect as the child of an externally provided span. Ends the span when the effect finishes. zio-opentelemetry will mark the span as being the child of the external one.

This is designed for use-cases where you are incrementally introducing zio & zio-telemetry in a project that already makes use of instrumentation, and you need to interoperate with futures-based code.

The caller is solely responsible for managing the external span, including calling Span.end

It also could be useful in combination with extractSpanUnsafe or spanUnsafe:

 for {
   (span, finalize) <- tracing.spanUnsafe("unsafe-span")
   // run some logic that would be wrapped in the span
   // modify the span
   _                <- zio @@ tracing.inSpan(span, "child-of-unsafe-span")
 } yield ()

Value parameters

links

spanContexts of the linked Spans.

span

externally provided span

spanKind

kind of the child span

spanName

name of the child span

statusMapper

status mapper

zio

body of the child span

Attributes

def injectSpan[C](propagator: TraceContextPropagator, carrier: OutgoingContextCarrier[C])(implicit trace: Trace): UIO[Unit]

Injects the current span into carrier C.

Injects the current span into carrier C.

Type parameters

C

carrier

Value parameters

carrier

mutable data from which the parent span is extracted

propagator

implementation of zio.telemetry.opentelemetry.tracing.propagation.TraceContextPropagator

Attributes

def root[R, E, E1 <: E, A, A1 <: A](spanName: String, spanKind: SpanKind, attributes: Attributes, statusMapper: StatusMapper[E, A], links: Seq[SpanContext])(zio: => ZIO[R, E1, A1])(implicit trace: Trace): ZIO[R, E1, A1]

Sets the current span to be the new root span with name 'spanName'.

Sets the current span to be the new root span with name 'spanName'.

Ends the span when the effect finishes.

Value parameters

links

spanContexts of the linked Spans.

spanKind

name of the new root span

spanName

name of the new root span

statusMapper

status mapper

zio

body of the new root span

Attributes

def scopedEffect[A](effect: => A)(implicit trace: Trace): Task[A]

Introduces a thread-local scope during the execution allowing for non-zio context propagation.

Introduces a thread-local scope during the execution allowing for non-zio context propagation.

Closes the scope when the effect finishes.

Value parameters

effect

piece of code to execute in the current context

Attributes

def scopedEffectFromFuture[A](make: ExecutionContext => Future[A])(implicit trace: Trace): Task[A]

Introduces a thread-local scope from the currently active zio span allowing for non-zio context propagation. This scope will only be active during Future creation, so another mechanism must be used to ensure that the scope is passed into the Future callbacks.

Introduces a thread-local scope from the currently active zio span allowing for non-zio context propagation. This scope will only be active during Future creation, so another mechanism must be used to ensure that the scope is passed into the Future callbacks.

The java auto instrumentation package provides such a mechanism out of the box, so one is not provided as a part of this method.

CLoses the scope when the effect finishes.

Value parameters

make

function for providing a scala.concurrent.Future by a given scala.concurrent.ExecutionContext to execute in the current context

Attributes

def scopedEffectTotal[A](effect: => A)(implicit trace: Trace): UIO[A]

Introduces a thread-local scope during the execution allowing for non-zio context propagation.

Introduces a thread-local scope during the execution allowing for non-zio context propagation.

Closes the scope when the effect finishes.

Value parameters

effect

piece of code to execute in the current context

Attributes

def setAttribute(name: String, value: Boolean)(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute(name: String, value: Double)(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute(name: String, value: Long)(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute(name: String, value: String)(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute[T](key: AttributeKey[T], value: T)(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute[T](attribute: Attribute[T])(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Value parameters

attribute

convenient Scala wrapper for Java key/value

Attributes

def setAttribute(name: String, values: Seq[String])(implicit trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

def setAttribute(name: String, values: Seq[Boolean])(implicit i1: DummyImplicit, trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Value parameters

i1

dummy implicit value to disambiguate the method calls

Attributes

def setAttribute(name: String, values: Seq[Long])(implicit i1: DummyImplicit, i2: DummyImplicit, trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Value parameters

i1

dummy implicit value to disambiguate the method calls

i2

dummy implicit value to disambiguate the method calls

Attributes

def setAttribute(name: String, values: Seq[Double])(implicit i1: DummyImplicit, i2: DummyImplicit, i3: DummyImplicit, trace: Trace): UIO[Unit]

Sets an attribute of the current span.

Sets an attribute of the current span.

Value parameters

i1

dummy implicit value to disambiguate the method calls

i2

dummy implicit value to disambiguate the method calls

i3

dummy implicit value to disambiguate the method calls

Attributes

def span[R, E, E1 <: E, A, A1 <: A](spanName: String, spanKind: SpanKind, attributes: Attributes, statusMapper: StatusMapper[E, A], links: Seq[SpanContext])(zio: => ZIO[R, E1, A1])(implicit trace: Trace): ZIO[R, E1, A1]

Sets the current span to be the child of the current span with name 'spanName'.

Sets the current span to be the child of the current span with name 'spanName'.

Ends the span when the effect finishes.

Value parameters

links

spanContexts of the linked Spans.

spanKind

kind of the child span

spanName

name of the child span

statusMapper

status mapper

zio

body of the child span

Attributes

def spanScoped(spanName: String, spanKind: SpanKind, attributes: Attributes, statusMapper: StatusMapper[Any, Unit], links: Seq[SpanContext])(implicit trace: Trace): ZIO[Scope, Nothing, Unit]

Sets the current span to be the child of the current span with name 'spanName'.

Sets the current span to be the child of the current span with name 'spanName'.

Ends the span when the scope closes.

Value parameters

links

spanContexts of the linked Spans.

spanKind

kind of the child span

spanName

name of the child span

statusMapper

status mapper

Attributes

def spanUnsafe(spanName: String, spanKind: SpanKind, attributes: Attributes, links: Seq[SpanContext])(implicit trace: Trace): UIO[(Span, UIO[Any])]

Unsafely sets the current span to be the child of the current span with name 'spanName'.

Unsafely sets the current span to be the child of the current span with name 'spanName'.

You need to manually call the finalizer to end the span.

Primarily useful for interop.

Value parameters

spanKind

kind of the child span

spanName

name of the child span

Attributes