This guide will demonstrate using the New Relic Ruby agent to report metrics for Sidekiq jobs being performed by workers. A minimal Ruby on Rails app with a minimal Sidekiq job class will be created.
required
- Ruby
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'async', '~> 2.2' | |
end |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# INSTRUCTIONS: | |
# - Place this file somewhere. It can be called something like `reporter.rb` | |
# | |
# - Either place a newrelic.yml file in the same directory as this file OR | |
# export the NEW_RELIC_LICENSE_KEY and NEW_RELIC_HOST environment variables. | |
# If using a newrelic.yml file, it should look like this: | |
# # newrelic.yml |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# A standalone example of using the New Relic Ruby agent's | |
# NewRelic::Agent.increment_metric public API | |
# | |
# INSTRUCTIONS: | |
# - Place this file somewhere. It can be called something like `increment.rb` | |
# | |
# - Either place a newrelic.yml file in the same directory as this file OR |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# INSTRUCTIONS: | |
# - Place this file somewhere. It can be called something like `test.rb` | |
# | |
# - Either place a newrelic.yml file in the same directory as this file OR | |
# export the NEW_RELIC_LICENSE_KEY environment variable. For a | |
# non-production host, also export the NEW_RELIC_HOST environment variable. | |
# |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# Instructions: | |
# 1. Copy newrelic.yml with a valid license key to the same directory as | |
# standalone.rb | |
# 1. rm -rf log | |
# 2. ruby standalone.rb | |
# 3. inspect log/newrelic_agent.log |
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'webrick' | |
class FakeServlet < WEBrick::HTTPServlet::AbstractServlet | |
RESPONSE_BODY = "Success\n" | |
TEXT_PLAIN = 'text/plain' | |
def do_GET(_request, response) |
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'resque', '1.27.4' | |
gem 'newrelic_rpm' |