Skip to content

Commit dae0af9

Browse files
authored
Add Req/Res count/time to candidate stats (#3043)
See pion/ice#763
1 parent 44062a7 commit dae0af9

File tree

4 files changed

+82
-61
lines changed

4 files changed

+82
-61
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/pion/datachannel v1.5.10
77
github.com/pion/dtls/v3 v3.0.4
8-
github.com/pion/ice/v4 v4.0.6
8+
github.com/pion/ice/v4 v4.0.7
99
github.com/pion/interceptor v0.1.37
1010
github.com/pion/logging v0.2.3
1111
github.com/pion/randutil v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk
3939
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
4040
github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U=
4141
github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg=
42-
github.com/pion/ice/v4 v4.0.6 h1:jmM9HwI9lfetQV/39uD0nY4y++XZNPhvzIPCb8EwxUM=
43-
github.com/pion/ice/v4 v4.0.6/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
42+
github.com/pion/ice/v4 v4.0.7 h1:mnwuT3n3RE/9va41/9QJqN5+Bhc0H/x/ZyiVlWMw35M=
43+
github.com/pion/ice/v4 v4.0.7/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
4444
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI=
4545
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y=
4646
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=

stats.go

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,32 +2041,35 @@ func toICECandidatePairStats(candidatePairStats ice.CandidatePairStats) (ICECand
20412041
Type: StatsTypeCandidatePair,
20422042
ID: newICECandidatePairStatsID(candidatePairStats.LocalCandidateID, candidatePairStats.RemoteCandidateID),
20432043
// TransportID:
2044-
LocalCandidateID: candidatePairStats.LocalCandidateID,
2045-
RemoteCandidateID: candidatePairStats.RemoteCandidateID,
2046-
State: state,
2047-
Nominated: candidatePairStats.Nominated,
2048-
PacketsSent: candidatePairStats.PacketsSent,
2049-
PacketsReceived: candidatePairStats.PacketsReceived,
2050-
BytesSent: candidatePairStats.BytesSent,
2051-
BytesReceived: candidatePairStats.BytesReceived,
2052-
LastPacketSentTimestamp: statsTimestampFrom(candidatePairStats.LastPacketSentTimestamp),
2053-
LastPacketReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastPacketReceivedTimestamp),
2054-
FirstRequestTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestTimestamp),
2055-
LastRequestTimestamp: statsTimestampFrom(candidatePairStats.LastRequestTimestamp),
2056-
LastResponseTimestamp: statsTimestampFrom(candidatePairStats.LastResponseTimestamp),
2057-
TotalRoundTripTime: candidatePairStats.TotalRoundTripTime,
2058-
CurrentRoundTripTime: candidatePairStats.CurrentRoundTripTime,
2059-
AvailableOutgoingBitrate: candidatePairStats.AvailableOutgoingBitrate,
2060-
AvailableIncomingBitrate: candidatePairStats.AvailableIncomingBitrate,
2061-
CircuitBreakerTriggerCount: candidatePairStats.CircuitBreakerTriggerCount,
2062-
RequestsReceived: candidatePairStats.RequestsReceived,
2063-
RequestsSent: candidatePairStats.RequestsSent,
2064-
ResponsesReceived: candidatePairStats.ResponsesReceived,
2065-
ResponsesSent: candidatePairStats.ResponsesSent,
2066-
RetransmissionsReceived: candidatePairStats.RetransmissionsReceived,
2067-
RetransmissionsSent: candidatePairStats.RetransmissionsSent,
2068-
ConsentRequestsSent: candidatePairStats.ConsentRequestsSent,
2069-
ConsentExpiredTimestamp: statsTimestampFrom(candidatePairStats.ConsentExpiredTimestamp),
2044+
LocalCandidateID: candidatePairStats.LocalCandidateID,
2045+
RemoteCandidateID: candidatePairStats.RemoteCandidateID,
2046+
State: state,
2047+
Nominated: candidatePairStats.Nominated,
2048+
PacketsSent: candidatePairStats.PacketsSent,
2049+
PacketsReceived: candidatePairStats.PacketsReceived,
2050+
BytesSent: candidatePairStats.BytesSent,
2051+
BytesReceived: candidatePairStats.BytesReceived,
2052+
LastPacketSentTimestamp: statsTimestampFrom(candidatePairStats.LastPacketSentTimestamp),
2053+
LastPacketReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastPacketReceivedTimestamp),
2054+
FirstRequestTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestTimestamp),
2055+
LastRequestTimestamp: statsTimestampFrom(candidatePairStats.LastRequestTimestamp),
2056+
FirstResponseTimestamp: statsTimestampFrom(candidatePairStats.FirstResponseTimestamp),
2057+
LastResponseTimestamp: statsTimestampFrom(candidatePairStats.LastResponseTimestamp),
2058+
FirstRequestReceivedTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestReceivedTimestamp),
2059+
LastRequestReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastRequestReceivedTimestamp),
2060+
TotalRoundTripTime: candidatePairStats.TotalRoundTripTime,
2061+
CurrentRoundTripTime: candidatePairStats.CurrentRoundTripTime,
2062+
AvailableOutgoingBitrate: candidatePairStats.AvailableOutgoingBitrate,
2063+
AvailableIncomingBitrate: candidatePairStats.AvailableIncomingBitrate,
2064+
CircuitBreakerTriggerCount: candidatePairStats.CircuitBreakerTriggerCount,
2065+
RequestsReceived: candidatePairStats.RequestsReceived,
2066+
RequestsSent: candidatePairStats.RequestsSent,
2067+
ResponsesReceived: candidatePairStats.ResponsesReceived,
2068+
ResponsesSent: candidatePairStats.ResponsesSent,
2069+
RetransmissionsReceived: candidatePairStats.RetransmissionsReceived,
2070+
RetransmissionsSent: candidatePairStats.RetransmissionsSent,
2071+
ConsentRequestsSent: candidatePairStats.ConsentRequestsSent,
2072+
ConsentExpiredTimestamp: statsTimestampFrom(candidatePairStats.ConsentExpiredTimestamp),
20702073
}, nil
20712074
}
20722075

@@ -2163,10 +2166,22 @@ type ICECandidatePairStats struct {
21632166
// (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent.
21642167
LastRequestTimestamp StatsTimestamp `json:"lastRequestTimestamp"`
21652168

2169+
// FirstResponseTimestamp represents the timestamp at which the first STUN response
2170+
// was received on this particular candidate pair.
2171+
FirstResponseTimestamp StatsTimestamp `json:"firstResponseTimestamp"`
2172+
21662173
// LastResponseTimestamp represents the timestamp at which the last STUN response
21672174
// was received on this particular candidate pair.
21682175
LastResponseTimestamp StatsTimestamp `json:"lastResponseTimestamp"`
21692176

2177+
// FirstRequestReceivedTimestamp represents the timestamp at which the first
2178+
// connectivity check request was received.
2179+
FirstRequestReceivedTimestamp StatsTimestamp `json:"firstRequestReceivedTimestamp"`
2180+
2181+
// LastRequestReceivedTimestamp represents the timestamp at which the last
2182+
// connectivity check request was received.
2183+
LastRequestReceivedTimestamp StatsTimestamp `json:"lastRequestReceivedTimestamp"`
2184+
21702185
// TotalRoundTripTime represents the sum of all round trip time measurements
21712186
// in seconds since the beginning of the session, based on STUN connectivity
21722187
// check responses (ResponsesReceived), including those that reply to requests

stats_go_test.go

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -853,38 +853,41 @@ func getStatsSamples() []statSample { //nolint:cyclop,maintidx
853853
}
854854
`
855855
iceCandidatePairStats := ICECandidatePairStats{
856-
Timestamp: 1688978831527.718,
857-
Type: StatsTypeCandidatePair,
858-
ID: "CPxIhBDNnT_LlMJOnBv",
859-
TransportID: "T01",
860-
LocalCandidateID: "IxIhBDNnT",
861-
RemoteCandidateID: "ILlMJOnBv",
862-
State: "waiting",
863-
Nominated: true,
864-
PacketsSent: 1,
865-
PacketsReceived: 2,
866-
BytesSent: 3,
867-
BytesReceived: 4,
868-
LastPacketSentTimestamp: 5,
869-
LastPacketReceivedTimestamp: 6,
870-
FirstRequestTimestamp: 7,
871-
LastRequestTimestamp: 8,
872-
LastResponseTimestamp: 9,
873-
TotalRoundTripTime: 10,
874-
CurrentRoundTripTime: 11,
875-
AvailableOutgoingBitrate: 12,
876-
AvailableIncomingBitrate: 13,
877-
CircuitBreakerTriggerCount: 14,
878-
RequestsReceived: 15,
879-
RequestsSent: 16,
880-
ResponsesReceived: 17,
881-
ResponsesSent: 18,
882-
RetransmissionsReceived: 19,
883-
RetransmissionsSent: 20,
884-
ConsentRequestsSent: 21,
885-
ConsentExpiredTimestamp: 22,
886-
PacketsDiscardedOnSend: 23,
887-
BytesDiscardedOnSend: 24,
856+
Timestamp: 1688978831527.718,
857+
Type: StatsTypeCandidatePair,
858+
ID: "CPxIhBDNnT_LlMJOnBv",
859+
TransportID: "T01",
860+
LocalCandidateID: "IxIhBDNnT",
861+
RemoteCandidateID: "ILlMJOnBv",
862+
State: "waiting",
863+
Nominated: true,
864+
PacketsSent: 1,
865+
PacketsReceived: 2,
866+
BytesSent: 3,
867+
BytesReceived: 4,
868+
LastPacketSentTimestamp: 5,
869+
LastPacketReceivedTimestamp: 6,
870+
FirstRequestTimestamp: 7,
871+
LastRequestTimestamp: 8,
872+
FirstResponseTimestamp: 9,
873+
LastResponseTimestamp: 9,
874+
FirstRequestReceivedTimestamp: 9,
875+
LastRequestReceivedTimestamp: 9,
876+
TotalRoundTripTime: 10,
877+
CurrentRoundTripTime: 11,
878+
AvailableOutgoingBitrate: 12,
879+
AvailableIncomingBitrate: 13,
880+
CircuitBreakerTriggerCount: 14,
881+
RequestsReceived: 15,
882+
RequestsSent: 16,
883+
ResponsesReceived: 17,
884+
ResponsesSent: 18,
885+
RetransmissionsReceived: 19,
886+
RetransmissionsSent: 20,
887+
ConsentRequestsSent: 21,
888+
ConsentExpiredTimestamp: 22,
889+
PacketsDiscardedOnSend: 23,
890+
BytesDiscardedOnSend: 24,
888891
}
889892
iceCandidatePairStatsJSON := `
890893
{
@@ -904,7 +907,10 @@ func getStatsSamples() []statSample { //nolint:cyclop,maintidx
904907
"lastPacketReceivedTimestamp": 6,
905908
"firstRequestTimestamp": 7,
906909
"lastRequestTimestamp": 8,
910+
"firstResponseTimestamp": 9,
907911
"lastResponseTimestamp": 9,
912+
"firstRequestReceivedTimestamp": 9,
913+
"lastRequestReceivedTimestamp": 9,
908914
"totalRoundTripTime": 10,
909915
"currentRoundTripTime": 11,
910916
"availableOutgoingBitrate": 12,

0 commit comments

Comments
 (0)