3 ms·
The Erlang "telemetry" module can even be used "applicatively" with good uses. An example of that is a "caching reverse proxy" in use at https://transport.data
by thibaut_barrere 3y ago
The Erlang "telemetry" module can even be used "applicatively" with good uses.
An example of that is a "caching reverse proxy" in use at https://transport.data.gouv.fr/ https://transport.data.gouv.fr/, which helps protect data producers servers from excessive load from data consumers (which we manage for them).
"External" requests come to us (via proxy.transport.data.gouv.fr) and if the response is not in cache (for a configured TTL), we forward the request as an "internal" request to the target (3rd party) server.
The proxy uses "telemetry" to generate events for these internal/external queries, without knowing how they will be consumed (https://github.com/etalab/transport-site/blob/master/apps/unlock/lib/controller.ex https://github.com/etalab/transport-site/blob/master/apps/un...).
The main app receives those events and does what it wants, in this case upserting metrics in the database (https://github.com/etalab/transport-site/blob/master/apps/transport/lib/transport/telemetry.ex https://github.com/etalab/transport-site/blob/master/apps/tr...).
As a result, it's easy to use LiveView to create a real-time dashboard to show these metrics (https://jumpshare.com/s/rdGtTa47CzlcgOz4jsOI https://jumpshare.com/s/rdGtTa47CzlcgOz4jsOI - low traffic at time of posting) or generate stats for the data producers which are behind the proxy (EDIT: LiveView source code at https://github.com/etalab/transport-site/blob/master/apps/transport/lib/transport_web/live/backoffice/proxy_config_live.ex https://github.com/etalab/transport-site/blob/master/apps/tr... and https://github.com/etalab/transport-site/blob/master/apps/transport/lib/transport_web/live/backoffice/proxy_config_live.html.heex https://github.com/etalab/transport-site/blob/master/apps/tr...).
It's all quite natural to do because it's really baked into the runtime!
- chasers 3y agoWe use :telemetry to collect usage data per tenant for Supabase Realtime. We do this for rate limiting but it also makes it very easy for us to attach a listener (https://github.com/supabase/realtime/blob/main/lib/realtime/telemetry/logger.ex https://github.com/supabase/realtime/blob/main/lib/realtime/...) which ships these (per second) aggregates to BigQuery (via Logflare), which then the billing team can aggregate further to display and actually bill people with.
- thibaut_barrere 3y agoThanks for sharing!