mirror of
https://github.com/pion/webrtc.git
synced 2025-10-04 23:02:48 +08:00
Add Req/Res count/time to candidate stats (#3043)
See https://github.com/pion/ice/pull/763
This commit is contained in:
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.20
|
|||||||
require (
|
require (
|
||||||
github.com/pion/datachannel v1.5.10
|
github.com/pion/datachannel v1.5.10
|
||||||
github.com/pion/dtls/v3 v3.0.4
|
github.com/pion/dtls/v3 v3.0.4
|
||||||
github.com/pion/ice/v4 v4.0.6
|
github.com/pion/ice/v4 v4.0.7
|
||||||
github.com/pion/interceptor v0.1.37
|
github.com/pion/interceptor v0.1.37
|
||||||
github.com/pion/logging v0.2.3
|
github.com/pion/logging v0.2.3
|
||||||
github.com/pion/randutil v0.1.0
|
github.com/pion/randutil v0.1.0
|
||||||
|
4
go.sum
4
go.sum
@@ -39,8 +39,8 @@ github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk
|
|||||||
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
||||||
github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U=
|
github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U=
|
||||||
github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg=
|
github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg=
|
||||||
github.com/pion/ice/v4 v4.0.6 h1:jmM9HwI9lfetQV/39uD0nY4y++XZNPhvzIPCb8EwxUM=
|
github.com/pion/ice/v4 v4.0.7 h1:mnwuT3n3RE/9va41/9QJqN5+Bhc0H/x/ZyiVlWMw35M=
|
||||||
github.com/pion/ice/v4 v4.0.6/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
|
github.com/pion/ice/v4 v4.0.7/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
|
||||||
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI=
|
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI=
|
||||||
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y=
|
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y=
|
||||||
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
|
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
|
||||||
|
67
stats.go
67
stats.go
@@ -2041,32 +2041,35 @@ func toICECandidatePairStats(candidatePairStats ice.CandidatePairStats) (ICECand
|
|||||||
Type: StatsTypeCandidatePair,
|
Type: StatsTypeCandidatePair,
|
||||||
ID: newICECandidatePairStatsID(candidatePairStats.LocalCandidateID, candidatePairStats.RemoteCandidateID),
|
ID: newICECandidatePairStatsID(candidatePairStats.LocalCandidateID, candidatePairStats.RemoteCandidateID),
|
||||||
// TransportID:
|
// TransportID:
|
||||||
LocalCandidateID: candidatePairStats.LocalCandidateID,
|
LocalCandidateID: candidatePairStats.LocalCandidateID,
|
||||||
RemoteCandidateID: candidatePairStats.RemoteCandidateID,
|
RemoteCandidateID: candidatePairStats.RemoteCandidateID,
|
||||||
State: state,
|
State: state,
|
||||||
Nominated: candidatePairStats.Nominated,
|
Nominated: candidatePairStats.Nominated,
|
||||||
PacketsSent: candidatePairStats.PacketsSent,
|
PacketsSent: candidatePairStats.PacketsSent,
|
||||||
PacketsReceived: candidatePairStats.PacketsReceived,
|
PacketsReceived: candidatePairStats.PacketsReceived,
|
||||||
BytesSent: candidatePairStats.BytesSent,
|
BytesSent: candidatePairStats.BytesSent,
|
||||||
BytesReceived: candidatePairStats.BytesReceived,
|
BytesReceived: candidatePairStats.BytesReceived,
|
||||||
LastPacketSentTimestamp: statsTimestampFrom(candidatePairStats.LastPacketSentTimestamp),
|
LastPacketSentTimestamp: statsTimestampFrom(candidatePairStats.LastPacketSentTimestamp),
|
||||||
LastPacketReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastPacketReceivedTimestamp),
|
LastPacketReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastPacketReceivedTimestamp),
|
||||||
FirstRequestTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestTimestamp),
|
FirstRequestTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestTimestamp),
|
||||||
LastRequestTimestamp: statsTimestampFrom(candidatePairStats.LastRequestTimestamp),
|
LastRequestTimestamp: statsTimestampFrom(candidatePairStats.LastRequestTimestamp),
|
||||||
LastResponseTimestamp: statsTimestampFrom(candidatePairStats.LastResponseTimestamp),
|
FirstResponseTimestamp: statsTimestampFrom(candidatePairStats.FirstResponseTimestamp),
|
||||||
TotalRoundTripTime: candidatePairStats.TotalRoundTripTime,
|
LastResponseTimestamp: statsTimestampFrom(candidatePairStats.LastResponseTimestamp),
|
||||||
CurrentRoundTripTime: candidatePairStats.CurrentRoundTripTime,
|
FirstRequestReceivedTimestamp: statsTimestampFrom(candidatePairStats.FirstRequestReceivedTimestamp),
|
||||||
AvailableOutgoingBitrate: candidatePairStats.AvailableOutgoingBitrate,
|
LastRequestReceivedTimestamp: statsTimestampFrom(candidatePairStats.LastRequestReceivedTimestamp),
|
||||||
AvailableIncomingBitrate: candidatePairStats.AvailableIncomingBitrate,
|
TotalRoundTripTime: candidatePairStats.TotalRoundTripTime,
|
||||||
CircuitBreakerTriggerCount: candidatePairStats.CircuitBreakerTriggerCount,
|
CurrentRoundTripTime: candidatePairStats.CurrentRoundTripTime,
|
||||||
RequestsReceived: candidatePairStats.RequestsReceived,
|
AvailableOutgoingBitrate: candidatePairStats.AvailableOutgoingBitrate,
|
||||||
RequestsSent: candidatePairStats.RequestsSent,
|
AvailableIncomingBitrate: candidatePairStats.AvailableIncomingBitrate,
|
||||||
ResponsesReceived: candidatePairStats.ResponsesReceived,
|
CircuitBreakerTriggerCount: candidatePairStats.CircuitBreakerTriggerCount,
|
||||||
ResponsesSent: candidatePairStats.ResponsesSent,
|
RequestsReceived: candidatePairStats.RequestsReceived,
|
||||||
RetransmissionsReceived: candidatePairStats.RetransmissionsReceived,
|
RequestsSent: candidatePairStats.RequestsSent,
|
||||||
RetransmissionsSent: candidatePairStats.RetransmissionsSent,
|
ResponsesReceived: candidatePairStats.ResponsesReceived,
|
||||||
ConsentRequestsSent: candidatePairStats.ConsentRequestsSent,
|
ResponsesSent: candidatePairStats.ResponsesSent,
|
||||||
ConsentExpiredTimestamp: statsTimestampFrom(candidatePairStats.ConsentExpiredTimestamp),
|
RetransmissionsReceived: candidatePairStats.RetransmissionsReceived,
|
||||||
|
RetransmissionsSent: candidatePairStats.RetransmissionsSent,
|
||||||
|
ConsentRequestsSent: candidatePairStats.ConsentRequestsSent,
|
||||||
|
ConsentExpiredTimestamp: statsTimestampFrom(candidatePairStats.ConsentExpiredTimestamp),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2163,10 +2166,22 @@ type ICECandidatePairStats struct {
|
|||||||
// (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent.
|
// (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent.
|
||||||
LastRequestTimestamp StatsTimestamp `json:"lastRequestTimestamp"`
|
LastRequestTimestamp StatsTimestamp `json:"lastRequestTimestamp"`
|
||||||
|
|
||||||
|
// FirstResponseTimestamp represents the timestamp at which the first STUN response
|
||||||
|
// was received on this particular candidate pair.
|
||||||
|
FirstResponseTimestamp StatsTimestamp `json:"firstResponseTimestamp"`
|
||||||
|
|
||||||
// LastResponseTimestamp represents the timestamp at which the last STUN response
|
// LastResponseTimestamp represents the timestamp at which the last STUN response
|
||||||
// was received on this particular candidate pair.
|
// was received on this particular candidate pair.
|
||||||
LastResponseTimestamp StatsTimestamp `json:"lastResponseTimestamp"`
|
LastResponseTimestamp StatsTimestamp `json:"lastResponseTimestamp"`
|
||||||
|
|
||||||
|
// FirstRequestReceivedTimestamp represents the timestamp at which the first
|
||||||
|
// connectivity check request was received.
|
||||||
|
FirstRequestReceivedTimestamp StatsTimestamp `json:"firstRequestReceivedTimestamp"`
|
||||||
|
|
||||||
|
// LastRequestReceivedTimestamp represents the timestamp at which the last
|
||||||
|
// connectivity check request was received.
|
||||||
|
LastRequestReceivedTimestamp StatsTimestamp `json:"lastRequestReceivedTimestamp"`
|
||||||
|
|
||||||
// TotalRoundTripTime represents the sum of all round trip time measurements
|
// TotalRoundTripTime represents the sum of all round trip time measurements
|
||||||
// in seconds since the beginning of the session, based on STUN connectivity
|
// in seconds since the beginning of the session, based on STUN connectivity
|
||||||
// check responses (ResponsesReceived), including those that reply to requests
|
// check responses (ResponsesReceived), including those that reply to requests
|
||||||
|
@@ -853,38 +853,41 @@ func getStatsSamples() []statSample { //nolint:cyclop,maintidx
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
iceCandidatePairStats := ICECandidatePairStats{
|
iceCandidatePairStats := ICECandidatePairStats{
|
||||||
Timestamp: 1688978831527.718,
|
Timestamp: 1688978831527.718,
|
||||||
Type: StatsTypeCandidatePair,
|
Type: StatsTypeCandidatePair,
|
||||||
ID: "CPxIhBDNnT_LlMJOnBv",
|
ID: "CPxIhBDNnT_LlMJOnBv",
|
||||||
TransportID: "T01",
|
TransportID: "T01",
|
||||||
LocalCandidateID: "IxIhBDNnT",
|
LocalCandidateID: "IxIhBDNnT",
|
||||||
RemoteCandidateID: "ILlMJOnBv",
|
RemoteCandidateID: "ILlMJOnBv",
|
||||||
State: "waiting",
|
State: "waiting",
|
||||||
Nominated: true,
|
Nominated: true,
|
||||||
PacketsSent: 1,
|
PacketsSent: 1,
|
||||||
PacketsReceived: 2,
|
PacketsReceived: 2,
|
||||||
BytesSent: 3,
|
BytesSent: 3,
|
||||||
BytesReceived: 4,
|
BytesReceived: 4,
|
||||||
LastPacketSentTimestamp: 5,
|
LastPacketSentTimestamp: 5,
|
||||||
LastPacketReceivedTimestamp: 6,
|
LastPacketReceivedTimestamp: 6,
|
||||||
FirstRequestTimestamp: 7,
|
FirstRequestTimestamp: 7,
|
||||||
LastRequestTimestamp: 8,
|
LastRequestTimestamp: 8,
|
||||||
LastResponseTimestamp: 9,
|
FirstResponseTimestamp: 9,
|
||||||
TotalRoundTripTime: 10,
|
LastResponseTimestamp: 9,
|
||||||
CurrentRoundTripTime: 11,
|
FirstRequestReceivedTimestamp: 9,
|
||||||
AvailableOutgoingBitrate: 12,
|
LastRequestReceivedTimestamp: 9,
|
||||||
AvailableIncomingBitrate: 13,
|
TotalRoundTripTime: 10,
|
||||||
CircuitBreakerTriggerCount: 14,
|
CurrentRoundTripTime: 11,
|
||||||
RequestsReceived: 15,
|
AvailableOutgoingBitrate: 12,
|
||||||
RequestsSent: 16,
|
AvailableIncomingBitrate: 13,
|
||||||
ResponsesReceived: 17,
|
CircuitBreakerTriggerCount: 14,
|
||||||
ResponsesSent: 18,
|
RequestsReceived: 15,
|
||||||
RetransmissionsReceived: 19,
|
RequestsSent: 16,
|
||||||
RetransmissionsSent: 20,
|
ResponsesReceived: 17,
|
||||||
ConsentRequestsSent: 21,
|
ResponsesSent: 18,
|
||||||
ConsentExpiredTimestamp: 22,
|
RetransmissionsReceived: 19,
|
||||||
PacketsDiscardedOnSend: 23,
|
RetransmissionsSent: 20,
|
||||||
BytesDiscardedOnSend: 24,
|
ConsentRequestsSent: 21,
|
||||||
|
ConsentExpiredTimestamp: 22,
|
||||||
|
PacketsDiscardedOnSend: 23,
|
||||||
|
BytesDiscardedOnSend: 24,
|
||||||
}
|
}
|
||||||
iceCandidatePairStatsJSON := `
|
iceCandidatePairStatsJSON := `
|
||||||
{
|
{
|
||||||
@@ -904,7 +907,10 @@ func getStatsSamples() []statSample { //nolint:cyclop,maintidx
|
|||||||
"lastPacketReceivedTimestamp": 6,
|
"lastPacketReceivedTimestamp": 6,
|
||||||
"firstRequestTimestamp": 7,
|
"firstRequestTimestamp": 7,
|
||||||
"lastRequestTimestamp": 8,
|
"lastRequestTimestamp": 8,
|
||||||
|
"firstResponseTimestamp": 9,
|
||||||
"lastResponseTimestamp": 9,
|
"lastResponseTimestamp": 9,
|
||||||
|
"firstRequestReceivedTimestamp": 9,
|
||||||
|
"lastRequestReceivedTimestamp": 9,
|
||||||
"totalRoundTripTime": 10,
|
"totalRoundTripTime": 10,
|
||||||
"currentRoundTripTime": 11,
|
"currentRoundTripTime": 11,
|
||||||
"availableOutgoingBitrate": 12,
|
"availableOutgoingBitrate": 12,
|
||||||
|
Reference in New Issue
Block a user