elixir-webrtc / ex_webrtc

An Elixir implementation of the W3C WebRTC API
Apache License 2.0
363 stars 14 forks source link

Observability: OpenTelemetry #172

Open tsloughter opened 1 month ago

tsloughter commented 1 month ago

Hello! I was looking at https://elixir-webrtc.org/ again thanks to the streams that were going on and noticed the Observability feature link to a video about Phoenix Dashboards -- great to have (I want Otel Phoenix Dashboards :), but a limited observability solution). It had me think to check if the OpenTelemetry project (https://opentelemetry.io/) -- a vendor agnostic solution to instrumenting and exporting telemetry data conforming to a standard -- had any semantic conventions (standardized names and attributes for telemetry so the data can be understood) for WebRTC -- https://github.com/open-telemetry/semantic-conventions. The only thing I could find is this old issue, https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1216, that went no where.

This had me think it would be awesome if it was Elixir's WebRTC that pushed a standardization forward :).

I know next to nothing about WebRTC but a quick search it seemed there was standard metric names for some parts but that is it?

Note, we have telemetry integration, so this isn't to say, "you should use our libraries". A user could already hook OpenTelemetry into telemetry events from ex_webrtc. But these metrics and events will be different between webrtc implementations and not allow users and vendors to define reusable dashboards and alerts.

mickel8 commented 1 month ago

Hi @tsloughter,

The main class in WebRTC is RTCPeerConnection and it exposes getStats. This functions returns a report with statistics about each audio and video track e.g. bitrate, retransmissions, packets sent, packets received, codec etc. The exact form of a report is standardized by W3C, e.g. statistics for a track that is sent to the other side has the follwoing form: https://www.w3.org/TR/webrtc-stats/#dom-rtcoutboundrtpstreamstats

The nature of WebRTC is that tracks can be added and removed in time, and in most cases you want to call getStats every X seconds (e.g. every second) to observer the bitrate, packet loss etc.

I don't know how this plays with OpenTelemetry. AFAIK, OpenTelemetry is more about some generic events e.g. track added, track removed, or about tracking function calls. In general, OpenTelemetry sounds to me like something pretty generic, and because of that, it's also pretty hard to me to understand it