New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl: libp2p metrics #705
impl: libp2p metrics #705
Conversation
|
||
tokio::spawn(async move { | ||
let server = Server::bind(&addr).serve(MakeMetricService::new(registry)); | ||
info!("Metrics server on http://{}/metrics", server.local_addr()); |
Check warning
Code scanning / devskim
An HTTP-based URL without TLS was detected. Warning
const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;version=1.0.0"; | ||
|
||
pub(crate) fn metrics_server(registry: Registry) { | ||
// Serve on localhost. |
Check notice
Code scanning / devskim
Accessing localhost could indicate debug code, or could hinder scaling. Note
sn_networking/src/driver.rs
Outdated
}); | ||
} | ||
NodeRecordStoreConfig { | ||
max_value_bytes: MAX_PACKET_SIZE, // TODO, does this need to be _less_ than MAX_PACKET_SIZE |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
sn_networking/src/driver.rs
Outdated
|
||
/// What is the largest packet to send over the network. | ||
/// Records larger than this will be rejected. | ||
// TODO: revisit once utxo is in |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
fab265e
to
757c0ce
Compare
Reviewpad Report
|
757c0ce
to
d772972
Compare
d772972
to
786dda3
Compare
fn respond_with_404_not_found(&mut self) -> Response<String> { | ||
let mut resp = Response::default(); | ||
*resp.status_mut() = StatusCode::NOT_FOUND; | ||
*resp.body_mut() = "Not found try localhost:[port]/metrics".to_string(); |
Check notice
Code scanning / devskim
Accessing localhost could indicate debug code, or could hinder scaling. Note
a87b203
to
44e2a85
Compare
44e2a85
to
2e02237
Compare
4a3dacb
to
9079f6d
Compare
d80cf29
to
9207811
Compare
How do we access these metrics? Do we need tostart a custom server for this? does each node run a server to access metrics? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think metrics
here confuses with out logging metrics output. I'd say we want a clearer name for this feature.
libp2p-metrics
, network-metrics
? something-else
?
I'm also torn on this being on by default atm... |
Yes, each node runs a separate hyper server on a random port. This returns the Also, I will push a change to update the feature name and remove it from the default features list. |
9207811
to
d84c4f1
Compare
- this is enabled by default for a node though
6d30e10
to
06471da
Compare
Depends on #706
Description
Summary generated by Reviewpad on 04 Sep 23 14:47 UTC
This pull request includes changes to multiple files. Here is an overview of the changes:
SwarmDriver
insn_networking
crate:The implementation of the
SwarmDriver
struct and its associated methods have been modified. Changes include:driver::SwarmDriver
trait.libp2p_metrics::Recorder
trait.NodeBehaviour
struct.NodeEvent
enum to include additional events.SwarmDriver
struct to include anetwork_metrics
field of typeRecorder
.handle_msg
method to handle request/response messages using therequest_response
crate.handle_kad_event
method to handle Kademlia events.Addition of
metrics_service.rs
:A new file called
metrics_service.rs
has been added. This file implements a metrics service for the SAFE Network Software. It defines aMetricService
struct and aMakeMetricService
struct. TheMetricService
struct implements theService
trait from thehyper
crate and provides functions for handling HTTP requests. TheMakeMetricService
struct is responsible for creating instances of theMetricService
struct. The file also contains ametrics_server
function that runs the metrics service onlocalhost
.Changes to
Cargo.toml
:The
Cargo.toml
file has been modified to include new dependencies and update existing ones. Changes include:libp2p-metrics
with version0.13.1
and featuresidentify
andkad
.prometheus-client
with version0.21.2
.hyper
to version0.14
and adding featuresserver
,tcp
, andhttp1
.cmd.rs
:The
cmd.rs
file has been modified to include changes related to imports and function removal. Changes include:use crate::driver::SwarmDriver
.use libp2p::swarm::dial_opts::DialOpts
.dial
anddial_with_opts
.rand::Rng
module, removing the definitions of specific constants, adjusting the implementation of theDefault
trait for a struct, removing unused imports, and removing some comments.sn_networking/src/msg/mod.rs
has been deleted.Please review these changes to ensure they are correct and meet the requirements of the codebase. Let me know if you need any further clarification!