Created
July 12, 2013 00:56
-
-
Save chendo/5980584 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Metrics | |
extend ::NewRelic::Agent::MethodTracer | |
class << self | |
def trace_execution(*metric_names, &block) | |
Benchmark.realtime do | |
self.trace_execution_scoped(metric_names.map { |name| prepend_custom_tag(name) }, &block) | |
end | |
end | |
def record_metric(metric_name, value = 1) | |
NewRelic::Agent.record_metric(prepend_custom_tag(metric_name), value) | |
end | |
def increment_metric(metric_name, amount = 1) | |
NewRelic::Agent.increment_metric(prepend_custom_tag(metric_name), amount) | |
end | |
private | |
def prepend_custom_tag(metric_name) | |
"Custom/#{metric_name}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment