Skip to content

fix: change MetricsPusher to also send tenant metrics#1759

Merged
edgurgel merged 1 commit intomainfrom
fix/metrics-pusher-send-tenant-metrics
Mar 25, 2026
Merged

fix: change MetricsPusher to also send tenant metrics#1759
edgurgel merged 1 commit intomainfrom
fix/metrics-pusher-send-tenant-metrics

Conversation

@edgurgel
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Also use Tasks to ensure that they drop the used memory after aggregating such metrics

Copilot AI review requested due to automatic review settings March 19, 2026 00:37
@blacksmith-sh

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Realtime.MetricsPusher to push both global and tenant PromEx metrics on each interval, running each aggregation/push in its own supervised Task so memory can be reclaimed when the task exits.

Changes:

  • Push global metrics (Realtime.PromEx.get_global_metrics/0) and tenant metrics (Realtime.TenantPromEx.get_metrics/0) concurrently via Task.Supervisor.async_nolink/2.
  • Add timeout/exit handling for metrics push tasks and label global vs tenant failures in logs.
  • Update MetricsPusherTest expectations to account for two push requests per interval and seed tenant telemetry.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
lib/realtime/metrics_pusher.ex Runs global + tenant metrics pushes in separate supervised tasks and adds labeled logging/error handling.
test/realtime/metrics_pusher_test.exs Updates tests to expect two HTTP pushes and seeds tenant telemetry for tenant-metric generation.
Comments suppressed due to low confidence (1)

test/realtime/metrics_pusher_test.exs:104

  • This test is named "sends request body untouched when compress=false", but it no longer asserts anything about the request body (only headers). Please assert that the raw body contains expected plaintext metrics (and is not gzip-compressed) for both requests so the test actually validates the non-compression behavior.
      Req.Test.expect(MetricsPusher, 2, fn conn ->
        assert Conn.get_req_header(conn, "content-encoding") == []
        assert Conn.get_req_header(conn, "content-type") == ["text/plain"]

        send(parent, :req_called)
        Req.Test.text(conn, "")
      end)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@edgurgel edgurgel force-pushed the fix/metrics-pusher-send-tenant-metrics branch from 27f15fb to f53439a Compare March 19, 2026 00:57
Also use Tasks to ensure that they drop the used memory after
aggregating such metrics
@edgurgel edgurgel force-pushed the fix/metrics-pusher-send-tenant-metrics branch from f53439a to 866fd7c Compare March 19, 2026 01:03
@edgurgel edgurgel requested a review from filipecabaco March 22, 2026 22:48
@edgurgel edgurgel merged commit 5d80128 into main Mar 25, 2026
12 of 13 checks passed
@edgurgel edgurgel deleted the fix/metrics-pusher-send-tenant-metrics branch March 25, 2026 21:08
@realtime-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 2.78.19 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants