Skip to content

Commit

Permalink
implement REMOVE to eosmechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 14, 2023
1 parent 976080a commit 6553e63
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 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.7"
substreams-sink-prometheus = "0.1.8"
substreams-database-change = "1.0.0"
substreams-entity-change = "1.0.0"
antelope = "0.0.11"
Expand Down
2 changes: 1 addition & 1 deletion accounts/substreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package:

imports:
kv: https://github.com/streamingfast/substreams-sink-kv/releases/download/v0.1.2/substreams-sink-kv-v0.1.2.spkg
prom: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.5/substreams-sink-prometheus-v0.1.5.spkg
prom: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.8/substreams-sink-prometheus-v0.1.8.spkg

protobuf:
files:
Expand Down
2 changes: 1 addition & 1 deletion atomicmarket/substreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package:
doc: Metrics for AtomicHub Market

imports:
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.5/substreams-sink-prometheus-v0.1.5.spkg
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.8/substreams-sink-prometheus-v0.1.8.spkg
antelope: https://github.com/pinax-network/firehose-antelope/releases/download/v0.0.5/antelope-v0.0.5.spkg

binaries:
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.2"
version = "0.3.4"
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.3
Version: v0.3.4
Doc: Block Producer Benchmarks
Modules:
----
Name: map_producer_usage
Initial block: 0
Kind: map
Output Type: proto:eosmechanics.v1.ProducerUsage
Hash: 4c74215a363f0f40413132a61464bb7a7ebe4e39
Hash: daaafefb647b0238139a48f2e54c1ef423b42406

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

Name: prom_out
Initial block: 0
Kind: map
Output Type: proto:pinax.substreams.sink.prometheus.v1.PrometheusOperations
Hash: b08bc360f9ebceeee0ddc58e7d428c2d88d41aff
Hash: fe1c9145a7a314dc668e94896ef148d0dd434945
```
10 changes: 6 additions & 4 deletions eosmechanics/src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ pub fn prom_out(

let mut prom_out = PrometheusOperations::default();
let producer = producer_usage.producer.clone();
let labels = HashMap::from([("producer".to_string(), producer.clone())]);

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

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

// SET schedule version
if !schedule_change.pending_schedule.is_empty() {
prom_out.push(Counter::from("schedule_changes").inc());
prom_out.push(Gauge::from("schedule_version").set(schedule_change.schedule_version as f64));
}

Expand All @@ -36,7 +38,7 @@ pub fn prom_out(
// must be declared after SET or else producer could stay in schedule indefinitely
for remove_producer in schedule_change.remove_from_schedule {
log::info!("RESET remove_producer={}", remove_producer);
// prom_out.push_reset("producer_usage", vec!["remove_producer"]) ;
prom_out.push(Gauge::from("producer_usage").remove(labels.clone()));
}

Ok(prom_out)
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.3
version: v0.3.4
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.5/substreams-sink-prometheus-v0.1.5.spkg
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.8/substreams-sink-prometheus-v0.1.8.spkg

binaries:
default:
Expand Down

0 comments on commit 6553e63

Please sign in to comment.