Method: Tasker::MetricsController#index

Defined in:
app/controllers/tasker/metrics_controller.rb

#indexText

Metrics endpoint providing Prometheus-compatible metrics Uses optional authentication based on telemetry configuration

Returns:

  • (Text)

    Prometheus format metrics or JSON error



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/tasker/metrics_controller.rb', line 22

def index
  result = export_metrics

  if result[:success]
    render plain: result[:data], content_type: 'text/plain; charset=utf-8'
  else
    render json: {
      error: 'Metrics export failed',
      message: result[:error],
      timestamp: result[:timestamp]
    }, status: :service_unavailable
  end
rescue StandardError => e
  render json: {
    error: 'Metrics endpoint failed',
    message: e.message,
    timestamp: Time.current.iso8601
  }, status: :service_unavailable
end