20#ifndef ORES_TELEMETRY_DOMAIN_TELEMETRY_CONTEXT_HPP
21#define ORES_TELEMETRY_DOMAIN_TELEMETRY_CONTEXT_HPP
25#include "ores.telemetry/domain/span_context.hpp"
26#include "ores.telemetry/domain/span_kind.hpp"
27#include "ores.telemetry/domain/span.hpp"
28#include "ores.telemetry/domain/resource.hpp"
59 std::shared_ptr<resource> res);
106 std::pair<telemetry_context, span>
start_span(
107 std::string_view name,
122 std::string_view name,
132 std::shared_ptr<resource> resource_;
Domain types for telemetry and observability.
Definition attribute_value.hpp:29
span_kind
The type of span, following OpenTelemetry conventions.
Definition span_kind.hpp:34
@ internal
Default value. Indicates an internal operation within an application, not representing a remote call.
Represents the entity producing telemetry data.
Definition resource.hpp:39
Immutable context for trace propagation across boundaries.
Definition span_context.hpp:37
A 64-bit span identifier, compatible with OpenTelemetry.
Definition span_id.hpp:42
Immutable context passed through the call chain for telemetry.
Definition telemetry_context.hpp:50
static telemetry_context create_root(std::shared_ptr< resource > res)
Creates a root telemetry context for a new trace.
Definition telemetry_context.cpp:39
std::pair< telemetry_context, span > start_span(std::string_view name, span_kind kind=span_kind::internal) const
Creates a new child span within the same trace.
Definition telemetry_context.cpp:68
std::pair< telemetry_context, span > start_linked_trace(std::string_view name, span_kind kind=span_kind::internal) const
Creates a new trace linked to the current span.
Definition telemetry_context.cpp:91
const span_id & get_span_id() const
Gets the span_id from the current context.
Definition telemetry_context.cpp:56
const trace_id & get_trace_id() const
Gets the trace_id from the current context.
Definition telemetry_context.cpp:52
const span_context & context() const
Gets the current span context.
Definition telemetry_context.cpp:48
bool is_valid() const
Checks if this context is valid.
Definition telemetry_context.cpp:122
const resource & get_resource() const
Gets the resource associated with this context.
Definition telemetry_context.cpp:60
std::shared_ptr< resource > resource_ptr() const
Gets the shared pointer to the resource.
Definition telemetry_context.cpp:64
A 128-bit trace identifier, compatible with OpenTelemetry.
Definition trace_id.hpp:42