Add host information to db entries (#1778)
Add new field to each db entry identifying the host that it originated from.
This commit is contained in:
parent
f99fae3c61
commit
9fe210c454
|
@ -109,6 +109,7 @@ sys-info = "0.5.6"
|
|||
tokio = "0.1"
|
||||
tokio-codec = "0.1"
|
||||
untrusted = "0.6.2"
|
||||
lazy_static = "1.2.0"
|
||||
solana-bpfloader = { path = "programs/native/bpf_loader", version = "0.11.0" }
|
||||
solana-erc20 = { path = "programs/native/erc20", version = "0.11.0" }
|
||||
solana-lualoader = { path = "programs/native/lua_loader", version = "0.11.0" }
|
||||
|
|
|
@ -123,6 +123,8 @@ extern crate sys_info;
|
|||
extern crate tokio;
|
||||
extern crate tokio_codec;
|
||||
extern crate untrusted;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
|
|
|
@ -3,14 +3,18 @@
|
|||
extern crate reqwest;
|
||||
|
||||
use influx_db_client as influxdb;
|
||||
use rand;
|
||||
use std::env;
|
||||
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||
use std::sync::{Arc, Barrier, Mutex, Once, ONCE_INIT};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use sys_info::hostname;
|
||||
use timing;
|
||||
|
||||
lazy_static! {
|
||||
static ref HOST_ID: i64 = rand::random::<i64>();
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum MetricsCommand {
|
||||
Submit(influxdb::Point),
|
||||
|
@ -131,6 +135,7 @@ impl MetricsAgent {
|
|||
}
|
||||
|
||||
pub fn submit(&self, mut point: influxdb::Point) {
|
||||
point.add_field("host_id", influxdb::Value::Integer(*HOST_ID));
|
||||
if point.timestamp.is_none() {
|
||||
point.timestamp = Some(timing::timestamp() as i64);
|
||||
}
|
||||
|
@ -237,10 +242,8 @@ pub fn set_panic_hook(program: &'static str) {
|
|||
Some(location) => location.to_string(),
|
||||
None => "?".to_string(),
|
||||
}),
|
||||
).add_field(
|
||||
"host",
|
||||
influxdb::Value::String(hostname().unwrap_or_else(|_| "?".to_string())),
|
||||
).to_owned(),
|
||||
).add_field("host_id", influxdb::Value::Integer(*HOST_ID))
|
||||
.to_owned(),
|
||||
);
|
||||
// Flush metrics immediately in case the process exits immediately
|
||||
// upon return
|
||||
|
|
Loading…
Reference in New Issue