rtiow: remove prometheus monitoring support.
This commit is contained in:
@@ -7,87 +7,16 @@ extern crate rand;
|
||||
extern crate rtiow;
|
||||
extern crate stderrlog;
|
||||
extern crate structopt;
|
||||
#[macro_use]
|
||||
#[cfg(feature = "prom")]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
#[cfg(feature = "prom")]
|
||||
extern crate prometheus;
|
||||
|
||||
use std::fs;
|
||||
|
||||
use chrono::DateTime;
|
||||
use chrono::Utc;
|
||||
#[cfg(feature = "profile")]
|
||||
use cpuprofiler::PROFILER;
|
||||
#[cfg(feature = "prom")]
|
||||
use prometheus::Encoder;
|
||||
use structopt::StructOpt;
|
||||
|
||||
use rtiow::renderer::opt_hash;
|
||||
use rtiow::renderer::render;
|
||||
use rtiow::renderer::Opt;
|
||||
|
||||
#[cfg(feature = "prom")]
|
||||
lazy_static! {
|
||||
static ref RUNTIME_COUNTER: prometheus::Gauge =
|
||||
register_gauge!("render_time_seconds", "Wall clock time for render").unwrap();
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "prom"))]
|
||||
fn push_metrics(_push_gateway_addr: &str, _instance: String, start_time: &DateTime<Utc>) {
|
||||
let runtime = (Utc::now() - *start_time).to_std().unwrap();
|
||||
info!(
|
||||
"Render time {}.{} seconds",
|
||||
runtime.as_secs(),
|
||||
runtime.subsec_millis()
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "prom")]
|
||||
fn push_metrics(push_gateway_addr: &str, instance: String, start_time: &DateTime<Utc>) {
|
||||
let runtime = (Utc::now() - *start_time).to_std().unwrap();
|
||||
info!(
|
||||
"Render time {}.{} seconds",
|
||||
runtime.as_secs(),
|
||||
runtime.subsec_millis()
|
||||
);
|
||||
|
||||
RUNTIME_COUNTER.set(runtime.as_secs() as f64 + f64::from(runtime.subsec_nanos()) * 1e-9);
|
||||
|
||||
let metric_families = prometheus::gather();
|
||||
let encoder = prometheus::TextEncoder::new();
|
||||
let stdout = std::io::stdout();
|
||||
println!("Prometheus metrics:");
|
||||
encoder
|
||||
.encode(&metric_families, &mut stdout.lock())
|
||||
.unwrap();
|
||||
|
||||
if push_gateway_addr.is_empty() {
|
||||
info!("Logging stats to push gateway disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if let Err(err) = prometheus::push_metrics(
|
||||
"tracer",
|
||||
labels! {
|
||||
"instance".to_owned() => instance,
|
||||
"start_time".to_owned() => start_time.to_rfc3339(),
|
||||
"timestamp".to_owned() => start_time.timestamp().to_string(),
|
||||
},
|
||||
push_gateway_addr,
|
||||
metric_families,
|
||||
None,
|
||||
// TODO(wathiede): auth?
|
||||
// Some(prometheus::BasicAuthentication {
|
||||
// username: "user".to_owned(),
|
||||
// password: "pass".to_owned(),
|
||||
// }),
|
||||
) {
|
||||
error!("Failed to push to prometheus gateway: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "profile"))]
|
||||
struct MockTimer;
|
||||
|
||||
@@ -120,7 +49,6 @@ fn main() -> Result<(), std::io::Error> {
|
||||
.timestamp(stderrlog::Timestamp::Millisecond)
|
||||
.init()
|
||||
.unwrap();
|
||||
let start_time: DateTime<Utc> = Utc::now();
|
||||
let opt = Opt::from_args();
|
||||
info!("{:?}", opt);
|
||||
let scene = opt.model.scene(&opt);
|
||||
@@ -140,7 +68,6 @@ fn main() -> Result<(), std::io::Error> {
|
||||
info!("Saving pprof to {}", pprof_path.to_string_lossy());
|
||||
PROFILER.lock().unwrap().stop().unwrap();
|
||||
}
|
||||
push_metrics(&opt.push_gateway, opt_hash(&opt), &start_time);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
@@ -31,6 +31,3 @@ extern crate rand;
|
||||
extern crate structopt;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
#[cfg(feature = "prom")]
|
||||
extern crate prometheus;
|
||||
|
||||
@@ -14,8 +14,6 @@ use std::thread;
|
||||
use std::time;
|
||||
|
||||
use core_affinity;
|
||||
#[cfg(feature = "prom")]
|
||||
use lazy_static::lazy_static;
|
||||
use num_cpus;
|
||||
use rand;
|
||||
use rand::Rng;
|
||||
@@ -32,25 +30,6 @@ use crate::texture::ConstantTexture;
|
||||
use crate::texture::EnvMap;
|
||||
use crate::vec3::Vec3;
|
||||
|
||||
#[cfg(feature = "prom")]
|
||||
lazy_static! {
|
||||
static ref RAY_COUNTER: prometheus::CounterVec =
|
||||
register_counter_vec!("rays", "Number of rays fired", &["level"]).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "prom"))]
|
||||
struct MockPrometheus;
|
||||
#[cfg(not(feature = "prom"))]
|
||||
impl MockPrometheus {
|
||||
fn with_label_values(&self, _: &[&str]) -> &MockPrometheus {
|
||||
self
|
||||
}
|
||||
fn inc(&self) {}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "prom"))]
|
||||
static RAY_COUNTER: MockPrometheus = MockPrometheus {};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Model {
|
||||
Bench,
|
||||
@@ -130,13 +109,6 @@ impl std::string::ToString for Model {
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "tracer", about = "An experimental ray tracer.")]
|
||||
pub struct Opt {
|
||||
/// Prometheus push gateway address, use "" to disable
|
||||
#[structopt(
|
||||
short = "a",
|
||||
long = "pushgateway",
|
||||
default_value = "pushgateway.z.xinu.tv:80"
|
||||
)]
|
||||
pub push_gateway: String,
|
||||
/// Image width
|
||||
#[structopt(short = "w", long = "width", default_value = "512")]
|
||||
pub width: usize,
|
||||
@@ -239,7 +211,6 @@ fn color(
|
||||
global_illumination: bool,
|
||||
env_map: &Option<EnvMap>,
|
||||
) -> (Vec3, usize) {
|
||||
RAY_COUNTER.with_label_values(&[&depth.to_string()]).inc();
|
||||
if let Some(rec) = world.hit(r, 0.001, std::f32::MAX) {
|
||||
let (u, v) = rec.uv;
|
||||
let emitted = rec.material.emitted(u, v, rec.p);
|
||||
|
||||
Reference in New Issue
Block a user