97 std::map<std::string, std::string>
headers;
231 const std::string& endpoint =
"http://localhost:4317") ->
tracing_config
235 config.otlp.endpoint = endpoint;
245 const std::string& endpoint =
"http://localhost:4318") ->
tracing_config
249 config.otlp.endpoint = endpoint;
259 const std::string& endpoint =
"http://localhost:14268/api/traces")
264 config.jaeger_endpoint = endpoint;
RAII span for distributed tracing.
exporter_type
Exporter types for trace data.
@ otlp_http
OTLP over HTTP (OpenTelemetry Collector)
@ otlp_grpc
OTLP over gRPC (OpenTelemetry Collector)
@ console
Console/stdout output (for debugging)
@ jaeger
Jaeger native format.
void flush_tracing()
Force flush all pending spans.
auto is_tracing_enabled() -> bool
Check if tracing is enabled.
void export_span(const span &s)
Export a completed span.
void register_span_processor(span_processor_callback callback)
Register a custom span processor.
sampler_type
Sampler types for trace sampling decisions.
@ trace_id
Sample based on trace ID ratio.
@ parent_based
Sample based on parent span's sampling decision.
@ always_off
Sample no traces.
@ always_on
Sample all traces.
void configure_tracing(const tracing_config &config)
Initialize the tracing system with configuration.
std::function< void(const span &)> span_processor_callback
Span processor callback type.
void shutdown_tracing()
Shutdown the tracing system.
Batch export configuration.
size_t max_export_batch_size
Maximum batch size for a single export @default 512.
std::chrono::milliseconds schedule_delay
Maximum time to wait before exporting a batch @default 5000ms.
std::chrono::milliseconds export_timeout
Timeout for export operations @default 30000ms.
size_t max_queue_size
Maximum number of spans to batch before export @default 512.
OTLP exporter configuration.
std::map< std::string, std::string > headers
Custom headers for OTLP requests.
std::string endpoint
Endpoint URL for OTLP exporter @default "http://localhost:4317" for gRPC, "http://localhost:4318" for...
std::string certificate_path
Certificate file path for TLS (optional)
bool insecure
Use insecure connection (no TLS) @default false.
std::chrono::milliseconds timeout
Connection timeout @default 10000ms.
Main configuration structure for tracing.
static auto otlp_http(const std::string &endpoint="http://localhost:4318") -> tracing_config
Create default configuration for OTLP HTTP exporter.
std::string zipkin_endpoint
Zipkin exporter endpoint @default "http://localhost:9411/api/v2/spans".
static auto console() -> tracing_config
Create default configuration with console exporter.
exporter_type exporter
Exporter type to use @default exporter_type::none.
std::string service_instance_id
Service instance ID (unique per instance) @default "" (auto-generated if empty)
sampler_type sampler
Sampler type to use @default sampler_type::always_on.
std::string service_version
Service version @default "".
std::string service_namespace
Service namespace @default "".
static auto otlp_grpc(const std::string &endpoint="http://localhost:4317") -> tracing_config
Create default configuration for OTLP gRPC exporter.
std::string jaeger_endpoint
Jaeger exporter endpoint @default "http://localhost:14268/api/traces".
double sample_rate
Sampling rate (0.0 to 1.0)
std::map< std::string, std::string > resource_attributes
Additional resource attributes.
static auto disabled() -> tracing_config
Create disabled tracing configuration.
otlp_config otlp
OTLP exporter configuration.
static auto jaeger(const std::string &endpoint="http://localhost:14268/api/traces") -> tracing_config
Create default configuration for Jaeger exporter.
std::string service_name
Service name for trace identification @default "network_system".
batch_config batch
Batch export configuration.
bool debug
Enable debug output @default false.