OpenTelemetry API v0.6.0 API Reference


An OpenTelemetry Trace consists of 1 or more Spans that either have a parent/child relationship or are linked together through a Link. Each Span has a TraceId (trace_id/0), SpanId (span_id/0), and a start and end time in nanoseconds.

Baggage is used to annotate telemetry, adding context and information to metrics, traces, and logs. It is represented by a set of name/value pairs describing user-defined properties.

require OpenTelemetry.Counter"some.counter")

OpenTelemetry.Counter.add("some.counter", 3)

Ctx is responsible for propagating values within a process that are associated with a particular Trace or set of Baggage. OpenTelemetry.Tracer and OpenTelemetry.Baggage handle updating the Context.

require OpenTelemetry.ValueRecorder
require OpenTelemetry.Counter
require OpenTelemetry.Meter



# use the new instrument by name
OpenTelemetry.Counter.add("some.counter", 1)

# or use a bound instrument
bound = OpenTelemetry.Meter.bind("some.latency", [])
# measure time spent on some function and then record it
OpenTelemetry.ValueRecorder.record(bound, time)

This module contains macros for Span operations that update the active current Span in the current process. An example of creating an Event and adding it to the current Span

require OpenTelemetry.SumObserver

OpenTelemetry.SumObserver.set_callback("some.counter", &OpenTelemetry.SumObserver.observe(&1, 33, []))

This module contains macros for Tracer operations around the lifecycle of the Spans within a Trace.

require OpenTelemetry.UpdownCounter"some.counter")

OpenTelemetry.UpdownCounter.add("some.counter", -3)
require OpenTelemetry.UpdownSumObserver

OpenTelemetry.UpdownSumObserver.set_callback("some.counter", OpenTelemetry.UpdownSumObserver.observe(&1, -33, []))
require OpenTelemetry.ValueObserver

OpenTelemetry.ValueObserver.set_callback("some.counter", fn o -> OpenTelemetry.ValueObserver.observe(o, 33, []))
require OpenTelemetry.ValueRecorder

OpenTelemetry.ValueRecorder.record("some.recorder", 3)