Tips for effective use of Telemetry in Elixir
- Events should all follow a naming scheme, like
[:my_lib, :function_call, ...]
Make Telemetry events suitable for spans, which allow their use in tracing:
- When starting a function call, execute a
[:lib, function, :start]event.
- When finishing a function call, execute a
[:lib, function, :stop]event.
- If something inside the function call raises or throws an exception, execute a
[:lib, :function, :exception]event.
For functions which use result tuples, include the error on events metadata inside an optional
Allow users to add more metadata. This is often useful for users who want to add additional context or business related metrics to each event.
See Use a single module for telemetry and include all of your context and docs in that module and Test your events on Telemetry Conventions for code examples.