-
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
add missing Prometheus exports (#2620, #2619): paths_bytes_sent, srt_conns, srt_conns_bytes_received, srt_conns_bytes_sent #2629
Conversation
5ad2d59
to
dc0f0f3
Compare
Codecov Report
@@ Coverage Diff @@
## main #2629 +/- ##
==========================================
+ Coverage 59.31% 59.49% +0.17%
==========================================
Files 144 144
Lines 15238 15267 +29
==========================================
+ Hits 9039 9083 +44
+ Misses 5559 5545 -14
+ Partials 640 639 -1
... and 4 files with indirect coverage changes 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
I've now also ensured that the commits were squashed and that your tests were successful again, too. |
3c854da
to
6bf70df
Compare
Hello, this is a really useful feature and will surely get merged. mediamtx/internal/stream/stream_format.go Lines 90 to 95 in 6bf70df
You can notice that Therefore, you need to send a PR to func (sf *serverStreamFormat) writePacketRTP(byts []byte, pkt *rtp.Packet, ntp time.Time) error {
sf.rtcpSender.ProcessPacket(pkt, ntp, sf.format.PTSEqualsDTS(pkt))
// send unicast
for r := range sf.sm.st.activeUnicastReaders {
sm, ok := r.setuppedMedias[sf.sm.media]
if ok {
err := sm.writePacketRTP(byts)
if err != nil {
r.onStreamWriteError(err)
} else {
s.sentBytes += len(byts)
}
}
}
// send multicast
if sf.sm.multicastWriter != nil {
err := sf.sm.multicastWriter.writePacketRTP(byts)
if err != nil {
return err
}
s.sentBytes += len(byts)
}
return nil
} After you do this, you can finally obtain the right // BytesSent returns sent bytes.
func (s *Stream) BytesSent() uint64 {
return atomic.LoadUint64(s.bytesSent) + s.rtspStream.BytesSent() + s.rtspsStream.BytesSent()
} |
I understand your point that your gortsplib should help out. I've checked its sources. Although I still do not fully understand its internals, I'm not sure whether the following change would be correct:
Because it looks like the
Also, a very similar code exists for RTCP, so I guess we also would need:
Can you confirm the following resulting changes?
The problem just remains that the above "sf.sm.st" and "sm.st" references are still incorrect, as the "sentBytes" is on "ServerSession" and not "ServerStream". I'm still trying to find out how to get to the "ServerStream" instead... |
you're confusing |
OK, next attempt: how about the following adjustment to your gortsplib?
Followed by an adjustment to my own PR to MediaMTX:
|
@rse this may work, open a PR inside gortsplib in order to check whether tests are successful. |
PR filed for gortsplib... Let's see... |
1462b21
to
04aa21d
Compare
Hmmm.. the new code in gortsplib fails when used from within MediaMTX:
The references "uint64" is properly initialized in gortsplib AFAIK. Here someone who better knowns Go has to shed some light on me, please. What additional initialization would be needed? |
paths_bytes_sent, srt_conns, srt_conns_bytes_received, srt_conns_bytes_sent
04aa21d
to
9ca41b1
Compare
Ok, I guess I've found the issue. It is one level above gortsplib: directly inside MediaMTX it can be that there are not RTSP channels, of course. |
The changes were now adjusted to use the new gortsplib functionality and finally pass all tests. Please review it now once again. Thanks for your support. |
Before merging, i need to add a mutex around |
Changes are now allowed. |
merged. Thanks again for this relevant contribution. |
This issue is mentioned in release v1.3.0 🚀 |
The following tries to resolve issues #2620 and #2619 by adding the following, missing Prometheus exports: paths_bytes_sent, srt_conns, srt_conns_bytes_received, srt_conns_bytes_sent
Fixes #2620
Fixes #2619