21#include <opentelemetry/exporters/ostream/span_exporter.h>
22#include <opentelemetry/sdk/trace/simple_processor.h>
23#include <opentelemetry/sdk/trace/tracer_provider.h>
24#include <opentelemetry/trace/tracer.h>
26namespace nostd = opentelemetry::nostd;
33 : span_(std::move(span))
36 void add_tag(
const std::string&
name,
const std::string& value)
override
38 span_->SetAttribute(
name, value);
40 void add_tag(
const std::string&
name, uint64_t value)
override
42 span_->SetAttribute(
name, value);
54 nostd::shared_ptr<opentelemetry::trace::Span> span_;
61 : tracer_(std::move(tracer))
65 auto start_span(std::string name, std::shared_ptr<couchbase::tracing::request_span>
parent = {})
66 -> std::shared_ptr<couchbase::tracing::request_span>
override
68 auto wrapped_parent = std::dynamic_pointer_cast<otel_request_span>(
parent);
70 opentelemetry::trace::StartSpanOptions opts;
71 opts.parent = wrapped_parent->wrapped_span()->GetContext();
72 return std::make_shared<otel_request_span>(tracer_->StartSpan(name, opts));
74 return std::make_shared<otel_request_span>(tracer_->StartSpan(name));
77 auto wrap_span(nostd::shared_ptr<opentelemetry::trace::Span> span)
78 -> std::shared_ptr<couchbase::tracing::otel_request_span>
80 return std::make_shared<couchbase::tracing::otel_request_span>(span);
84 nostd::shared_ptr<opentelemetry::trace::Tracer> tracer_;
Definition otel_tracer.hxx:30
void add_tag(const std::string &name, uint64_t value) override
Definition otel_tracer.hxx:40
nostd::shared_ptr< opentelemetry::trace::Span > wrapped_span()
Definition otel_tracer.hxx:48
void end() override
Definition otel_tracer.hxx:44
void add_tag(const std::string &name, const std::string &value) override
Definition otel_tracer.hxx:36
otel_request_span(nostd::shared_ptr< opentelemetry::trace::Span > span)
Definition otel_tracer.hxx:32
Definition otel_tracer.hxx:58
auto start_span(std::string name, std::shared_ptr< couchbase::tracing::request_span > parent={}) -> std::shared_ptr< couchbase::tracing::request_span > override
Definition otel_tracer.hxx:65
auto wrap_span(nostd::shared_ptr< opentelemetry::trace::Span > span) -> std::shared_ptr< couchbase::tracing::otel_request_span >
Definition otel_tracer.hxx:77
otel_request_tracer(nostd::shared_ptr< opentelemetry::trace::Tracer > tracer)
Definition otel_tracer.hxx:60
Definition request_span.hxx:27
auto name() const -> const std::string &
Definition request_span.hxx:49
Definition request_tracer.hxx:28
Definition otel_tracer.hxx:28
@ parent
Notify the context that the process has forked and is the parent.