Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from arielze/master
add example to newrelic metrics and transaction tracing
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
$: << File.expand_path('../lib', File.dirname(__FILE__)) | ||
require 'sneakers' | ||
require 'sneakers/runner' | ||
require 'sneakers/metrics/newrelic_metrics' | ||
require 'open-uri' | ||
require 'nokogiri' | ||
require 'newrelic_rpm' | ||
|
||
# With this configuration will send two types of data to newrelic server: | ||
# 1. Transaction data which you would see under 'Applications' | ||
# 2. Metrics where you will be able to see by configuring a dashboardi, available for enterprise accounts | ||
# | ||
# You should have newrelic.yml in the 'config' folder with the proper account settings | ||
|
||
Sneakers::Metrics::NewrelicMetrics.eagent ::NewRelic | ||
Sneakers.configure metrics: Sneakers::Metrics::NewrelicMetrics.new | ||
|
||
class MetricsWorker | ||
include Sneakers::Worker | ||
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
|
||
from_queue 'downloads' | ||
|
||
def work(msg) | ||
doc = Nokogiri::HTML(open(msg)) | ||
logger.info "FOUND <#{doc.css('title').text}>" | ||
ack! | ||
end | ||
|
||
add_transaction_tracer :work, name: 'MetricsWorker', params: 'args[0]' | ||
|
||
end | ||
|
||
|
||
r = Sneakers::Runner.new([ MetricsWorker ]) | ||
r.run | ||
|
||
|
||
|
||
|