A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
tracer.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2
3#ifndef A11_OBS_TRACER_H_
4#define A11_OBS_TRACER_H_
5
6#include <string_view>
7
8#include "a11/obs/span.h"
10
11namespace a11::obs {
12
21class Tracer {
22 public:
23 // Starts a span continuing a remote parent recovered from headers. When
24 // `parent` is null (or points at an empty context), the span begins a fresh
25 // root trace. Baggage carried by the parent is retained for propagation.
27 static Span StartSpan(std::string_view name, SpanKind kind,
28 const TraceContext* parent);
29
30 // Starts a span parented to an in-process span, inheriting its baggage.
32 static Span StartChildSpan(std::string_view name, SpanKind kind,
33 const Span& parent);
34
35 // Starts a root span for a session or stream, optionally pinning the trace
36 // id (32 lowercase hex chars). An empty `preassigned_trace_id` lets the SDK
37 // generate one. This is the implementation-level hook for preassigning trace
38 // ids without widening any public transport interface.
40 static Span StartRootSpan(std::string_view name, SpanKind kind,
41 std::string_view preassigned_trace_id = {});
42};
43
44} // namespace a11::obs
45
46#endif // A11_OBS_TRACER_H_
Move-only RAII handle to one action, session, or transport span.
Definition span.h:37
Factory that makes parentage explicit for A11's migrating fibers.
Definition tracer.h:21
static Span StartRootSpan(std::string_view name, SpanKind kind, std::string_view preassigned_trace_id={})
Start a root span, optionally using a preassigned 32-character trace id.
Definition tracer.cc:386
static Span StartChildSpan(std::string_view name, SpanKind kind, const Span &parent)
Start an in-process child and inherit the parent's baggage.
Definition tracer.cc:370
static Span StartSpan(std::string_view name, SpanKind kind, const TraceContext *parent)
Continue parent, or begin a root when it is null or empty.
Definition tracer.cc:347
Definition provider.cc:47
SpanKind
OpenTelemetry span relationships, mirrored to keep OTel out of this API.
Definition span.h:21
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30
SDK-independent W3C parent context recovered from reserved action headers.
Definition trace_context.h:36