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

Plugin should not fail if no statsd server is available #32

Closed
jar349 opened this issue Apr 6, 2021 · 1 comment · Fixed by #33
Closed

Plugin should not fail if no statsd server is available #32

jar349 opened this issue Apr 6, 2021 · 1 comment · Fixed by #33

Comments

@jar349
Copy link
Contributor

jar349 commented Apr 6, 2021

I am developing a service that uses puma and I wish to use this plugin to report statistics to our datadog service via dogstatsd.

Since dogstatsd is only available in our production network, the app cannot reach the server when running locally or in CI. This precludes me from using this plugin right now. In my opinion, it should be possible for this plugin to not crash when no statsd endpoint is available.

Luckily, you provide one! in devtools/statsd-to-stdout.rb, it's possible to run this local to the application. However, the source code of the repo is needed and I don't have it - or won't have it. Because I install this plugin as a gem. Bundler has a mechanism for this, which is the executables configuration in the gemspec. By making your statsd-to-stdout.rb an executable for which a binstub can be installed (bundle binstubs puma-plugins-statsd), the script will be available without needing the repo source code.

Here is how I imagine using that:

if [ -z "$DOGSTATSD_HOST" ]; then
  # since this is not set, we are running locally or in some other non-prod environment so start a local statsd
  nohup ./bin/statsd-to-stdout > statsd.log &
  echo $! > statsd-to-stdout.pid
  echo "A local statsd sink has been started and is logging to statsd.log"
  echo "To stop the local sink, run 'kill \$(cat statsd-to-stdout.pid)'"
else
  # for puma's statsd plugin to find the correct dogstatsd server
  # see: https://github.com/yob/puma-plugin-statsd#usage
  export STATSD_HOST="$DOGSTATSD_HOST"
  export STATSD_PORT="$DOGSTATSD_PORT"
fi
@yob
Copy link
Owner

yob commented Apr 7, 2021

Since dogstatsd is only available in our production network, the app cannot reach the server when running locally or in CI. This precludes me from using this plugin right now. In my opinion, it should be possible for this plugin to not crash when no statsd endpoint is available.

This is surprising to me, what makes the plugin crash?

statsd is UDP so the plugin will happily fire packets at an address that doesn't have statsd/dogstats running. Does it fail fatally when ENV['STATSD_HOST'] is unset? If so, I thought that was fixed in #20 🤔

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 a pull request may close this issue.

2 participants