Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Refactor rebase master prometheus_v0.3
  • Loading branch information
nodebreaker0-0 committed Dec 27, 2019
commit dea83cf5893f56d03e03404c7a6e20e511b54fad
696 changes: 450 additions & 246 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ members = [
"client/service",
"client/service/test",
"client/state-db",
"client/prometheus",
"client/telemetry",
"client/transaction-pool",
"client/transaction-pool/graph",
Expand Down
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sp-state-machine = { version = "2.0.0", path = "../primitives/state-machine" }
sc-telemetry = { version = "2.0.0", path = "telemetry" }
sp-trie = { version = "2.0.0", path = "../primitives/trie" }
tracing = "0.1.10"
sc-prometheus = { path = "prometheus" }

[dev-dependencies]
env_logger = "0.7.0"
Expand Down
1 change: 1 addition & 0 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sp-core = { version = "2.0.0", path = "../../primitives/core" }
sc-service = { version = "2.0.0", default-features = false, path = "../service" }
sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" }
sc-telemetry = { version = "2.0.0", path = "../telemetry" }
sc-prometheus = { path = "../prometheus" }
sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" }
names = "0.11.0"
structopt = "0.3.3"
Expand Down
7 changes: 5 additions & 2 deletions client/cli/src/informant/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use sc_network::SyncState;
use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Zero, Saturating};
use sc_service::NetworkStatus;
use std::{convert::{TryFrom, TryInto}, fmt, time};

use sc_prometheus::prometheus_gauge;
/// State of the informant display system.
///
/// This is the system that handles the line that gets regularly printed and that looks something
Expand Down Expand Up @@ -63,7 +63,10 @@ impl<B: BlockT> InformantDisplay<B> {
let (status, target) = match (net_status.sync_state, net_status.best_seen_block) {
(SyncState::Idle, _) => ("Idle".into(), "".into()),
(SyncState::Downloading, None) => (format!("Syncing{}", speed), "".into()),
(SyncState::Downloading, Some(n)) => (format!("Syncing{}", speed), format!(", target=#{}", n)),
(SyncState::Downloading, Some(n)) => {
prometheus_gauge!(TARGET_NUM => n.saturated_into().try_into().unwrap());
(format!("Syncing{}", speed), format!(", target=#{}", n))
}
};

info!(
Expand Down
8 changes: 7 additions & 1 deletion client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,13 @@ where

config.tracing_targets = cli.tracing_targets.into();
config.tracing_receiver = cli.tracing_receiver.into();


match cli.prometheus_endpoint {
None => {config.prometheus_endpoint = None;},
Some(x) => {
config.prometheus_endpoint = Some(parse_address(&format!("{}:{}", x, 33333), cli.prometheus_port)?);
}
}
// Imply forced authoring on --dev
config.force_authoring = cli.shared_params.dev || cli.force_authoring;

Expand Down
6 changes: 6 additions & 0 deletions client/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ pub struct RunCmd {
/// Use `--unsafe-ws-external` to suppress the warning if you understand the risks.
#[structopt(long = "ws-external")]
pub ws_external: bool,
/// Prometheus exporter TCP port.
#[structopt(long = "prometheus-port", value_name = "PORT")]
pub prometheus_port: Option<u16>,
/// Prometheus exporter IP addr.
#[structopt(long = "prometheus-addr", value_name = "Local IP address")]
pub prometheus_endpoint: Option<String>,

/// Listen to all Websocket interfaces.
///
Expand Down
16 changes: 16 additions & 0 deletions client/prometheus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "sc-prometheus"
version = "2.0.0"
authors = ["Parity Technologies <[email protected]>"]
description = "prometheus utils"
edition = "2018"

[dependencies]
hyper = "0.12"
lazy_static = "1.0"
log = "0.4"
prometheus = { version = "0.7", features = ["nightly", "process"]}
tokio = "0.1"

[dev-dependencies]
reqwest = "0.9"
Loading