Nginx OTel module.
This commit is contained in:
parent
0cce01b3c7
commit
9d3e21194c
8 changed files with 963 additions and 0 deletions
25
src/trace_context.hpp
Normal file
25
src/trace_context.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <opentelemetry/trace/trace_id.h>
|
||||
#include <opentelemetry/trace/span_id.h>
|
||||
#include <opentelemetry/sdk/trace/random_id_generator.h>
|
||||
|
||||
#include "str_view.hpp"
|
||||
|
||||
struct TraceContext {
|
||||
opentelemetry::trace::TraceId traceId;
|
||||
opentelemetry::trace::SpanId spanId;
|
||||
bool sampled;
|
||||
StrView state;
|
||||
|
||||
static TraceContext generate(bool sampled, TraceContext parent = {})
|
||||
{
|
||||
opentelemetry::sdk::trace::RandomIdGenerator idGen;
|
||||
|
||||
return {parent.traceId.IsValid() ?
|
||||
parent.traceId : idGen.GenerateTraceId(),
|
||||
idGen.GenerateSpanId(),
|
||||
sampled,
|
||||
parent.state};
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue