Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report Puma metrics to Datadog #4618

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

colby-swandale
Copy link
Member

@colby-swandale colby-swandale commented Apr 17, 2024

This PR opens up the Puma control/metrics server to expose numerous puma metrics such as num of backlogged requests, active workers, threads, etc for Datadog to collect that allows us to report and monitor.

@colby-swandale colby-swandale changed the title Collect and report Puma metrics to Datadog Report Puma metrics to Datadog Apr 17, 2024
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.11%. Comparing base (6283709) to head (c1df514).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4618   +/-   ##
=======================================
  Coverage   97.11%   97.11%           
=======================================
  Files         393      393           
  Lines        8324     8324           
=======================================
  Hits         8084     8084           
  Misses        240      240           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -42,6 +42,9 @@
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

# Optionally enable the Puma Control/Metrics API
activate_control_app "tcp://127.0.0.1:9293", { auth_token: ENV.fetch("PUMA_CONTROL_AUTH_TOKEN") } if ENV["PUMA_CONTROL_ENABLED"].present?
Copy link
Member

Choose a reason for hiding this comment

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

Two questions.

  1. Are 2 variables needed? Isn't it possible to enable when token is present?
  2. Is token even needed? Is the Metrics API exposed to the public?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are 2 variables needed? Isn't it possible to enable when token is present?

I need to coordinate the release of this for testing and ensuring the integration between Datadog and puma is reliable. Seeing we do not having branch environments, I can only do this with feature flags/environment variables for to enable for staging and production.

Maybe after this PR has been merged we can reduce the flags down into something simpler.

Is token even needed? Is the Metrics API exposed to the public?

The control server also lets you shutdown, restart and manage other process related actions for puma. The port will be exposed within Kubernetes, so i want to ensure the endpoint is well protected from any potential threats.

@segiddins segiddins force-pushed the colby/puma-datadog-monitoring branch from cc46872 to c1df514 Compare May 8, 2024 15:53
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.

None yet

2 participants