Skip to content

Conversation

@jeffkreeftmeijer
Copy link

We're exploring adopting OpenTelemetry for our Elixir offering at AppSignal and found that controller render actions weren't being traced.

This PR adds support for tracing Phoenix controller render events, enabling instrumentation of template rendering within controller actions.

Changes

  • Attach telemetry handlers for controller render start/stop/exception events
  • Implement span creation for controller renders with format: ViewModule#template.format (e.g., MyAppWeb.PageView#index.html)
  • Add optional controller configuration option (enabled by default, can be disabled with controller: false). Added in a separate commit in case we'd like to keep this out.
  • Update module documentation to mention controller render events

Add support for tracing Phoenix controller render events. This enables
instrumentation of template rendering within controller actions,
providing visibility into view rendering performance.

Changes:
- Attach telemetry handlers for controller render start/stop/exception
- Implement span creation for controller renders with format:
  ViewModule#template.format (e.g., MyAppWeb.PageView#index.html)
- Add test coverage for controller render tracing
- Update module documentation to mention controller render events

The implementation follows the same pattern as the LiveView handlers.
Add optional configuration to enable/disable controller render tracing.
The feature is enabled by default and can be disabled by passing
`controller: false` to `setup/1`.

Changes:
- Add `controller` boolean option to setup (defaults to true)
- Conditionally attach controller render handlers based on option
- Add test coverage for disabled controller render tracing
@jeffkreeftmeijer jeffkreeftmeijer requested a review from a team as a code owner December 22, 2025 15:24
@linux-foundation-easycla
Copy link

CLA Not Signed

@tsloughter
Copy link
Member

@jeffkreeftmeijer thanks! I'd like to hear from others why these weren't already instrumented as I am not very familiar with Phoenix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants