Tweaked metrics.
This commit is contained in:
1 parent
ac0d0d8dae
commit
d4abac9d0d
4 files changed
+45
-32
No files matched your search
@@ -1,11 +1,11 @@
|
||||
#include "SocketConnection.h"
|
||||
#include "lib/jetfix/store/session_name.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/metrics/metrics.h"
|
||||
#include "lib/tracing/bts_trace.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/helper_macros.h"
|
||||
#include "lib/metrics/metrics.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <fstream>
|
||||
@@ -20,9 +20,8 @@ namespace jetfix {
|
||||
|
||||
SocketConnection::SocketConnection(bts::config::JetFIX::Connection const &cfg,
|
||||
metrics::MetricsContainer &stats)
|
||||
: _fd(-1), _cfg(cfg), _log(cfg.log_fix_stream()), _in_log(), _out_log(),_stats(stats),
|
||||
_tick_to_order(), _fill_to_order()
|
||||
{
|
||||
: _fd(-1), _cfg(cfg), _log(cfg.log_fix_stream()), _in_log(), _out_log(),
|
||||
_stats(stats), _tick_to_order(), _fill_to_order() {
|
||||
if (_log) {
|
||||
_in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg),
|
||||
std::ios_base::app);
|
||||
@@ -30,10 +29,17 @@ SocketConnection::SocketConnection(bts::config::JetFIX::Connection const &cfg,
|
||||
std::ios_base::app);
|
||||
}
|
||||
std::vector<metrics::Label> labels;
|
||||
labels.push_back({ "connection", cfg.name()});
|
||||
labels.push_back({"connection", cfg.name()});
|
||||
|
||||
_tick_to_order = std::make_shared<metrics::CounterMetric<uint64_t>> ("spark_tick_to_order_ns",labels);
|
||||
_fill_to_order = std::make_shared<metrics::CounterMetric<uint64_t>> ("spark_fill_to_order_ns",labels);
|
||||
std::array<double, 30> buckets;
|
||||
auto i = 1;
|
||||
for (auto &b : buckets)
|
||||
b = (i *= 2);
|
||||
|
||||
_tick_to_order = std::make_shared<metrics::HistogramMetric<30>>(
|
||||
"spark_tick_to_order_ns", buckets, labels);
|
||||
_fill_to_order = std::make_shared<metrics::HistogramMetric<30>>(
|
||||
"spark_fill_to_order_ns", buckets, labels);
|
||||
_stats.publish(_tick_to_order);
|
||||
_stats.publish(_fill_to_order);
|
||||
}
|
||||
@@ -121,28 +127,31 @@ int SocketConnection::write(WriteVec const &vec, size_t vec_size,
|
||||
auto result = ::writev(_fd, iv, (int)vec_size);
|
||||
|
||||
if (trace.md.to_uint64()) {
|
||||
auto s2s = (trace_cpy.fix_socket_w - trace_cpy.md).microseconds();
|
||||
auto s2s = (trace_cpy.fix_socket_w - trace_cpy.md);
|
||||
LOG(Latency, Info,
|
||||
"tick_to_order event trace. s2s_us:{} fix_socket_r:{} md:{} md_src:{} spreader:{} "
|
||||
"order_update:{} exe_gw:{} fix_socket_w:{} md_sn:{}",s2s,
|
||||
trace_cpy.fix_socket_r.to_uint64(), trace_cpy.md.to_uint64(),
|
||||
trace_cpy.md_src.to_uint64(), trace_cpy.spreader.to_uint64(),
|
||||
trace_cpy.order_update.to_uint64(), trace_cpy.exe_gw.to_uint64(),
|
||||
trace_cpy.fix_socket_w.to_uint64(), trace_cpy.md_sn);
|
||||
_tick_to_order->set(s2s);
|
||||
"tick_to_order event trace. s2s_us:{} fix_socket_r:{} md:{} "
|
||||
"md_src:{} spreader:{} "
|
||||
"order_update:{} exe_gw:{} fix_socket_w:{} md_sn:{}",
|
||||
s2s.microseconds(), trace_cpy.fix_socket_r.to_uint64(),
|
||||
trace_cpy.md.to_uint64(), trace_cpy.md_src.to_uint64(),
|
||||
trace_cpy.spreader.to_uint64(), trace_cpy.order_update.to_uint64(),
|
||||
trace_cpy.exe_gw.to_uint64(), trace_cpy.fix_socket_w.to_uint64(),
|
||||
trace_cpy.md_sn);
|
||||
_tick_to_order->observe(s2s.nanoseconds());
|
||||
}
|
||||
|
||||
if (trace.fix_socket_r.to_uint64()) {
|
||||
auto s2s = (trace_cpy.fix_socket_w - trace_cpy.md).microseconds();
|
||||
auto s2s = (trace_cpy.fix_socket_w - trace_cpy.fix_socket_r);
|
||||
LOG(Latency, Info,
|
||||
"fill_to_order trace. s2s_us:{} fix_socket_r:{} md:{} md_src:{} spreader:{} "
|
||||
"fill_to_order trace. s2s_us:{} fix_socket_r:{} md:{} md_src:{} "
|
||||
"spreader:{} "
|
||||
"order_update:{} exe_gw:{} fix_socket_w:{} md_sn:{}",
|
||||
(trace_cpy.fix_socket_w - trace_cpy.md).microseconds(),
|
||||
trace_cpy.fix_socket_r.to_uint64(), trace_cpy.md.to_uint64(),
|
||||
trace_cpy.md_src.to_uint64(), trace_cpy.spreader.to_uint64(),
|
||||
trace_cpy.order_update.to_uint64(), trace_cpy.exe_gw.to_uint64(),
|
||||
trace_cpy.fix_socket_w.to_uint64(), trace_cpy.md_sn);
|
||||
_fill_to_order->set(s2s);
|
||||
s2s.microseconds(), trace_cpy.fix_socket_r.to_uint64(),
|
||||
trace_cpy.md.to_uint64(), trace_cpy.md_src.to_uint64(),
|
||||
trace_cpy.spreader.to_uint64(), trace_cpy.order_update.to_uint64(),
|
||||
trace_cpy.exe_gw.to_uint64(), trace_cpy.fix_socket_w.to_uint64(),
|
||||
trace_cpy.md_sn);
|
||||
_fill_to_order->observe(s2s.nanoseconds());
|
||||
}
|
||||
|
||||
tracepoint(bts_trace, trace_order, (char *)"SocketConnection.post_write", 0,
|
||||
|
||||
Reference in new issue
Block a user