Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion graph-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2018"
[dependencies]
actix = "^0.8.3"
actix-web = "^1.0.2"
chrono = "^0.4.7"
cincinnati = { path = "../cincinnati" }
commons = { path = "../commons" }
dkregistry = { git = "https://github.com/camallo/dkregistry-rs.git", rev = "eb6349f2b99cd3dbd681d18d692a8c69e2e7b339" }

env_logger = "^0.6.0"
failure = "^0.1.1"
flate2 = "^1.0.1"
Expand Down
35 changes: 23 additions & 12 deletions graph-builder/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ lazy_static! {
"Number of releases in the final graph, after processing"
)
.unwrap();
static ref GRAPH_LAST_SUCCESSFUL_REFRESH: IntGauge = IntGauge::new(
Comment thread
steveej marked this conversation as resolved.
Outdated
"graph_last_successful_refresh_timestamp",
Comment thread
steveej marked this conversation as resolved.
Outdated
"UTC timestamp of last successful graph refresh"
)
.unwrap();
static ref GRAPH_UPSTREAM_RAW_RELEASES: IntGauge = IntGauge::new(
"graph_upstream_raw_releases",
"Number of releases fetched from upstream, before processing"
Expand All @@ -57,6 +62,7 @@ lazy_static! {
pub fn register_metrics(registry: &prometheus::Registry) -> Fallible<()> {
commons::register_metrics(&registry)?;
registry.register(Box::new(GRAPH_FINAL_RELEASES.clone()))?;
registry.register(Box::new(GRAPH_LAST_SUCCESSFUL_REFRESH.clone()))?;
registry.register(Box::new(GRAPH_UPSTREAM_RAW_RELEASES.clone()))?;
registry.register(Box::new(UPSTREAM_ERRORS.clone()))?;
registry.register(Box::new(UPSTREAM_SCRAPES.clone()))?;
Expand Down Expand Up @@ -249,21 +255,26 @@ pub fn run<'a>(settings: &'a config::AppSettings, state: &State) -> ! {
}
};

match serde_json::to_string(&graph) {
Ok(json) => {
*state.json.write() = json;
let json_graph = match serde_json::to_string(&graph) {
Ok(json) => json,
Err(err) => {
error!("Failed to serialize graph: {}", err);
continue;
}
};

if first_success {
*state.ready.write() = true;
first_success = false;
};
*state.json.write() = json_graph;

let nodes_count = graph.releases_count();
GRAPH_FINAL_RELEASES.set(nodes_count as i64);
debug!("graph update completed, {} valid releases", nodes_count);
}
Err(err) => error!("Failed to serialize graph: {}", err),
if first_success {
*state.ready.write() = true;
first_success = false;
};

GRAPH_LAST_SUCCESSFUL_REFRESH.set(chrono::Utc::now().timestamp() as i64);

let nodes_count = graph.releases_count();
Comment thread
steveej marked this conversation as resolved.
Outdated
GRAPH_FINAL_RELEASES.set(nodes_count as i64);
debug!("graph update completed, {} valid releases", nodes_count);
}
}

Expand Down