Otel.Trace.Tracer (otel v0.4.1)

Copy Markdown View Source

Span creation entry points for the SDK.

Minikube has no plugin ecosystem and the spec's TracerProvider / Tracer entities collapse to a single hardcoded identity:

Both are runtime-constructed at each start_span/3 call — there is no Tracer struct to thread through. Sampling is hardcoded to Otel.Trace.Sampler (parentbased_always_on); ID generation to Otel.Trace.IdGenerator (random).

All functions are safe for concurrent use, satisfying spec trace/api.md L843-L853 (Status: Stable, #4887) — "Tracer — all methods MUST be documented that implementations need to be safe for concurrent use by default."

Public API

FunctionRole
start_span/3OTel API MUST — trace/api.md §Span Creation L378-L414
with_span/4OTel API MAY — trace/api.md L385 closure form

References

  • OTel Trace SDK §Tracer: opentelemetry-specification/specification/trace/sdk.md L120-L228
  • OTel Trace API §Tracer: opentelemetry-specification/specification/trace/api.md L160-L416

Summary

Functions

OTel API MUST — Span Creation (trace/api.md §Span Creation L378-L414).

OTel API MAY — start_span + make_current + closure + end_span in one call (trace/api.md L385).

Functions

start_span(ctx, name, opts)

@spec start_span(
  ctx :: Otel.Ctx.t(),
  name :: String.t(),
  opts :: Otel.Trace.Span.start_opts()
) :: Otel.Trace.SpanContext.t()

OTel API MUST — Span Creation (trace/api.md §Span Creation L378-L414).

Delegates to Otel.Trace.Span.start_span/4 for sampling and ID generation, stamps the hardcoded scope/limits, and inserts the span into ETS storage.

with_span(ctx, name, opts, fun)

@spec with_span(
  ctx :: Otel.Ctx.t(),
  name :: String.t(),
  opts :: Otel.Trace.Span.start_opts(),
  fun :: (Otel.Trace.SpanContext.t() -> result)
) :: result
when result: term()

OTel API MAY — start_span + make_current + closure + end_span in one call (trace/api.md L385).

Records exception attributes and sets :error status on any raised exception / thrown value / exit, then re-raises to preserve caller-side error handling. The try/catch here is the spec-mandated exception-recording contract, not error handling per code-conventions.md.