Skip to content
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

RTCStatsReport - make this the center of statistics docs #27028

Merged
merged 29 commits into from
Jun 5, 2023

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented May 29, 2023

We're flattening the RTCStats hierarchy and making the entry points clearer. This updates RTCStatsReport to include the list of types it might return and information about the map methods.

I have individually documented the map methods. I don't think we can just link to map because the versions in which these are implemented would then not be documentable in the context of RTCStatsReport BCD.

If this gets in, next step would be to purge RTCStats. Then start filling out the other dictionaries.

A question - this is in RTCStatsReport is shown in WebRTC API home page AND https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API -. Is this second doc of any use? It has no sidebar, and I will move most things into RTCStatsReport?
Or to put it another way, how do we handle sidebars with these kind of "sub APIs"

This is part of the docs work in #26146

@hamishwillee hamishwillee requested a review from a team as a code owner May 29, 2023 07:25
@hamishwillee hamishwillee requested review from wbamberg and removed request for a team May 29, 2023 07:25
@github-actions github-actions bot added the Content:WebAPI Web API docs label May 29, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 29, 2023

Preview URLs (42 pages)
Flaws (85)

Note! 25 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/RTCIceCandidateStats
Title: RTCIceCandidateStats
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/RTCTransportStats does not exist

URL: /en-US/docs/Web/API/RTCIceCandidatePairStats
Title: RTCIceCandidatePairStats
Flaw count: 5

  • macros:
    • /en-US/docs/Glossary/IP does not exist
    • /en-US/docs/Glossary/IP does not exist
    • /en-US/docs/Web/API/RTCTransportStats does not exist
    • /en-US/docs/Web/API/RTCTransportStats does not exist
    • /en-US/docs/Web/API/RTCTransportStats/selectedCandidatePairId does not exist

URL: /en-US/docs/Web/API/RTCStatsReport
Title: RTCStatsReport
Flaw count: 6

  • macros:
    • /en-US/docs/Web/API/RTCCertificateStats does not exist
    • /en-US/docs/Web/API/RTCCodecStats does not exist
    • /en-US/docs/Web/API/RTCDataChannelStats does not exist
    • /en-US/docs/Web/API/RTCVideoSourceStats does not exist
    • /en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats does not exist
    • and 1 more flaws omitted

URL: /en-US/docs/Web/API/RTCStatsReport/@@iterator
Title: RTCStatsReport: [@@iterator]() method
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: api.RTCStatsReport.@@iterator

URL: /en-US/docs/Web/API/RTCInboundRtpStreamStats
Title: RTCInboundRtpStreamStats
Flaw count: 19

  • macros:
    • /en-US/docs/Web/API/RTCInboundRtpStreamStats/packetsDiscarded does not exist
    • /en-US/docs/Web/API/RTCInboundRtpStreamStats/packetsDiscarded does not exist
    • /en-US/docs/Web/API/RTCAudioReceiverStats does not exist
    • /en-US/docs/Web/API/RTCVideoReceiverStats does not exist
    • /en-US/docs/Web/API/RTCReceiverAudioTrackAttachmentStats does not exist
    • and 14 more flaws omitted

URL: /en-US/docs/Web/API/RTCInboundRtpStreamStats/trackId
Title: RTCInboundRtpStreamStats: trackId property
Flaw count: 5

  • macros:
    • /en-US/docs/Web/API/RTCReceiverAudioTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCReceiverVideoTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCReceiverAudioTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCReceiverVideoTrackAttachmentStats does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCInboundRtpStreamStats.trackId

URL: /en-US/docs/Web/API/RTCInboundRtpStreamStats/receiverId
Title: RTCInboundRtpStreamStats: receiverId property
Flaw count: 3

  • macros:
    • /en-US/docs/Web/API/RTCAudioReceiverStats does not exist
    • /en-US/docs/Web/API/RTCVideoReceiverStats does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCInboundRtpStreamStats.receiverId

URL: /en-US/docs/Web/API/RTCRtpStreamStats
Title: RTCRtpStreamStats
Flaw count: 7

  • macros:
    • /en-US/docs/Web/API/RTCCodecStats does not exist
    • /en-US/docs/Web/API/RTCCodecStats/codec does not exist
    • /en-US/docs/Web/API/RTCMediaStreamTrackStats does not exist
    • /en-US/docs/Web/API/RTCTransportStats does not exist
    • /en-US/docs/Web/API/RTCReceivedRtpStreamStats/framesDecoded does not exist
    • and 1 more flaws omitted
  • bad_bcd_queries:
    • No BCD data for query: api.RTCRtpStreamStats

URL: /en-US/docs/Web/API/WebRTC_API
Title: WebRTC API
Flaw count: 4

  • macros:
    • /en-US/docs/Web/API/RTCDtlsTransport/statechange_event does not exist
    • /en-US/docs/Web/API/RTCIdentityProvider does not exist
    • /en-US/docs/Web/API/RTCIdentityProviderRegistrar does not exist
  • broken_links:
    • Can't resolve /en-US/docs/Web/API/WebRTC_API/adapter.js

URL: /en-US/docs/Web/API/RTCRemoteOutboundRtpStreamStats
Title: RTCRemoteOutboundRtpStreamStats
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/RTCSentRtpStreamStats does not exist

URL: /en-US/docs/Web/API/RTCRemoteOutboundRtpStreamStats/localId
Title: RTCRemoteOutboundRtpStreamStats: localId property
Flaw count: 5

  • macros:
    • /en-US/docs/Web/API/RTCStats redirects to /en-US/docs/Web/API/RTCStatsReport
    • /en-US/docs/Web/API/RTCStats redirects to /en-US/docs/Web/API/RTCStatsReport
    • /en-US/docs/Web/API/RTCSentRtpStreamStats/packetsSent does not exist
    • /en-US/docs/Web/API/RTCSentRtpStreamStats/bytesSent does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCRemoteOutboundRtpStreamStats.localId

URL: /en-US/docs/Web/API/RTCRemoteOutboundRtpStreamStats/remoteTimestamp
Title: RTCRemoteOutboundRtpStreamStats: remoteTimestamp property
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: api.RTCRemoteOutboundRtpStreamStats.remoteTimestamp

URL: /en-US/docs/Web/API/RTCOutboundRtpStreamStats
Title: RTCOutboundRtpStreamStats
Flaw count: 16

  • macros:
    • /en-US/docs/Web/API/RTCSentRtpStreamStats does not exist
    • /en-US/docs/Web/API/RTCOutboundRtpStreamStats/qualityLimitationDurations does not exist
    • /en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats does not exist
    • /en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats does not exist
    • /en-US/docs/Web/API/RTCOutboundRtpStreamStats/retransmittedBytesSent does not exist
    • and 11 more flaws omitted

URL: /en-US/docs/Web/API/RTCOutboundRtpStreamStats/trackId
Title: RTCOutboundRtpStreamStats: trackId property
Flaw count: 5

  • macros:
    • /en-US/docs/Web/API/RTCSenderAudioTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCSenderVideoTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCSenderAudioTrackAttachmentStats does not exist
    • /en-US/docs/Web/API/RTCSenderVideoTrackAttachmentStats does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCOutboundRtpStreamStats.trackId

URL: /en-US/docs/Web/API/RTCOutboundRtpStreamStats/qpSum
Title: RTCOutboundRtpStreamStats: qpSum property
Flaw count: 2

  • macros:
    • /en-US/docs/Web/API/RTCSentRtpStreamStats/framesEncoded does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCStatsReport.type_outbound-rtp.qpSum

URL: /en-US/docs/Web/API/RTCOutboundRtpStreamStats/remoteId
Title: RTCOutboundRtpStreamStats: remoteId property
Flaw count: 3

  • macros:
    • /en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats does not exist
    • /en-US/docs/Web/API/RTCRemoteInboundRtpStreamStats does not exist
  • bad_bcd_queries:
    • No BCD data for query: api.RTCOutboundRtpStreamStats.remoteId

URL: /en-US/docs/Web/API/RTCOutboundRtpStreamStats/lastPacketSentTimestamp
Title: RTCOutboundRtpStreamStats: lastPacketSentTimestamp property
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: api.RTCStatsReport.type_outbound-rtp.lastPacketSentTimestamp

(comment last updated: 2023-06-05 07:08:48)


## Examples

### Iterate report from an RTCPeerConnection using forEach loop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW all the examples are similar because they are all ways of iterating the map and checking against type. We should revisit this later with a few more interesting examples - looking at real statistics - that would show off things like taking averages as I did in the peer connection stats.

Don't want to do that until I have a better idea of what you can do with stats.

Comment on lines 11 to 13
The **`keys()`** method of the {{domxref("RTCStatsReport")}} interface returns a new _[map iterator](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator)_ object that can be used to iterate through the keys for each element in the `RTCStatsReport` object, in insertion order.

The keys in the `RTCStatsReport` are unique string `id` values, which represent the monitored statistics objects from which the statistics are derived.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I wasn't sure how to do this (everywhere) refer to keys, and values as per map and then explain what they are, or refer to them as ids and statistics dictionaries. My feeling is that this approach is slightly better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach.


### Using keys()

This example shows how to iterate through a statistics report by calling `next()` on the iterator returned by `keys()`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this example is a little contrived. Yes you can do it, but as we're only using the keys to get the values, you might as well iterate the values or entries.

As far as I can tell the ids aren't all that useful unless you're comparing a particular statistic across a timeslice.

@hamishwillee hamishwillee mentioned this pull request May 29, 2023
10 tasks
@wbamberg
Copy link
Collaborator

wbamberg commented May 29, 2023

A question - this is in RTCStatsReport is shown in WebRTC API home page AND https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API -. Is this second doc of any use? It has no sidebar, and I will move most things into RTCStatsReport?

What do you think about converting this to a "Analyzing WebRTC statistics" guide page? It doesn't make sense at all as an API overview page.

(edited: or you could just fold whatever is salvageable into https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport. Less work. But I do feel this could benefit from a guide.)

@hamishwillee hamishwillee requested review from a team as code owners May 30, 2023 02:30
@hamishwillee hamishwillee requested review from bsmth and removed request for a team May 30, 2023 02:30
@@ -0,0 +1,84 @@
---
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wbamberg This is the old WebRTC Statistics API page moved to the title you suggested. I tidied up the table and there is a lot more work that can and should be done. This is "less crap" than it was. But we will need to create a more complete guide later, after having done all the dictionaries.

This PR should merge first.

The report may contain many different categories of statistics, including inbound and outbound statistics for both the current and remote ends of the peer connection, information about codecs, certificates and media used, and so on.
Each category of statistic is provided in a different type of statistics dictionary object, which can be identified from its [`type`](#type) property.

### Common instance properties
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wbamberg OK, so this adds a specific section in description about the instance properties, as you suggested in https://github.com/mdn/content/pull/27028/files#r1213871272

It makes clear that you probably use type to find your stat of interest, and can subsequently use the id to track change.
This could do with an example, but it is pretty hard to test stuff. So for now I have not done one.

If I was to, I might expand the example here: https://developer.mozilla.org/en-US/docs/Web/API/RTCAudioSourceStats#examples
Showing how you calculate the audio level across a timeslice.

@hamishwillee
Copy link
Collaborator Author

Thanks for that. I think we're ready for another round of re-review.

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you @hamishwillee , very nice work.

@wbamberg wbamberg merged commit fbbef30 into mdn:main Jun 5, 2023
yin1999 added a commit to mdn/translated-content that referenced this pull request Jun 6, 2023
yin1999 added a commit to mdn/translated-content that referenced this pull request Jun 6, 2023
* zh-cn: sync translated content

* RTCStatsReport - make this the center of statistics docs

ref: mdn/content#27028

---------

Co-authored-by: allo <[email protected]>
@hamishwillee
Copy link
Collaborator Author

Thanks so much for the review. I appreciate it is not much fun! :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants