Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
no-std or warm compatibility issues, grapana-data -source code refere…
Browse files Browse the repository at this point in the history
…nce and correction,applicable
  • Loading branch information
nodebreaker0-0 committed Jan 2, 2020
1 parent 472aca1 commit 1974f94
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 157 deletions.
66 changes: 66 additions & 0 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ where
let rpc_interface: &str = interface_str(cli.rpc_external, cli.unsafe_rpc_external, cli.validator)?;
let ws_interface: &str = interface_str(cli.ws_external, cli.unsafe_ws_external, cli.validator)?;
let grafana_interface: &str = if cli.grafana_external { "0.0.0.0" } else { "127.0.0.1" };
let prometheus_interface: &str = if cli.prometheus_external { "0.0.0.0" } else { "127.0.0.1" };

config.rpc_http = Some(parse_address(&format!("{}:{}", rpc_interface, 9933), cli.rpc_port)?);
config.rpc_ws = Some(parse_address(&format!("{}:{}", ws_interface, 9944), cli.ws_port)?);
Expand Down Expand Up @@ -943,12 +944,10 @@ where
config.tracing_receiver = cli.tracing_receiver.into();

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

Expand Down
6 changes: 3 additions & 3 deletions client/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ pub struct RunCmd {
/// 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>,
/// Prometheus exporter on/off external".
#[structopt(long = "prometheus-external")]
pub prometheus_external: bool,

/// Listen to all Websocket interfaces.
///
Expand Down
14 changes: 9 additions & 5 deletions client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,11 +1116,15 @@ ServiceBuilder<
telemetry
});
// prometheus init
match config.prometheus_endpoint {
None => (),
Some(x) => {
let _prometheus = sc_prometheus::init_prometheus(x);
}
if let Some(port) = config.prometheus_port {
let future = select(
sc_prometheus::init_prometheus(port).boxed()
,exit.clone()
).map(|either| match either {
Either::Left((result, _)) => result.map_err(|_| ()),
Either::Right(_) => Ok(())
}).compat();
let _ = to_spawn_tx.unbounded_send(Box::new(future));
}
// Grafana data source
if let Some(port) = config.grafana_port {
Expand Down
6 changes: 3 additions & 3 deletions client/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub struct Configuration<C, G, E = NoExtension> {
pub rpc_cors: Option<Vec<String>>,
/// Grafana data source http port. `None` if disabled.
pub grafana_port: Option<SocketAddr>,
/// Promteheus IP addr. `None` if disabled. and defult port 33333
pub prometheus_endpoint: Option<SocketAddr>,
/// Promteheus Port. `None` if disabled. and defult port 33333
pub prometheus_port: Option<SocketAddr>,
/// Telemetry service URL. `None` if disabled.
pub telemetry_endpoints: Option<TelemetryEndpoints>,
/// External WASM transport for the telemetry. If `Some`, when connection to a telemetry
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<C, G, E> Configuration<C, G, E> where
rpc_ws: None,
rpc_ws_max_connections: None,
rpc_cors: Some(vec![]),
prometheus_endpoint: None,
prometheus_port: None,
grafana_port: None,
telemetry_endpoints: None,
telemetry_external_transport: None,
Expand Down
2 changes: 1 addition & 1 deletion client/service/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn node_config<G, E: Clone> (
rpc_ws: None,
rpc_ws_max_connections: None,
rpc_cors: None,
prometheus_endpoint: None,
prometheus_port: None,
grafana_port: None,
telemetry_endpoints: None,
telemetry_external_transport: None,
Expand Down
14 changes: 8 additions & 6 deletions utils/prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ description = "prometheus utils"
edition = "2018"

[dependencies]
hyper = "0.12"
lazy_static = "1.0"
log = "0.4"
hyper = { version = "0.13.1", default-features = false, features = ["stream"] }
lazy_static = "1.4"
log = "0.4.8"
prometheus = { version = "0.7", features = ["nightly", "process"]}
tokio = "0.1"
tokio = "0.2"
futures-util = { version = "0.3.1", default-features = false, features = ["io"] }
sp-runtime = { package = "sp-runtime",path = "../../primitives/runtime" }
derive_more = "0.99"

[dev-dependencies]
reqwest = "0.9"
[target.'cfg(not(target_os = "unknown"))'.dependencies]
async-std = { version = "1.0.1", features = ["unstable"] }
Loading

0 comments on commit 1974f94

Please sign in to comment.