Skip to content

ANA-7386 Add Protorabbit instrumentor - #41

Open
markcmurphy wants to merge 1 commit into
mainfrom
add-protorabbit-instrumentor
Open

ANA-7386 Add Protorabbit instrumentor#41
markcmurphy wants to merge 1 commit into
mainfrom
add-protorabbit-instrumentor

Conversation

@markcmurphy

@markcmurphy markcmurphy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Jira: ANA-7386

What/Why?

Protorabbit processes have no Prometheus instrumentor, so the exporter server never starts and any metrics pushed during message processing fail with Errno::ECONNREFUSED. This is confirmed in theme-registry, auth, bmp, and bigpay, so the fix lives here rather than in each service individually.

Changes:

  • lib/bigcommerce/prometheus/instrumentors/protorabbit.rb — new Protorabbit instrumentor; starts the exporter server, registers the built-in ActiveRecordCollector/ActiveRecordSql type collector, then any configured protorabbit_collectors/protorabbit_type_collectors, mirroring Hutch/Resque minus middleware setup
  • lib/bigcommerce/prometheus/configuration.rb — adds protorabbit_collectors/protorabbit_type_collectors config, defaulting to []
  • lib/bigcommerce/prometheus.rb — requires the new instrumentor
  • README.md — documents Protorabbit.new.start usage and the new config keys
  • CHANGELOG.md, version.rb — bump to 0.9.0

A few notes for reviewers:

  • Protorabbit has no tracer/middleware hook like Hutch does, so this instrumentor only starts the server and registers collectors — it doesn't wrap message processing itself. It unblocks metrics (e.g. gRPC client interceptor metrics) already being pushed from inside message handlers that were previously refused for lack of a listening exporter.
  • Protorabbit.new takes no app: arg, unlike Hutch.new(app:) — there's no Rails app object available in a protorabbit worker context.

Rollout/Rollback

Ships as a new gem version (0.9.0) with no behavior change until a consuming service calls Bigcommerce::Prometheus::Instrumentors::Protorabbit.new.start in its protorabbit boot code. Existing Web/Resque/Hutch instrumentation is untouched.

Rollback is a plain gem downgrade; no data or schema is involved. Consuming services (theme-registry, auth, bmp, bigpay) need a follow-up change to actually wire in .start — that adoption is out of scope here.

Testing

Automated:

  • spec/bigcommerce/prometheus/instrumentors/protorabbit_spec.rb — covers disabled-noop, enabled start (registers ActiveRecordCollector, registers the ActiveRecord SQL type collector, registers configured type collector last so it can override, starts server, starts collectors), and rescue-and-log on server start failure
bundle exec rspec spec/bigcommerce/prometheus/instrumentors/protorabbit_spec.rb

Manual verification:

Before fix (no .start call) — reproduces the exact bug from ANA-7386:

W, [...] WARN -- : [bigcommerce-prometheus][unknown] Prometheus Exporter is dropping a message to http://0.0.0.0:9395/send-metrics: Failed to open TCP connection to 0.0.0.0:9395 (Connection refused - connect(2) for "0.0.0.0" port 9395)

After fix (Protorabbit.new.start called, then a metric pushed via Bigcommerce::Prometheus.client):

$ curl -s localhost:9394/metrics | grep protorabbit_smoke_test
# HELP ruby_protorabbit_smoke_test_total smoke test
# TYPE ruby_protorabbit_smoke_test_total counter
ruby_protorabbit_smoke_test_total 1

Exporter starts, registers collectors, and serves the pushed metric on /metrics — no connection refused.

Manual checklist for reviewer:

  • Confirm README's Protorabbit section matches the intended integration pattern for a consuming service
  • Confirm 0.9.0 version bump and CHANGELOG entry are accurate

Note

Low Risk
Opt-in at call sites via .start; mirrors existing Hutch/Resque server startup with no change to Web/Resque/Hutch until services wire it in.

Overview
Adds Bigcommerce::Prometheus::Instrumentors::Protorabbit so protorabbit (RabbitMQ protobuf consumer) workers can start the same embedded Prometheus exporter used by Web/Resque/Hutch. Without it, metrics pushed during message handling hit Errno::ECONNREFUSED on /send-metrics because nothing listens on the exporter port.

Call Protorabbit.new.start in protorabbit boot code (no app: argument—unlike Hutch). The instrumentor registers ActiveRecordCollector, the ActiveRecord SQL type collector, configured protorabbit_collectors / protorabbit_type_collectors, then starts the server and polling collectors. It does not wrap message processing (no Hutch-style middleware); it only enables ingestion of metrics already emitted from handlers (e.g. gRPC client interceptors).

Configuration adds protorabbit_collectors and protorabbit_type_collectors (default []). Gem version bumps to 0.9.0 with CHANGELOG/README updates and a new protorabbit_spec covering disabled noop, enabled startup order, and error rescue.

Reviewed by Cursor Bugbot for commit 61ca592. Bugbot is set up for automated code reviews on this repo. Configure here.

protorabbit worker processes ran no embedded Prometheus exporter server, so
any metric pushed from inside message processing (e.g. gRPC client interceptor
metrics) was refused with Errno::ECONNREFUSED on /send-metrics and silently
dropped.

Adds Instrumentors::Protorabbit, following the existing Hutch instrumentor
pattern minus the tracer/middleware wiring that protorabbit has no hook for,
plus protorabbit_collectors/protorabbit_type_collectors configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in Protorabbit worker instrumentation so Prometheus metrics can reach an embedded exporter.

Changes:

  • Adds and tests the Protorabbit instrumentor.
  • Adds collector configuration and integration documentation.
  • Releases the feature as version 0.9.0.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/bigcommerce/prometheus/instrumentors/protorabbit.rb Implements exporter startup and collector registration.
spec/bigcommerce/prometheus/instrumentors/protorabbit_spec.rb Tests startup, configuration, disabled behavior, and failures.
lib/bigcommerce/prometheus/configuration.rb Adds Protorabbit collector settings.
lib/bigcommerce/prometheus.rb Loads the new instrumentor.
README.md Documents setup and configuration.
CHANGELOG.md Records the new feature.
lib/bigcommerce/prometheus/version.rb Bumps the gem to 0.9.0.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@markcmurphy
markcmurphy marked this pull request as ready for review August 19, 2026 17:18
@markcmurphy
markcmurphy requested a review from a team as a code owner August 19, 2026 17:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61ca592c05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/bigcommerce/prometheus/instrumentors/protorabbit.rb
@markcmurphy
markcmurphy requested a review from a team August 24, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants