
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
queue_time_statsd_reporter
Advanced tools
QueueTimeStatsdReporter reports to Datadog the time a request spends queued before hitting your Rails/Rack application.
Add this line to your application's Gemfile:
gem 'queue_time_statsd_reporter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install queue_time_statsd_reporter
In your web server, configure the X-Request-Start header, eg. for Nginx:
location @app {
proxy_set_header X-Request-Start "t=${msec}";
}
Next in Rails create an initialiser containing the code:
metric_name = "mycorp.widgetsapp.queue_time"
tags = ["env:#{Rails.env}"]
Rails.application.middleware.unshift QueueTimeStatsdReporter, my_statsd_object, metric_name, tags
where my_statsd_object
is an object, perhaps a proxy for your statsd implementation, that has a method with signature:
gauge(metric, value, tags=[])
When a request is received QueueTimeStatsdReporter will report the time spent queueing by calling the guage method with:
For instance, if you're reporting to Datadog your object might look something like:
class MyDatadogClass
def initialize(endpoint = Datadog::Statsd.new(ENV.fetch("STATS_HOST", "localhost"), 8125))
@endpoint = endpoint
end
def gauge(metric, value, tags=[], sample_rate=1)
@endpoint.gauge(metric, value, tags: tags, sample_rate: sample_rate)
end
end
and your initialiser:
Rails.application.middleware.unshift QueueTimeStatsdReporter, MyDatadogClass.new, "mycorp.widgetsapp.queue_time", ["env:#{Rails.env}", "infra:aws"]
You can use this middleware outside of Rails too.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/rubytune/queue_time_statsd_reporter.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that queue_time_statsd_reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.