Skip to content
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

Add simple telemetry feed #284

Merged
merged 24 commits into from
Apr 11, 2023
Merged

Add simple telemetry feed #284

merged 24 commits into from
Apr 11, 2023

Conversation

AndreiEres
Copy link
Collaborator

Related to #283
Adds a subscription to telemetry feed. Could be used as a scaffolding for further work.

src/core/telemetry_feed.rs Outdated Show resolved Hide resolved
src/core/telemetry_feed.rs Outdated Show resolved Hide resolved
@AndreiEres
Copy link
Collaborator Author

Here are all messages defined there https://github.com/paritytech/substrate-telemetry/blob/b25f3fbf2270c009aafebefa10bdcc034b8d1cc0/backend/telemetry_core/src/feed_message.rs#L105-L125

Then we can check which telemetry events are not being processed and add additional support.

@AndreiEres AndreiEres force-pushed the AndreiEres/telemetry-feed branch from bbeb431 to 45ec085 Compare March 27, 2023 18:29
pub fn from_bytes(bytes: &[u8]) -> color_eyre::Result<Vec<TelemetryFeed>> {
let v: Vec<&RawValue> = serde_json::from_slice(bytes)?;

let mut feed_messages = vec![];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we might probably set a size hint here for feed_messages vector.

async fn on_shutdown(shutdown_tx: Sender<()>) {
signal::ctrl_c().await.unwrap();
let _ = shutdown_tx.send(());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


async fn watch(mut update: Receiver<TelemetryEvent>) {
loop {
match update.try_recv() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider it as a bad pattern: instead of polling the channel with update.recv we are querying it manually with added timer. It introduces additional latency, extra timer, and gives nothing compared to the simple recv.await call. I would also suggest to use priority-channel instead of mpsc::channel to unify the code.

@AndreiEres AndreiEres force-pushed the AndreiEres/telemetry-feed branch from 45ec085 to 596dd33 Compare March 28, 2023 12:01
}

for message in feed.unwrap() {
info!("[telemetry] {:?}", message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will spam a lot should be debug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true

Self { consumers }
}

// Sets up per websocket tasks to handle updates and reconnects on errors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems to not reflect what the function does. This is actually the task.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

pub url: String,
// Chain's genesis hash
#[clap(name = "chain", long)]
pub chain_hash: H256,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Telemetry in the beginning sends events only about added chains. We need to subscribe to one of them to start getting its events.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this looks like usability trouble. In practice do we have multiple chains on the same backend ?


#[derive(Clone, Debug, Parser)]
#[clap(rename_all = "kebab-case")]
pub(crate) struct TelemetryOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is actually a very simple CLI telemetry frontend. I'd add at least some filter by node id, otherwise the output would be too much for a large net.

@AndreiEres AndreiEres requested a review from sandreim March 31, 2023 10:55
let mut node_id: Option<FeedNodeId> = None;

loop {
match update.try_recv() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do update.recv().await and block until a message arrives or an error happens.

@AndreiEres AndreiEres force-pushed the AndreiEres/telemetry-feed branch from 85479b7 to 1788771 Compare April 11, 2023 08:57
@AndreiEres AndreiEres merged commit 251a3a7 into master Apr 11, 2023
@AndreiEres AndreiEres deleted the AndreiEres/telemetry-feed branch April 11, 2023 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants