Skip to content

Commit

Permalink
update eosmechanics & accounts with latest prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 9, 2023
1 parent f7fba6f commit bfc4e8d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 70 deletions.
2 changes: 1 addition & 1 deletion accounts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accounts"
version = "0.2.0"
version = "0.3.1"
authors = ["Yaro <yaro@pinax.network>", "Denis <denis@pinax.network>"]
description = "Antelope newly created accounts"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion accounts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ run:

.PHONY: gui
gui:
substreams gui -e eos.firehose.eosnation.io:9001 map_accounts -s 1000000 -t +10000
substreams gui -e eos.firehose.eosnation.io:9001 prom_out -s 1000000 -t +10000

.PHONY: sink
sink:
Expand Down
9 changes: 5 additions & 4 deletions accounts/src/sinks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use substreams::{log, proto};
use substreams_sink_kv::pb::kv::KvOperations;
use substreams::errors::Error;
use substreams_sink_prometheus::PrometheusOperations;
use substreams_sink_prometheus::{PrometheusOperations, Gauge};

use crate::accounts::Accounts;

Expand All @@ -22,10 +22,11 @@ pub fn kv_out( accounts: Accounts) -> Result<KvOperations, Error> {
pub fn prom_out(accounts: Accounts) -> Result<PrometheusOperations, Error> {

let mut prom_out = PrometheusOperations::default();
let total = accounts.accounts.len() as f64;

if accounts.accounts.len() > 0 {
log::info!("New accounts: {}", accounts.accounts.len());
prom_out.push_add("accounts_counter", accounts.accounts.len() as f64, vec![]);
if total > 0.0 {
log::info!("New accounts: {}", total);
prom_out.push(Gauge::new("accounts_counter").add(total));
}

Ok(prom_out)
Expand Down
4 changes: 2 additions & 2 deletions accounts/substreams.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
specVersion: v0.1.0
package:
name: "accounts"
version: v0.2.0
version: v0.3.1
url: https://github.com/pinax-network/substreams
doc: Antelope newly created accounts

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.2/substreams-sink-prometheus-v0.1.2.spkg
prom: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.3/substreams-sink-prometheus-v0.1.3.spkg

protobuf:
files:
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.0"
version = "0.3.1"
authors = ["Denis <denis@pinax.network>", "Fred <fred@pinax.network>", "Charles <charles@pinax.network>"]
description = "Block Producer Benchmarks"
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions eosmechanics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ info:

.PHONY: run
run:
substreams run -e eos.firehose.eosnation.io:9001 map_producer_usage -s 292442484 -t +100000 -o jsonl
substreams run -e eos.firehose.eosnation.io:9001 prom_out -s 292442484 -t +100000 -o jsonl

.PHONY: gui
gui:
substreams gui -e eos.firehose.eosnation.io:9001 map_producer_usage -s 292103130 -t +100000
substreams gui -e eos.firehose.eosnation.io:9001 prom_out -s 292103130 -t +100000

.PHONY: sink
sink:
Expand Down
50 changes: 0 additions & 50 deletions eosmechanics/proto/v1/prometheus.proto

This file was deleted.

10 changes: 6 additions & 4 deletions eosmechanics/src/sinks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use substreams::errors::Error;
use substreams::log;
use substreams_sink_prometheus::PrometheusOperations;
use substreams_sink_prometheus::{PrometheusOperations, Counter, Gauge};

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

Expand All @@ -16,15 +16,17 @@ pub fn prom_out(
// SET producer CPU usage
if !producer.is_empty() {
log::info!("SET producer_usage={:?}", producer_usage);
prom_out.push_set("producer_usage", producer_usage.cpu_usage as f64, vec![producer.as_str()]);
let mut gauge = Gauge::new("producer_usage");
gauge.set_label(producer.as_str());
prom_out.push(gauge.set(producer_usage.cpu_usage as f64));

// INC action count
prom_out.push_inc("action_count", vec![]);
prom_out.push(Counter::new("action_count").inc());
}

// SET schedule version
if !schedule_change.pending_schedule.is_empty() {
prom_out.push_set("schedule_version", schedule_change.schedule_version as f64, vec![]);
prom_out.push(Gauge::new("schedule_version").set(schedule_change.schedule_version as f64));
}

// RESET remove producer
Expand Down
8 changes: 4 additions & 4 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.0
version: v0.3.1
url: https://github.com/pinax-network/substreams
doc: Block Producer Benchmarks

# import:
# prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.1/substreams-sink-prometheus-v0.1.1.spkg
imports:
prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.3/substreams-sink-prometheus-v0.1.3.spkg

binaries:
default:
Expand All @@ -16,7 +16,7 @@ binaries:
protobuf:
files:
- eosmechanics.proto
- prometheus.proto

importPaths:
- proto/v1

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

[dependencies]
substreams = "0.5.2"
substreams = { workspace = true }

0 comments on commit bfc4e8d

Please sign in to comment.