-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: bandwidth metering metrics #844
Conversation
Assumes the API introduced in #785 |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #844 +/- ##
==========================================
- Coverage 74.91% 74.87% -0.05%
==========================================
Files 313 313
Lines 34108 34139 +31
==========================================
+ Hits 25551 25560 +9
- Misses 8557 8579 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Going to mark as blocked for now by #892 |
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.
What do we need to get this over the line?
As discussed we only want to be counting Ingress/Egress, and not KB/s or MB/s. |
Ack, that's effectively what this does, will rename to make it clearer. |
For viz: after discussing w/ @onbjerg, I realized I was overloading the term "metric." We don't want to expose bytes/s as an external metric (e.g. in Prometheus) but it will be helpful to have it in-process, picking up on that in #992 |
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.
lgtm
Wdyt @onbjerg ?
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.
See my comment on the trait. Another question I have is what the difference is between NetworkIOMeter
and MeteredStream
? Could MeteredStream
not tally this up itself, i.e. is it not possible to merge NetworkIOMeter
and MeteredStream
? If so, is there a reason not to?
There is a slight difference - one |
I would prob rename |
I'm being a bit pedantic, but I'm wary of calling it You're right though that it's not just for network streams, perhaps I'll call it |
…e counts for peer sessions
@onbjerg does this line up w how you wanted discovery ingress/egress monitored? |
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 we need to be precise about what we actually want to
- measure
- expose via
metric
counter/gauge
Because right now I'm a little lost and not sure about either. But I'm strongly against instrumenting a TCP stream with metrics
because this is likely more expensive that just incrementing an Atomic via relaxed for statistical purposes, like we're doing on main
is "total bytes read/written by all sessions combined" even useful?
what do we want/need from a single session in order to rate the quality of the session?
/// The [`MeteredStreamCounts`] structs this can increment ingress / egress counts for, | ||
/// with optional metrics associated with each. | ||
meters: HashMap<&'a str, (MeteredStreamCounts, Option<MeteredStreamMetrics>)>, |
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.
what are we using this for?
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.
E.g. here
// Attach meter for total across all sessions
metered_stream.add_meter(SESSIONS_METER_NAME, metered_stream_counts);
// Attach meter for this session
metered_stream.add_meter("session", MeteredStreamCounts::default());
we meter ingress/egress both on the meter shared by all sessions, and on a meter just for the current session
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 see, so this is basically just
struct MeteredStream {
inner,
total: MeteredStreamCounts,
session: MeteredStreamCounts
}
?
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.
yup, i admittedly jumped the gun on flexibility so it can be any number of MeteredStreamCounts
} | ||
} | ||
|
||
impl MeteredStream<'_, UdpSocket> { |
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.
hmm it is a bit odd that we implement something called Stream for a UdpSocket
since it only sends individual packets, perhaps counting bytes read/written is not really ideal
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.
If we just want to count whole packets, we could make an extension to the MeteredSender
, i.e. make it work over any Sink
& have a similar MeteredReceiver
that works over any Stream
, and use a UdpFramed
here to have a type that impls Sink + Stream
.
Or, of course, we could make a new type here that simply counts whole packets, but FWIW the MeteredSender
isn't used anywhere yet
Yeah, we're not exposing metrics over the TCP streams in the peer sessions, just counting up via
Honestly, as something that we'd want to reference in code, I don't think so. But now the
As I'm thinking through #908, I really think it's a matter of throughput and latency. Latency is out of scope here, but for throughput we need a rate. The new approach I'm working on for #1002 actually does read the per-stream ingress/egress byte values to calculate this rate, for use in dropping peers |
Closing for now as we couldn't figure out a great way to integrate this at the time - think we'll revisit metrics in the coming weeks and we'll cherry-pick parts of this and the other PR then! |
Resolves #783, introduces a type that exposes metrics from an underlying
BandwidthMeter