Add session usage reporting callback to TURN database driver#1794
Add session usage reporting callback to TURN database driver#1794mesibo wants to merge 6 commits intocoturn:masterfrom
Conversation
|
@mesibo thanks for the PR
|
|
We initially had a MySQL driver implementation of report_usage, but later refactored our approach, removed all db drivers, and built a REST API-based driver instead. We can contribute if it works for you. On the conditional flag — not sure that's necessary. Like any other function in the dbdriver interface, the implementation can simply choose to ignore it if not needed. On a broader note, bundling DB drivers into Coturn pulls in external dependencies (libmysqlclient, libpq, etc.) that add unnecessary build and maintenance overhead for everyone. A better approach would be loadable modules, so operators can plug in their own reporting backend without touching the core Coturn build. Moreover, we felt that DB drivers don't work well with dynamic username generation — one of the reasons we moved away from them in production. We generate usernames not just based on time, but also on call ID to control and gate traffic. |
|
@mesibo Thanks for the explanation - those make sense to me. |
We use Coturn in production at mesibo and identified a gap in dbdriver: there's no callback to capture post-session metrics like duration, bandwidth consumed, timestamps, etc.
We've made the following changes, which could be useful for Coturn. Would appreciate your consideration. These changes are tested in production environments at mesibo.
Changes for reporting usage
Added a
report_usagecallback to the database driver interface, invoked at session termination. This allows drivers to capture and persist detailed usage statistics in their preferred storage (MySQL, PostgreSQL, etc.).1. Database Driver Interface
File:
src/apps/relay/dbdrivers/dbdriver.h2. Session Termination Hook
File:
src/apps/relay/ns_ioalib_engine_impl.c