Skip to content

Create the configuration for a dedicated metrics publishing service#6726

Open
TheOneFromNorway wants to merge 2 commits intonextfrom
MAV-7300/create_metrics_publisher_service
Open

Create the configuration for a dedicated metrics publishing service#6726
TheOneFromNorway wants to merge 2 commits intonextfrom
MAV-7300/create_metrics_publisher_service

Conversation

@TheOneFromNorway
Copy link
Copy Markdown
Contributor

  • This allows for publishing service-independent metrics
  • This is valuable for higher level stats that should not be produced per running container

...

Jira Issue - MAV-XXX

Screenshots

...

- This allows for publishing service-independent metrics
- This is valuable for higher level stats that should not be produced
  per running container
@TheOneFromNorway TheOneFromNorway marked this pull request as ready for review May 1, 2026 10:18
@TheOneFromNorway TheOneFromNorway requested a review from a team as a code owner May 1, 2026 10:19
Comment thread bin/metrics-publisher
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/environment"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we actually need to load the entire Rails env? Or is this just to load bundler so we can require prometheus_exporter/instrumentation? Just looking at PrometheusExporter::CustomActiveRecordCollector it's not clear to me that all of Rails is needed.

Comment thread bin/prometheus_exporter
Comment on lines +42 to +49
labels = {
"TaskId" => resolve_label("PROMETHEUS_TASK_ID_LABEL") do
ARGV.include?("skip-server-labels") ? nil : fetch_ecs_task_id
end,
"ServiceName" => resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do
ARGV.include?("skip-server-labels") ? nil : ENV["SERVICE_NAME"]
end
}.compact
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I would've expected skip-server-labels to override the env vars? For example, I would expect that a shell could have those env vars set from previous testing / work, but if you ran this script with skip-server-labels it wouldn't send those. I think the way resolve_label works is that it'll ignore this block, and the ARGV check inside it, if the env var is set.

If I'm right, simply swapping the ARGV check with the fetch_ecs_task_id call would fix it, although this syntax might be invalid because of the block, probably will have to tweak it.

Suggested change
labels = {
"TaskId" => resolve_label("PROMETHEUS_TASK_ID_LABEL") do
ARGV.include?("skip-server-labels") ? nil : fetch_ecs_task_id
end,
"ServiceName" => resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do
ARGV.include?("skip-server-labels") ? nil : ENV["SERVICE_NAME"]
end
}.compact
labels = {
"TaskId" => ARGV.include?("skip-server-labels") ? nil : resolve_label("PROMETHEUS_TASK_ID_LABEL") do
fetch_ecs_task_id
end,
"ServiceName" => ARGV.include?("skip-server-labels") ? nil : resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do
ENV["SERVICE_NAME"]
end
}.compact

- As it relies on the same template infrastructure the modifications are
  trivial
@TheOneFromNorway TheOneFromNorway force-pushed the MAV-7300/create_metrics_publisher_service branch from 06b8434 to 891c1a8 Compare May 1, 2026 10:59
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