A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
tracer.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A11_OBS_TRACER_H_
18#define A11_OBS_TRACER_H_
19
20#include <string_view>
21
22#include "a11/obs/span.h"
24
25namespace a11::obs {
26
35class Tracer {
36 public:
37 // Starts a span continuing a remote parent recovered from headers.
39 static Span StartSpan(std::string_view name, SpanKind kind,
40 const TraceContext* parent);
41
42 // Starts a span parented to an in-process span, inheriting its baggage.
44 static Span StartChildSpan(std::string_view name, SpanKind kind,
45 const Span& parent);
46
47 // Starts a root span for a session or stream, optionally pinning the trace id
48 // (32 lowercase hex chars).
50 static Span StartRootSpan(std::string_view name, SpanKind kind,
51 std::string_view preassigned_trace_id = {});
52};
53
54} // namespace a11::obs
55
56#endif // A11_OBS_TRACER_H_
Move-only RAII handle to one action, session, or transport span.
Definition span.h:51
Factory that makes parentage explicit for A11's migrating fibers.
Definition tracer.h:35
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:393
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:377
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:354
TokenKind kind
Definition format.cc:913
std::string name
The name and its colon, which travel together because they always do.
Definition format.cc:49
Definition provider.cc:58
SpanKind
OpenTelemetry span relationships, mirrored to keep OTel out of this API.
Definition span.h:35
const Scope * parent
Definition resolve.cc:730
SDK-independent W3C parent context recovered from reserved action headers.
Definition trace_context.h:50