Better RPC prometheus metrics. (#9358)

* Better RPC prometehus metrics.

* Add session metrics.

* Add counting requests as well.

* Fix type for web build.

* Fix browser-node

* Filter out unknown method names.

* Change Gauge to Counters

* Use micros instead of millis.

* cargo fmt

* Update client/rpc-servers/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* move log to separate lines.

* Fix compilation.

* cargo +nightly fmt --all

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Tomasz Drwięga
2021-08-24 12:48:23 +02:00
committed by GitHub
parent 3abe7cc4d0
commit d722c44248
4 changed files with 275 additions and 39 deletions
+5 -2
View File
@@ -639,12 +639,15 @@ where
)
};
let rpc_metrics = sc_rpc_server::RpcMetrics::new(config.prometheus_registry())?;
let rpc = start_rpc_servers(&config, gen_handler, rpc_metrics.clone())?;
let server_metrics = sc_rpc_server::ServerMetrics::new(config.prometheus_registry())?;
let rpc = start_rpc_servers(&config, gen_handler, rpc_metrics.clone(), server_metrics)?;
// This is used internally, so don't restrict access to unsafe RPC
let known_rpc_method_names =
sc_rpc_server::method_names(|m| gen_handler(sc_rpc::DenyUnsafe::No, m))?;
let rpc_handlers = RpcHandlers(Arc::new(
gen_handler(
sc_rpc::DenyUnsafe::No,
sc_rpc_server::RpcMiddleware::new(rpc_metrics, "inbrowser"),
sc_rpc_server::RpcMiddleware::new(rpc_metrics, known_rpc_method_names, "inbrowser"),
)?
.into(),
));