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

Fix new relic instrumentation #331

Merged
merged 1 commit into from Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/cequel/metal/new_relic_instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,28 @@ module Metal
module NewRelicInstrumentation
extend ActiveSupport::Concern

define_method :execute_with_options_with_newrelic do |statement, bind_vars, options|
define_method :execute_with_options_with_newrelic do |statement, options|

operation = nil
statement_txt = nil
statement_words = nil

if statement.is_a?(::Cequel::Metal::Statement)
statement_txt = statement.cql
statement_words = statement_txt.split
operation = statement_words.first.downcase
elsif statement.is_a?(::Cassandra::Statements::Batch)
operation = "batch"
end

callback = Proc.new do |result, scoped_metric, elapsed|
NewRelic::Agent::Datastores.notice_statement(statement, elapsed)
NewRelic::Agent::Datastores.notice_statement(statement_txt, elapsed)
end

statement_words = statement.split
operation = statement_words.first.downcase
table = nil
case operation
when "batch"
# Nothing to do
when "begin"
operation = "batch"
when "select"
Expand All @@ -33,7 +46,7 @@ module NewRelicInstrumentation
end

NewRelic::Agent::Datastores.wrap("Cassandra", operation, table, callback) do
execute_with_options_without_newrelic(statement, bind_vars, options)
execute_with_options_without_newrelic(statement, options)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cequel/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*-
module Cequel
# The current version of the library
VERSION = '2.0.1'
VERSION = '2.0.2'
end