Upload bench output as build artifacts (#1478)

* Upload bench output as build artifacts

* Fix tags types

* Pull previous stats from metrics

* Change the default branch for comparison

* Fix formatting

* Fix build errors

* Address review comments

* Dedup some common code

* Add eval for channel info to find branch name
This commit is contained in:
Pankaj Garg
2018-10-12 15:13:10 -07:00
committed by GitHub
parent 1515bba9c6
commit e5ab9a856c
3 changed files with 120 additions and 19 deletions

View File

@@ -1,5 +1,7 @@
//! The `metrics` module enables sending measurements to an InfluxDB instance
extern crate reqwest;
use influx_db_client as influxdb;
use std::env;
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
@@ -37,11 +39,7 @@ impl InfluxDbMetricsWriter {
}
fn build_client() -> Option<influxdb::Client> {
let host = env::var("INFLUX_HOST")
.unwrap_or_else(|_| "https://metrics.solana.com:8086".to_string());
let db = env::var("INFLUX_DATABASE").unwrap_or_else(|_| "scratch".to_string());
let username = env::var("INFLUX_USERNAME").unwrap_or_else(|_| "scratch_writer".to_string());
let password = env::var("INFLUX_PASSWORD").unwrap_or_else(|_| "topsecret".to_string());
let (host, db, username, password) = get_env_settings();
debug!("InfluxDB host={} db={} username={}", host, db, username);
let mut client = influxdb::Client::new_with_option(host, db, None)
@@ -177,6 +175,27 @@ pub fn submit(point: influxdb::Point) {
agent.submit(point);
}
fn get_env_settings() -> (String, String, String, String) {
let host =
env::var("INFLUX_HOST").unwrap_or_else(|_| "https://metrics.solana.com:8086".to_string());
let db = env::var("INFLUX_DATABASE").unwrap_or_else(|_| "scratch".to_string());
let username = env::var("INFLUX_USERNAME").unwrap_or_else(|_| "scratch_writer".to_string());
let password = env::var("INFLUX_PASSWORD").unwrap_or_else(|_| "topsecret".to_string());
(host, db, username, password)
}
pub fn query(q: &str) -> Result<String, String> {
let (host, _, username, password) = get_env_settings();
let query = format!("{}/query?u={}&p={}&q={}", &host, &username, &password, &q);
let response = reqwest::get(query.as_str())
.map_err(|err| err.to_string())?
.text()
.map_err(|err| err.to_string())?;
Result::Ok(response)
}
/// Blocks until all pending points from previous calls to `submit` have been
/// transmitted.
pub fn flush() {