Skip to content

Commit

Permalink
add histogram & summary to eosmechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 16, 2023
1 parent 7a93f39 commit f8ad331
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ substreams = "0.5.2"
substreams-antelope = "0.1.1"
substreams-ethereum = "0.9"
substreams-sink-kv = "0.1"
substreams-sink-prometheus = "0.1.8"
substreams-sink-prometheus = "0.1.9"
substreams-database-change = "1.0.0"
substreams-entity-change = "1.0.0"
antelope = "0.0.11"
Expand Down
2 changes: 1 addition & 1 deletion eosmechanics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eosmechanics"
version = "0.3.4"
version = "0.3.5"
authors = ["Denis <[email protected]>", "Fred <[email protected]>", "Charles <[email protected]>"]
description = "Block Producer Benchmarks"
license = "MIT OR Apache-2.0"
Expand Down
8 changes: 4 additions & 4 deletions eosmechanics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ graph TD;

```yaml
Package name: eosmechanics
Version: v0.3.4
Version: v0.3.5
Doc: Block Producer Benchmarks
Modules:
----
Name: map_producer_usage
Initial block: 0
Kind: map
Output Type: proto:eosmechanics.v1.ProducerUsage
Hash: daaafefb647b0238139a48f2e54c1ef423b42406
Hash: 79d347ce956757310bebc0cde1bed9606edab871

Name: map_schedule_change
Initial block: 0
Kind: map
Output Type: proto:eosmechanics.v1.ScheduleChange
Hash: b9deac907bccc0f249dddd00614109e7b8fc834b
Hash: bd732c1b9c0755ebb848c9adac8dd7ebb030e3c5

Name: prom_out
Initial block: 0
Kind: map
Output Type: proto:pinax.substreams.sink.prometheus.v1.PrometheusOperations
Hash: fe1c9145a7a314dc668e94896ef148d0dd434945
Hash: 086515ddb61488e7feeb2763dc20e0868eeac32b
```
12 changes: 10 additions & 2 deletions eosmechanics/src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use substreams::errors::Error;
use substreams::log;
use substreams_sink_prometheus::{PrometheusOperations, Counter, Gauge};
use substreams_sink_prometheus::{PrometheusOperations, Counter, Gauge, Histogram, Summary};

use crate::eosmechanics::{ProducerUsage, ScheduleChange};

Expand All @@ -18,17 +18,25 @@ pub fn prom_out(

// SET producer CPU usage
if !producer.is_empty() {
log::info!("SET producer_usage={:?}", producer_usage);
log::info!("producer_usage={:?}", producer_usage);
let mut gauge = Gauge::from("producer_usage").with(labels.clone());
prom_out.push(gauge.set(producer_usage.cpu_usage as f64));

// Histogram & Summary
let mut histogram = Histogram::from("histogram_producer_usage");
prom_out.push(histogram.observe(producer_usage.cpu_usage as f64));

let mut summary = Summary::from("summary_producer_usage");
prom_out.push(summary.observe(producer_usage.cpu_usage as f64));

// INC action count
prom_out.push(Counter::from("cpu_actions_total").inc());
prom_out.push(Counter::from("cpu_actions").with(labels.clone()).inc());
}

// SET schedule version
if !schedule_change.pending_schedule.is_empty() {
log::info!("schedule_change={:?}", schedule_change);
prom_out.push(Counter::from("schedule_changes").inc());
prom_out.push(Gauge::from("schedule_version").set(schedule_change.schedule_version as f64));
}
Expand Down
4 changes: 2 additions & 2 deletions eosmechanics/substreams.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
specVersion: v0.1.0
package:
name: eosmechanics
version: v0.3.4
version: v0.3.5
url: https://github.com/pinax-network/substreams
doc: Block Producer Benchmarks

imports:
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.8/substreams-sink-prometheus-v0.1.8.spkg
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.9/substreams-sink-prometheus-v0.1.9.spkg

binaries:
default:
Expand Down
3 changes: 2 additions & 1 deletion params/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
substreams = { workspace = true }
# substreams = { workspace = true }
substreams = { path = "/Users/denis/Github/substreams-rs/substreams"}

0 comments on commit f8ad331

Please sign in to comment.