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

Concise view

Type members

Classlikes

object aspects

Attributes

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

Value members

Abstract methods

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

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[Span]

Adds an event with attributes to the current span.

Adds an event with attributes to the current span.

Attributes

attributes

event attributes

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

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.

Attributes

C

carrier

carrier

mutable data from which the parent span is extracted

errorMapper

error mapper

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

zio

body of the child span

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.

Attributes

C

carrier

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

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

Gets the current Context

Gets the current Context

Attributes

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

Gets the current Span.

Gets the current Span.

Attributes

Gets the current SpanContext.

Gets the current SpanContext.

Attributes

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

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 ()

Attributes

errorMapper

error mapper

links

spanContexts of the linked Spans.

span

externally provided span

spanKind

kind of the child span

spanName

name of the child span

zio

body of the child span

def inject[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.

Attributes

C

carrier

carrier

mutable data from which the parent span is extracted

propagator

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

def root[R, E, A](spanName: String, spanKind: SpanKind, attributes: Attributes, errorMapper: ErrorMapper[E], links: Seq[SpanContext])(zio: => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

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.

Attributes

errorMapper

error mapper

links

spanContexts of the linked Spans.

spanKind

name of the new root span

spanName

name of the new root span

zio

body of the new root span

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.

Attributes

effect

piece of code to execute in the current context

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.

Attributes

make

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

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.

Attributes

effect

piece of code to execute in the current context

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

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[Span]

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[Span]

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[Span]

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[Span]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

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

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[Span]

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

i1

dummy implicit value to disambiguate the method calls

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

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

i1

dummy implicit value to disambiguate the method calls

i2

dummy implicit value to disambiguate the method calls

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

Sets an attribute of the current span.

Sets an attribute of the current span.

Attributes

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

def span[R, E, A](spanName: String, spanKind: SpanKind, attributes: Attributes, errorMapper: ErrorMapper[E], links: Seq[SpanContext])(zio: => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

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.

Attributes

errorMapper

error mapper

links

spanContexts of the linked Spans.

spanKind

kind of the child span

spanName

name of the child span

zio

body of the child span

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.

Attributes

spanKind

kind of the child span

spanName

name of the child span