Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::zipkin_span Struct Reference

#include <zipkin.hpp>

Inheritance diagram for fc::zipkin_span:
Collaboration diagram for fc::zipkin_span:

Classes

struct  span_data
 
struct  token
 

Public Member Functions

 zipkin_span (std::string name, uint64_t parent_id=0)
 
 zipkin_span (uint64_t id, std::string name, uint64_t parent_id=0)
 
 zipkin_span (const zipkin_span &)=delete
 
zipkin_spanoperator= (const zipkin_span &)=delete
 
zipkin_spanoperator= (zipkin_span &&)=delete
 
 zipkin_span (zipkin_span &&rhs) noexcept
 
 ~zipkin_span ()
 
void add_tag (const std::string &key, const std::string &var)
 
void add_tag (const std::string &key, const char *var)
 
void add_tag (const std::string &key, bool v)
 
template<typename T >
std::enable_if_t< std::is_arithmetic_v< std::remove_reference_t< T > >, void > add_tag (const std::string &key, T &&var)
 
template<typename T >
std::enable_if_t<!std::is_arithmetic_v< std::remove_reference_t< T > >, void > add_tag (const std::string &key, T &&var)
 
token get_token () const
 

Static Public Member Functions

static uint64_t to_id (const fc::sha256 &id)
 
template<typename T >
static uint64_t to_id (const T &id)
 

Public Attributes

span_data data
 

Detailed Description

Definition at line 60 of file zipkin.hpp.

Constructor & Destructor Documentation

◆ zipkin_span() [1/4]

fc::zipkin_span::zipkin_span ( std::string name,
uint64_t parent_id = 0 )
inlineexplicit

Definition at line 61 of file zipkin.hpp.

62 : data( std::move( name ), parent_id ) {}
std::string name
span_data data
Definition zipkin.hpp:149

◆ zipkin_span() [2/4]

fc::zipkin_span::zipkin_span ( uint64_t id,
std::string name,
uint64_t parent_id = 0 )
inlineexplicit

Definition at line 64 of file zipkin.hpp.

65 : data( id, std::move( name ), parent_id ) {}

◆ zipkin_span() [3/4]

fc::zipkin_span::zipkin_span ( const zipkin_span & )
delete

◆ zipkin_span() [4/4]

fc::zipkin_span::zipkin_span ( zipkin_span && rhs)
inlinenoexcept

Definition at line 71 of file zipkin.hpp.

72 : data( std::move( rhs.data ) ) {
73 rhs.data.id = 0;
74 }

◆ ~zipkin_span()

fc::zipkin_span::~zipkin_span ( )

Definition at line 197 of file zipkin.cpp.

197 {
198 if( data.id == 0 )
199 return;
200 try {
202 data.stop = time_point::now();
203 zipkin_config::get_zipkin().log( std::move( data ) );
204 }
205 } catch( ... ) {}
206}
static time_point now()
Definition time.cpp:14
static bool is_enabled()
Thread safe only if init() called from main thread before spawning of any threads.
Definition zipkin.hpp:29
static zipkin & get_zipkin()
Definition zipkin.cpp:26
void log(zipkin_span::span_data &&span)
Definition zipkin.cpp:158
Here is the call graph for this function:

Member Function Documentation

◆ add_tag() [1/5]

void fc::zipkin_span::add_tag ( const std::string & key,
bool v )
inline

Definition at line 88 of file zipkin.hpp.

88 {
89 // zipkin tags are required to be strings
90 data.tags( key, v ? "true" : "false" );
91 }

◆ add_tag() [2/5]

void fc::zipkin_span::add_tag ( const std::string & key,
const char * var )
inline

Definition at line 83 of file zipkin.hpp.

83 {
84 // zipkin tags are required to be strings
85 data.tags( key, var );
86 }

◆ add_tag() [3/5]

void fc::zipkin_span::add_tag ( const std::string & key,
const std::string & var )
inline

Definition at line 78 of file zipkin.hpp.

78 {
79 // zipkin tags are required to be strings
80 data.tags( key, var );
81 }

◆ add_tag() [4/5]

template<typename T >
std::enable_if_t< std::is_arithmetic_v< std::remove_reference_t< T > >, void > fc::zipkin_span::add_tag ( const std::string & key,
T && var )
inline

Definition at line 95 of file zipkin.hpp.

95 {
96 data.tags( key, std::to_string( std::forward<T>( var ) ) );
97 }

◆ add_tag() [5/5]

template<typename T >
std::enable_if_t<!std::is_arithmetic_v< std::remove_reference_t< T > >, void > fc::zipkin_span::add_tag ( const std::string & key,
T && var )
inline

Definition at line 101 of file zipkin.hpp.

101 {
102 data.tags( key, (std::string) var );
103 }

◆ get_token()

token fc::zipkin_span::get_token ( ) const
inline

Definition at line 116 of file zipkin.hpp.

116{ return token{data.id}; };
Here is the caller graph for this function:

◆ operator=() [1/2]

zipkin_span & fc::zipkin_span::operator= ( const zipkin_span & )
delete

◆ operator=() [2/2]

zipkin_span & fc::zipkin_span::operator= ( zipkin_span && )
delete

◆ to_id() [1/2]

uint64_t fc::zipkin_span::to_id ( const fc::sha256 & id)
static

Definition at line 192 of file zipkin.cpp.

192 {
193 // avoid 0 since id of 0 is used as a flag
194 return id._hash[3] == 0 ? 1 : id._hash[3];
195}

◆ to_id() [2/2]

template<typename T >
static uint64_t fc::zipkin_span::to_id ( const T & id)
inlinestatic

Definition at line 121 of file zipkin.hpp.

121 {
122 static_assert( std::is_same_v<decltype( id.data() ), const uint64_t*>, "expected uint64_t" );
123 return id.data()[3];
124 }
unsigned __int64 uint64_t
Definition stdint.h:136

Member Data Documentation

◆ data

span_data fc::zipkin_span::data

Definition at line 149 of file zipkin.hpp.


The documentation for this struct was generated from the following files: