From ab4788bf71582a40590286d01f9400d3febfa78e Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Tue, 29 Aug 2017 17:58:50 -0400 Subject: [PATCH] changes influx host, adds ticker, side to KrknTrade meas --- Cargo.toml | 1 + src/influx.rs | 3 ++- src/latency.rs | 14 ++++++++++++-- src/lib.rs | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 93cc15a..8f9609e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ pub-sub = "2.0" slog = "2.0.6" windows = { path = "../windows" } +money = { path = "../money" } diff --git a/src/influx.rs b/src/influx.rs index 760bb62..3d88f9e 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -22,7 +22,8 @@ use warnings::Warning; const WRITER_ADDR: &'static str = "ipc:///tmp/mm/influx"; //const WRITER_ADDR: &'static str = "tcp://127.0.0.1:17853"; const DB_NAME: &'static str = "mm"; -const DB_HOST: &'static str = "http://localhost:8086/write"; +//const DB_HOST: &'static str = "http://localhost:8086/write"; +const DB_HOST: &'static str = "http://harrison.0ptimus.internal:8086/write"; const ZMQ_RCV_HWM: i32 = 0; const ZMQ_SND_HWM: i32 = 0; diff --git a/src/latency.rs b/src/latency.rs index 034d00d..61721e0 100644 --- a/src/latency.rs +++ b/src/latency.rs @@ -11,6 +11,8 @@ use zmq; use influent::measurement::{Measurement, Value}; use windows::{DurationWindow, Incremental}; +use money::{Ticker, Side}; + use influx; @@ -109,7 +111,7 @@ pub enum ExperiencedLatency { KrknHttpPrivate(Duration), - KrknTrade(Duration), + KrknTrade(Duration, Option, Option), EventLoop(Duration), @@ -350,13 +352,21 @@ impl LatencyManager { plnx_order.update(loop_time, d) } - ExperiencedLatency::KrknTrade(d) => { + ExperiencedLatency::KrknTrade(d, ticker, side) => { last.krkn = loop_time; let n = DurationWindow::nanos(d); krkn_trade_30.update(loop_time, d); krkn_trade_300.update(loop_time, d); + let ticker_s = ticker.map(|t| t.to_string()).unwrap_or("".into()); + let side_s = side.map(|s| s.to_string()).unwrap_or("".into()); let mut m = Measurement::new("krkn_trade_api"); m.add_field("nanos", Value::Integer(n as i64)); + if ticker.is_some() { + m.add_tag("ticker", &ticker_s); + } + if side.is_some() { + m.add_tag("side", &side_s); + } m.set_timestamp(now()); influx::serialize(&m, &mut buf); socket.send_str(&buf, 0); diff --git a/src/lib.rs b/src/lib.rs index 1a29e84..84d5fa0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ #![feature(test)] #[macro_use] extern crate slog; +#[macro_use] extern crate money; extern crate test; extern crate zmq;