getStats() is the API in WebRTC that is used to collect metrics (statistics) from an ongoing WebRTC session. It is usually called periodically throughout the lifetime of a WebRTC session to gauge the health of the session by the client.

The metrics returned are returned as a set of reports, each dealing with a different aspect of the session.

There are two types of metrics you can retrieve with getStats(), the set that is now called “legacy” stats and the spec-compliant stats. The spec-compliant ones are provided when calling getStats() using a promise. It is advisable to use the spec-complaint stats.

The data exposed via getStats() is also available in webrtc-internals.

Additional reading

Tags: Stats

Looking to learn more about WebRTC? 

Check my WebRTC training courses

About WebRTC Glossary

The WebRTC Glossary is an ongoing project where users can learn more about WebRTC related terms. It is maintained by Tsahi Levent-Levi of BlogGeek.me.