# `Otel.Trace.Tracer`
[🔗](https://github.com/yangbancode/otel/blob/main/lib/otel/trace/tracer.ex#L1)

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:

- scope from `Otel.InstrumentationScope.new/1` defaults
- span limits from `Otel.Trace.SpanLimits.new/1` defaults

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

| Function | Role |
|---|---|
| `start_span/3` | OTel API MUST — `trace/api.md` §Span Creation L378-L414 |
| `with_span/4` | OTel 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

# `start_span`

```elixir
@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`

```elixir
@spec with_span(
  ctx :: Otel.Ctx.t(),
  name :: String.t(),
  opts :: Otel.Trace.Span.start_opts(),
  fun :: (Otel.Trace.SpanContext.t() -&gt; 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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
