Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::zipkin::impl Class Reference
Collaboration diagram for fc::zipkin::impl:

Public Member Functions

 impl (std::string url, std::string service_name, uint32_t timeout_us)
 
void init ()
 
void shutdown ()
 
void log (zipkin_span::span_data &&span)
 
 ~impl ()
 

Public Attributes

const std::string zipkin_url
 
const std::string service_name
 
const uint32_t timeout_us
 
std::mutex mtx
 
uint64_t next_id = 0
 
http_client http
 
std::atomic< uint32_tconsecutive_errors = 0
 
std::atomic< unsigned char > stopped = 0
 
std::optional< urlendpoint
 
std::thread thread
 
boost::asio::io_context ctx
 
boost::asio::io_context::strand work_strand {ctx}
 
boost::asio::executor_work_guard< boost::asio::io_context::executor_type > work_guard = boost::asio::make_work_guard(ctx)
 

Static Public Attributes

static constexpr uint32_t max_consecutive_errors = 9
 

Detailed Description

Definition at line 46 of file zipkin.cpp.

Constructor & Destructor Documentation

◆ impl()

fc::zipkin::impl::impl ( std::string url,
std::string service_name,
uint32_t timeout_us )
inline

Definition at line 64 of file zipkin.cpp.

65 : zipkin_url( std::move(url) )
66 , service_name( std::move(service_name) )
68 }
const uint32_t timeout_us
Definition zipkin.cpp:52
const std::string service_name
Definition zipkin.cpp:51
const std::string zipkin_url
Definition zipkin.cpp:50
string url
Definition main.cpp:166

◆ ~impl()

fc::zipkin::impl::~impl ( )

Definition at line 90 of file zipkin.cpp.

90 {
91 try {
92 shutdown();
93 } catch (...) {}
94}
void shutdown()
Definition zipkin.cpp:96
Here is the call graph for this function:

Member Function Documentation

◆ init()

void fc::zipkin::impl::init ( )

Definition at line 78 of file zipkin.cpp.

78 {
79 thread = std::thread( [this]() {
80 fc::set_os_thread_name( "zipkin" );
81 while( true ) {
82 try {
83 ctx.run();
84 break;
86 }
87 } );
88}
boost::asio::io_context ctx
Definition zipkin.cpp:60
#define FC_LOG_AND_DROP(...)
void set_os_thread_name(const string &name)
Here is the call graph for this function:

◆ log()

void fc::zipkin::impl::log ( zipkin_span::span_data && span)

Definition at line 167 of file zipkin.cpp.

167 {
169 return;
170
171 try {
172 auto deadline = fc::time_point::now() + fc::microseconds( timeout_us );
173 if( !endpoint ) {
175 dlog( "connecting to zipkin: ${p}", ("p", *endpoint) );
176 }
177
178 http.post_sync( *endpoint, create_zipkin_variant( std::move( span ), service_name ), deadline );
179
181 return;
182 } catch( const fc::exception& e ) {
183 wlog( "unable to connect to zipkin: ${u}, error: ${e}", ("u", zipkin_url)("e", e.to_detail_string()) );
184 } catch( const std::exception& e ) {
185 wlog( "unable to connect to zipkin: ${u}, error: ${e}", ("u", zipkin_url)("e", e.what()) );
186 } catch( ... ) {
187 wlog( "unable to connect to zipkin: ${u}, error: unknown", ("u", zipkin_url) );
188 }
190}
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
std::string to_detail_string(log_level ll=log_level::all) const
static time_point now()
Definition time.cpp:14
std::optional< url > endpoint
Definition zipkin.cpp:58
static constexpr uint32_t max_consecutive_errors
Definition zipkin.cpp:48
std::atomic< uint32_t > consecutive_errors
Definition zipkin.cpp:56
#define wlog(FORMAT,...)
Definition logger.hpp:124
#define dlog(FORMAT,...)
Definition logger.hpp:101
fc::variant create_zipkin_variant(zipkin_span::span_data &&span, const std::string &service_name)
Definition zipkin.cpp:121
Here is the call graph for this function:

◆ shutdown()

void fc::zipkin::impl::shutdown ( )

Definition at line 96 of file zipkin.cpp.

96 {
97 if( stopped ^= 1 ) return;
98 work_guard.reset(); // drain the queue
99 thread.join();
100}
std::atomic< unsigned char > stopped
Definition zipkin.cpp:57
boost::asio::executor_work_guard< boost::asio::io_context::executor_type > work_guard
Definition zipkin.cpp:62

Member Data Documentation

◆ consecutive_errors

std::atomic<uint32_t> fc::zipkin::impl::consecutive_errors = 0

Definition at line 56 of file zipkin.cpp.

◆ ctx

boost::asio::io_context fc::zipkin::impl::ctx

Definition at line 60 of file zipkin.cpp.

◆ endpoint

std::optional<url> fc::zipkin::impl::endpoint

Definition at line 58 of file zipkin.cpp.

◆ http

http_client fc::zipkin::impl::http

Definition at line 55 of file zipkin.cpp.

◆ max_consecutive_errors

uint32_t fc::zipkin::impl::max_consecutive_errors = 9
staticconstexpr

Definition at line 48 of file zipkin.cpp.

◆ mtx

std::mutex fc::zipkin::impl::mtx

Definition at line 53 of file zipkin.cpp.

◆ next_id

uint64_t fc::zipkin::impl::next_id = 0

Definition at line 54 of file zipkin.cpp.

◆ service_name

const std::string fc::zipkin::impl::service_name

Definition at line 51 of file zipkin.cpp.

◆ stopped

std::atomic<unsigned char> fc::zipkin::impl::stopped = 0

Definition at line 57 of file zipkin.cpp.

◆ thread

std::thread fc::zipkin::impl::thread

Definition at line 59 of file zipkin.cpp.

◆ timeout_us

const uint32_t fc::zipkin::impl::timeout_us

Definition at line 52 of file zipkin.cpp.

◆ work_guard

boost::asio::executor_work_guard<boost::asio::io_context::executor_type> fc::zipkin::impl::work_guard = boost::asio::make_work_guard(ctx)

Definition at line 62 of file zipkin.cpp.

◆ work_strand

boost::asio::io_context::strand fc::zipkin::impl::work_strand {ctx}

Definition at line 61 of file zipkin.cpp.

61{ctx};

◆ zipkin_url

const std::string fc::zipkin::impl::zipkin_url

Definition at line 50 of file zipkin.cpp.


The documentation for this class was generated from the following file: