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