Add /metrics endpoint with Prometheus metrics gem #19

Closed
opened 2026-05-25 03:04:42 +00:00 by ldraney · 0 comments
Owner

Type

Feature

Lineage

Standalone -- discovered during observability gap audit. Prerequisite for ServiceMonitor and dashboard issues to be useful.

Repo

ldraney/landscaping-assistant

User Story

As an operator
I want the Rails app to expose a /metrics endpoint with standard request metrics
So that Prometheus can scrape application-level data for dashboards and alerts

Context

The Rails app has no Prometheus metrics integration. The Gemfile contains zero metrics-related gems. Without a /metrics endpoint, even a correctly configured ServiceMonitor has nothing to scrape. This is the foundational piece that all other observability work depends on. Two main options: prometheus_exporter (separate metrics server on port 9394) or yabeda-rails + yabeda-prometheus (serves on the main app port at /metrics). The yabeda approach is simpler for ServiceMonitor configuration since it uses the same port.

File Targets

Files the agent should modify or create:

  • Gemfile -- add metrics gem(s)
  • config/initializers/metrics.rb or config/initializers/yabeda.rb -- configure metrics collection
  • config/routes.rb -- mount metrics endpoint if needed (yabeda-prometheus auto-mounts)

Files the agent should NOT touch:

  • .woodpecker.yaml -- CI config is a separate concern
  • Application controllers/models -- no business logic changes

Acceptance Criteria

  • Metrics gem added to Gemfile and bundle installed
  • /metrics endpoint returns Prometheus text format (content-type text/plain)
  • Metrics include: request count by method/controller/status, request duration histogram, active request gauge
  • /metrics returns HTTP 200 in both development and production
  • Metrics endpoint requests are excluded from Rails request logging

Test Expectations

  • Manual: curl localhost:3000/metrics returns Prometheus-format metrics
  • Manual: make a few requests to the app, then verify counters increment on /metrics
  • Run command: bundle exec rails runner "puts 'metrics configured'" RAILS_ENV=development

Constraints

  • Prefer yabeda-rails + yabeda-prometheus for simpler ServiceMonitor port alignment
  • If using prometheus_exporter, document the port difference for ServiceMonitor configuration
  • Consider yabeda-puma-plugin for thread/worker saturation metrics if using Puma
  • No authentication on /metrics -- internal cluster traffic only

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-landscaping-assistant -- project this affects
### Type Feature ### Lineage Standalone -- discovered during observability gap audit. Prerequisite for ServiceMonitor and dashboard issues to be useful. ### Repo `ldraney/landscaping-assistant` ### User Story As an operator I want the Rails app to expose a /metrics endpoint with standard request metrics So that Prometheus can scrape application-level data for dashboards and alerts ### Context The Rails app has no Prometheus metrics integration. The Gemfile contains zero metrics-related gems. Without a /metrics endpoint, even a correctly configured ServiceMonitor has nothing to scrape. This is the foundational piece that all other observability work depends on. Two main options: `prometheus_exporter` (separate metrics server on port 9394) or `yabeda-rails` + `yabeda-prometheus` (serves on the main app port at /metrics). The yabeda approach is simpler for ServiceMonitor configuration since it uses the same port. ### File Targets Files the agent should modify or create: - `Gemfile` -- add metrics gem(s) - `config/initializers/metrics.rb` or `config/initializers/yabeda.rb` -- configure metrics collection - `config/routes.rb` -- mount metrics endpoint if needed (yabeda-prometheus auto-mounts) Files the agent should NOT touch: - `.woodpecker.yaml` -- CI config is a separate concern - Application controllers/models -- no business logic changes ### Acceptance Criteria - [ ] Metrics gem added to Gemfile and bundle installed - [ ] `/metrics` endpoint returns Prometheus text format (content-type `text/plain`) - [ ] Metrics include: request count by method/controller/status, request duration histogram, active request gauge - [ ] `/metrics` returns HTTP 200 in both development and production - [ ] Metrics endpoint requests are excluded from Rails request logging ### Test Expectations - [ ] Manual: `curl localhost:3000/metrics` returns Prometheus-format metrics - [ ] Manual: make a few requests to the app, then verify counters increment on /metrics - Run command: `bundle exec rails runner "puts 'metrics configured'" RAILS_ENV=development` ### Constraints - Prefer `yabeda-rails` + `yabeda-prometheus` for simpler ServiceMonitor port alignment - If using `prometheus_exporter`, document the port difference for ServiceMonitor configuration - Consider `yabeda-puma-plugin` for thread/worker saturation metrics if using Puma - No authentication on /metrics -- internal cluster traffic only ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-landscaping-assistant` -- project this affects
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/landscaping-assistant#19
No description provided.