mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-09 20:21:01 +00:00
Use startup_time from system.connected (#300)
* Handle startup time * Remove dead code * Bump protocol version + FE changes
This commit is contained in:
@@ -290,7 +290,7 @@ impl Handler<Connect> for Aggregator {
|
||||
|
||||
connector.do_send(Connected(fid));
|
||||
|
||||
self.serializer.push(feed::Version(30));
|
||||
self.serializer.push(feed::Version(31));
|
||||
|
||||
// TODO: keep track on number of nodes connected to each chain
|
||||
for (_, entry) in self.chains.iter() {
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ impl Serialize for AddedNode<'_> {
|
||||
tup.serialize_element(node.hardware())?;
|
||||
tup.serialize_element(node.block_details())?;
|
||||
tup.serialize_element(&node.location())?;
|
||||
tup.serialize_element(&node.connected_at())?;
|
||||
tup.serialize_element(&node.startup_time())?;
|
||||
tup.end()
|
||||
}
|
||||
}
|
||||
|
||||
+10
-7
@@ -33,16 +33,19 @@ pub struct Node {
|
||||
location: Option<Arc<NodeLocation>>,
|
||||
/// Flag marking if the node is stale (not syncing or producing blocks)
|
||||
stale: bool,
|
||||
/// Connected at timestamp
|
||||
connected_at: Timestamp,
|
||||
/// Unix timestamp for when node started up (falls back to connection time)
|
||||
startup_time: Option<Timestamp>,
|
||||
/// Network state
|
||||
network_state: Option<Bytes>,
|
||||
}
|
||||
|
||||
impl Node {
|
||||
pub fn new(details: NodeDetails) -> Self {
|
||||
Node {
|
||||
pub fn new(mut details: NodeDetails) -> Self {
|
||||
let startup_time = details.startup_time
|
||||
.take()
|
||||
.and_then(|time| time.parse().ok());
|
||||
|
||||
Node {
|
||||
details,
|
||||
stats: NodeStats::default(),
|
||||
io: NodeIO::default(),
|
||||
@@ -52,7 +55,7 @@ impl Node {
|
||||
hardware: NodeHardware::default(),
|
||||
location: None,
|
||||
stale: false,
|
||||
connected_at: now(),
|
||||
startup_time,
|
||||
network_state: None,
|
||||
}
|
||||
}
|
||||
@@ -230,7 +233,7 @@ impl Node {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connected_at(&self) -> Timestamp {
|
||||
self.connected_at
|
||||
pub fn startup_time(&self) -> Option<Timestamp> {
|
||||
self.startup_time
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,6 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for NodeConnector {
|
||||
|
||||
match serde_json::from_slice(&data) {
|
||||
Ok(msg) => {
|
||||
// info!("New node message: {}", std::str::from_utf8(&data).unwrap_or_else(|_| "INVALID UTF8"));
|
||||
self.handle_message(msg, data, ctx)
|
||||
},
|
||||
#[cfg(debug)]
|
||||
|
||||
@@ -8,18 +8,11 @@ use crate::types::{Block, BlockNumber, BlockHash};
|
||||
#[derive(Deserialize, Debug, Message)]
|
||||
#[rtype(result = "()")]
|
||||
pub struct NodeMessage {
|
||||
pub level: Level,
|
||||
pub ts: DateTime<Utc>,
|
||||
#[serde(flatten)]
|
||||
pub details: Details,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub enum Level {
|
||||
#[serde(rename = "INFO")]
|
||||
Info,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(tag = "msg")]
|
||||
pub enum Details {
|
||||
|
||||
@@ -17,6 +17,7 @@ pub struct NodeDetails {
|
||||
pub version: Box<str>,
|
||||
pub validator: Option<Box<str>>,
|
||||
pub network_id: Option<Box<str>>,
|
||||
pub startup_time: Option<Box<str>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
|
||||
@@ -204,7 +204,7 @@ export class Connection {
|
||||
nodeHardware,
|
||||
blockDetails,
|
||||
location,
|
||||
connectedAt,
|
||||
startupTime,
|
||||
] = message.payload;
|
||||
const pinned = this.pins.has(nodeDetails[0]);
|
||||
const node = new Node(
|
||||
@@ -216,7 +216,7 @@ export class Connection {
|
||||
nodeHardware,
|
||||
blockDetails,
|
||||
location,
|
||||
connectedAt
|
||||
startupTime
|
||||
);
|
||||
|
||||
nodes.add(node);
|
||||
|
||||
@@ -80,7 +80,7 @@ export namespace Variants {
|
||||
NodeHardware,
|
||||
BlockDetails,
|
||||
Maybe<NodeLocation>,
|
||||
Timestamp
|
||||
Maybe<Timestamp>
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ import * as FeedMessage from './feed';
|
||||
export { Types, FeedMessage };
|
||||
|
||||
// Increment this if breaking changes were made to types in `feed.ts`
|
||||
export const VERSION: Types.FeedVersion = 30 as Types.FeedVersion;
|
||||
export const VERSION: Types.FeedVersion = 31 as Types.FeedVersion;
|
||||
|
||||
@@ -9,7 +9,7 @@ export class UptimeColumn extends React.Component<Column.Props, {}> {
|
||||
public static readonly icon = icon;
|
||||
public static readonly width = 58;
|
||||
public static readonly setting = 'uptime';
|
||||
public static readonly sortBy = ({ connectedAt }: Node) => connectedAt || 0;
|
||||
public static readonly sortBy = ({ startupTime }: Node) => startupTime || 0;
|
||||
|
||||
public shouldComponentUpdate(nextProps: Column.Props) {
|
||||
// Uptime only changes when the node does
|
||||
@@ -17,11 +17,15 @@ export class UptimeColumn extends React.Component<Column.Props, {}> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { connectedAt } = this.props.node;
|
||||
const { startupTime } = this.props.node;
|
||||
|
||||
if (!startupTime) {
|
||||
return <td className="Column">-</td>;
|
||||
}
|
||||
|
||||
return (
|
||||
<td className="Column">
|
||||
<Ago when={connectedAt} justTime={true} />
|
||||
<Ago when={startupTime} justTime={true} />
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class Node {
|
||||
public readonly version: Types.NodeVersion;
|
||||
public readonly validator: Maybe<Types.Address>;
|
||||
public readonly networkId: Maybe<Types.NetworkId>;
|
||||
public readonly connectedAt: Types.Timestamp;
|
||||
public readonly startupTime: Maybe<Types.Timestamp>;
|
||||
|
||||
public readonly sortableName: string;
|
||||
public readonly sortableVersion: number;
|
||||
@@ -82,7 +82,7 @@ export class Node {
|
||||
nodeHardware: Types.NodeHardware,
|
||||
blockDetails: Types.BlockDetails,
|
||||
location: Maybe<Types.NodeLocation>,
|
||||
connectedAt: Types.Timestamp
|
||||
startupTime: Maybe<Types.Timestamp>
|
||||
) {
|
||||
const [name, implementation, version, validator, networkId] = nodeDetails;
|
||||
|
||||
@@ -94,7 +94,7 @@ export class Node {
|
||||
this.version = version;
|
||||
this.validator = validator;
|
||||
this.networkId = networkId;
|
||||
this.connectedAt = connectedAt;
|
||||
this.startupTime = startupTime;
|
||||
|
||||
const [major = 0, minor = 0, patch = 0] = (version || '0.0.0')
|
||||
.split('.')
|
||||
|
||||
Reference in New Issue
Block a user