29 static bool is_enabled() {
return get_zipkin_() !=
nullptr; }
35 static void init(
const std::string&
url,
const std::string& service_name,
uint32_t timeout_us );
52 static zipkin* get_zipkin_() {
return get().zip.get(); };
54 static zipkin_config& get();
57 std::unique_ptr<zipkin> zip;
62 : data(
std::move(
name ), parent_id ) {}
65 : data(
id,
std::move(
name ), parent_id ) {}
72 :
data( std::move( rhs.data ) ) {
78 void add_tag(
const std::string& key,
const std::string& var ) {
80 data.tags( key, var );
83 void add_tag(
const std::string& key,
const char* var ) {
85 data.tags( key, var );
88 void add_tag(
const std::string& key,
bool v ) {
90 data.tags( key, v ?
"true" :
"false" );
94 std::enable_if_t<std::is_arithmetic_v<std::remove_reference_t<T>>,
void>
96 data.tags( key, std::to_string( std::forward<T>( var ) ) );
100 std::enable_if_t<!std::is_arithmetic_v<std::remove_reference_t<T>>,
void>
102 data.tags( key, (std::string) var );
109 constexpr explicit operator bool() const noexcept {
return id != 0; }
122 static_assert( std::is_same_v<
decltype(
id.data() ),
const uint64_t*>,
"expected uint64_t" );
159 [[nodiscard]]
static std::optional<zipkin_span>
166 std::optional<zipkin_trace>
opt;
168 constexpr explicit operator bool() const noexcept {
return opt.has_value(); }
177 zipkin(
const std::string&
url,
const std::string& service_name,
uint32_t timeout_us );
193 std::unique_ptr<impl> my;
An order-preserving dictionary of variants.
static uint64_t get_next_unique_id()
Starts with a random id and increments on each call, will not return 0.
static bool is_enabled()
Thread safe only if init() called from main thread before spawning of any threads.
static zipkin & get_zipkin()
void log(zipkin_span::span_data &&span)
uint64_t get_next_unique_id()
Starts with a random id and increments on each call, will not return 0.
~zipkin()=default
finishes logging all queued up spans
zipkin(const std::string &url, const std::string &service_name, uint32_t timeout_us)
constexpr const char sha256[]
#define T(meth, val, expected)
unsigned __int64 uint64_t
zipkin_span::token get_token() const
std::optional< zipkin_trace > opt
fc::mutable_variant_object tags
span_data(const span_data &)=delete
span_data(span_data &&rhs)=default
span_data & operator=(span_data &&)=delete
span_data(uint64_t id, std::string name, uint64_t parent_id=0)
span_data & operator=(const span_data &)=delete
span_data(std::string name, uint64_t parent_id=0)
const fc::time_point start
zipkin_span & operator=(zipkin_span &&)=delete
static uint64_t to_id(const fc::sha256 &id)
zipkin_span(uint64_t id, std::string name, uint64_t parent_id=0)
zipkin_span(zipkin_span &&rhs) noexcept
std::enable_if_t<!std::is_arithmetic_v< std::remove_reference_t< T > >, void > add_tag(const std::string &key, T &&var)
void add_tag(const std::string &key, const char *var)
void add_tag(const std::string &key, bool v)
static uint64_t to_id(const T &id)
zipkin_span & operator=(const zipkin_span &)=delete
std::enable_if_t< std::is_arithmetic_v< std::remove_reference_t< T > >, void > add_tag(const std::string &key, T &&var)
void add_tag(const std::string &key, const std::string &var)
zipkin_span(const zipkin_span &)=delete
zipkin_span(std::string name, uint64_t parent_id=0)
std::optional< zipkin_span > create_span(std::string name) const
static std::optional< zipkin_span > create_span_from_token(zipkin_span::token token, std::string name)