Performance measurement and telemetry for PhoenixLiveCalendar.
Emits :telemetry events so consumers can attach their own handlers
(LiveDashboard, Grafana, etc.) and logs warnings when operations exceed
configurable thresholds.
Telemetry events
All events are prefixed with [:phoenix_live_calendar]:
| Event | Measurements | Metadata |
|---|---|---|
[:phoenix_live_calendar, :measure, :start] | %{system_time: integer} | %{label: atom} ++ custom |
[:phoenix_live_calendar, :measure, :stop] | %{duration: integer} | %{label: atom} ++ custom |
[:phoenix_live_calendar, :measure, :exception] | %{duration: integer} | %{label: atom, kind: atom, reason: term, stacktrace: list} |
[:phoenix_live_calendar, :ingress] | %{event_count: integer, estimated_bytes: integer} | %{view: atom} |
Configuration
config :phoenix_live_calendar,
perf_warnings: true,
perf_thresholds: %{
group_events: 10,
slot_layout: 5,
filter: 5,
overlap_layout: 5
}Set perf_warnings: false to silence all Logger warnings. Override individual
thresholds via the perf_thresholds map.
Summary
Functions
Measures the execution time of fun, emits telemetry events, and logs
a warning if the duration exceeds the configured threshold for label.
Measures and also checks duration against threshold, logging a warning
if exceeded. Use this instead of measure/3 for hot paths where you
want automatic threshold warnings.
Profiles an incoming event list at ingress time. Always runs exactly once per data update, regardless of dataset size.
Returns whether measurement should run for hot paths given the dataset size. Small datasets skip measurement to avoid overhead.
Returns the configured threshold in milliseconds for a given label.
Returns whether perf warnings are enabled.
Functions
Measures the execution time of fun, emits telemetry events, and logs
a warning if the duration exceeds the configured threshold for label.
Returns the result of fun.
Examples
Telemetry.measure(:group_events, %{events: 200, dates: 42}, fn ->
DateHelpers.group_events_by_date(events, dates)
end)
Measures and also checks duration against threshold, logging a warning
if exceeded. Use this instead of measure/3 for hot paths where you
want automatic threshold warnings.
Returns the result of fun.
@spec profile_ingress([struct()], atom()) :: {non_neg_integer(), non_neg_integer()}
Profiles an incoming event list at ingress time. Always runs exactly once per data update, regardless of dataset size.
Emits a [:phoenix_live_calendar, :ingress] telemetry event and logs warnings
for large datasets or high memory usage.
Returns {event_count, estimated_bytes} for the caller to use in
downstream decisions (e.g. whether to measure hot paths).
@spec should_measure?(non_neg_integer()) :: boolean()
Returns whether measurement should run for hot paths given the dataset size. Small datasets skip measurement to avoid overhead.
Returns the configured threshold in milliseconds for a given label.
@spec warnings_enabled?() :: boolean()
Returns whether perf warnings are enabled.