Permalink
Browse files

vendor metric parser gem

  • Loading branch information...
1 parent a249d0e commit 2eed5bcb14387a228d84dfabc634458f80410b7a Justin George committed with jaggederest Aug 24, 2010
Showing with 1,533 additions and 227 deletions.
  1. +5 −0 lib/conditional_vendored_metric_parser.rb
  2. +0 −1 lib/new_relic/agent.rb
  3. +2 −0 lib/new_relic/agent/error_collector.rb
  4. +2 −0 lib/new_relic/control.rb
  5. +0 −226 test/new_relic/metric_parser_test.rb
  6. +116 −0 vendor/gems/metric_parser-0.1.0.pre1/.specification
  7. 0 vendor/gems/metric_parser-0.1.0.pre1/LICENSE
  8. 0 vendor/gems/metric_parser-0.1.0.pre1/README
  9. +1 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb
  10. +65 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb
  11. +14 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb
  12. +31 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb
  13. +33 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb
  14. +89 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb
  15. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb
  16. +46 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb
  17. +67 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb
  18. +43 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb
  19. +17 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb
  20. +48 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb
  21. +24 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb
  22. +28 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb
  23. +17 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb
  24. +11 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb
  25. +55 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb
  26. +40 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb
  27. +20 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb
  28. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb
  29. +31 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb
  30. +17 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb
  31. +34 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb
  32. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb
  33. +55 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb
  34. +122 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb
  35. +27 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb
  36. +40 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb
  37. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb
  38. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb
  39. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb
  40. +7 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb
  41. +27 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb
  42. +15 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb
  43. +54 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb
  44. +6 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb
  45. +6 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb
  46. +20 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb
  47. +20 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb
  48. +5 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb
  49. +66 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
  50. +18 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb
  51. +14 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb
  52. +133 −0 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb
@@ -0,0 +1,5 @@
+unless defined?(NewRelic) && defined?(NewRelic::MetricParser)
+ vendored_metric_parser = File.expand_path('../../vendor/gems/metric_parser-0.1.0.pre1/lib/', __FILE__)
+ $:.unshift vendored_metric_parser unless $:.include?(vendored_metric_parser)
+ require 'metric_parser'
+end
View
@@ -63,7 +63,6 @@ module Agent
require 'new_relic/metrics'
require 'new_relic/metric_spec'
require 'new_relic/metric_data'
- require 'new_relic/metric_parser'
require 'new_relic/collection_helper'
require 'new_relic/transaction_analysis'
require 'new_relic/transaction_sample'
@@ -105,6 +105,8 @@ def notice_error(exception, options={})
end
end
exception
+ rescue Exception => e
+ log.error("Error capturing an error, yodawg. #{e}")
end
# Get the errors currently queued up. Unsent errors are left
View
@@ -93,6 +93,8 @@ def newrelic_root
# is called one or more times.
#
def init_plugin(options={})
+ require 'conditional_vendored_metric_parser'
+
options['app_name'] = ENV['NEWRELIC_APP_NAME'] if ENV['NEWRELIC_APP_NAME']
require 'new_relic/agent'
@@ -1,226 +0,0 @@
-ENV['SKIP_RAILS'] = 'true'
-require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
-
-class MetricParserTest < Test::Unit::TestCase
-
- def test_memcache
- m = NewRelic::MetricParser::MetricParser.for_metric_named "MemCache/read"
- assert_equal "MemCache read", m.developer_name
- end
-
- def test_memcache__all
- m = NewRelic::MetricParser::MetricParser.for_metric_named "MemCache/all"
- assert_equal "MemCache All Operations", m.developer_name
- assert_equal "All Operations", m.operation
- end
-
- def test_view__short
- i = NewRelic::MetricParser::MetricParser.parse("View/.rhtml Processing")
- assert_equal "ERB compilation", i.developer_name
- end
- def test_controller
- ["Controller", "Controller/1/2/3","Controller//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
- assert m.is_controller?
- assert !m.is_view?
- assert !m.is_database?
- assert !m.is_web_service?
- end
-
- ["Controller+1/2/3","Lew//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_controller?
- end
- end
-
- def test_controller_cpu
- ["Controller/1/2/3","Controller//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert m.is_controller?
- assert !m.is_view?
- assert !m.is_database?
- assert !m.is_web_service?
- end
-
- ["ControllerCPU/1/2/3","ControllerCPU//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert m.is_controller_cpu?
- assert !m.is_view?
- assert !m.is_controller?
- assert !m.is_database?
- assert !m.is_web_service?
-
- assert_not_nil m.base_metric_name
- assert_equal 0, m.base_metric_name.index('Controller/')
- end
-
- end
-
- def test_web_service
- ["WebService/x/Controller/", "WebService","WebService/1/2/3","WebService//!!#!//"].each do |metric_name|
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_controller?
- assert !m.is_view?
- assert !m.is_database?
- assert m.is_web_service?
- end
-
- ["Web/Service","WEBService+1/2/3","Lew//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_web_service?, metric_name
- end
- end
-
- def test_database
- ["ActiveRecord","ActiveRecord/1/2/3","ActiveRecord//!!#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_view?
- assert !m.is_controller?
- assert m.is_active_record?, "#{metric_name}: #{m.category}"
- assert !m.is_web_service?
- end
-
- ["ActiveRecordxx","ActiveRecord+1/2/3","ActiveRecord#!//"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_database?
- end
- end
- def test_view
- %w[View/posts/post/Rendering View/admin/users/view/Partial View/ERB/Compile].each do | name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(name)
- assert !m.is_database?
- assert !m.is_controller?
- assert !m.is_web_service?
- assert !m.is_error?
- assert m.is_view?
- end
- end
- def test_view__render
- m = NewRelic::MetricParser::MetricParser.parse "View/blogs/show.html.erb/Rendering"
-
- short_name = "show.html.erb Template"
- long_name = "blogs/show.html.erb Template"
- assert_equal short_name, m.pie_chart_label
- assert_equal long_name, m.developer_name
- assert_equal short_name, m.pie_chart_label
- assert_equal "blogs/show.html.erb Template", m.controller_name
- assert_equal "show", m.action_name
- assert_equal "/blogs/show.html.erb", m.url
- end
- def test_view__partial
- m = NewRelic::MetricParser::MetricParser.for_metric_named "View/admin/users/view.html.erb/Partial"
- m.pie_chart_label
- assert_equal "view.html.erb Partial", m.pie_chart_label
- assert_equal "admin/users/view.html.erb Partial", m.developer_name
- assert_equal "admin/users/view.html.erb Partial", m.controller_name
- assert_equal "view", m.action_name
- assert_equal "/admin/users/view.html.erb", m.url
- end
- def test_view__rhtml
- m = NewRelic::MetricParser::MetricParser.for_metric_named "View/admin/users/view.rhtml/Rendering"
- m.pie_chart_label
- assert_equal "view.rhtml Template", m.pie_chart_label
- assert_equal "admin/users/view.rhtml Template", m.developer_name
- assert_equal "admin/users/view.rhtml Template", m.controller_name
- assert_equal "view", m.action_name
- assert_equal "/admin/users/view.rhtml", m.url
- end
- def test_error
- ["Errors","Errors/Type/MyType","Errors/Controller/MyController/"].each do | metric_name |
- m = NewRelic::MetricParser::MetricParser.for_metric_named(metric_name)
-
- assert !m.is_database?
- assert !m.is_controller?
- assert !m.is_web_service?
- assert !m.is_view?
- assert m.is_error?
- end
-
- m = NewRelic::MetricParser::MetricParser.for_metric_named("Errors/Type/MyType")
- assert_equal m.short_name, 'MyType'
- end
- def test_external
- m = NewRelic::MetricParser::MetricParser.for_metric_named("External/all")
- assert m.all?
- assert !m.hosts_all?
- assert_equal "All External", m.developer_name
- assert_equal "calls to external systems", m.tooltip_name
- assert_equal "External Services", m.legend_name
- assert_nil m.operation
- assert_nil m.library
-
- m = NewRelic::MetricParser::MetricParser.for_metric_named("External/venus/all")
- assert !m.all?
- assert m.hosts_all?
- assert_equal "venus", m.developer_name
- assert_equal "calls to venus", m.tooltip_name
- assert_equal "All venus calls", m.legend_name
- assert_nil m.operation
- assert_equal 'all', m.library
-
- m = NewRelic::MetricParser::MetricParser.for_metric_named("External/venus/Net::Http/get")
- assert !m.all?
- assert !m.hosts_all?
- assert_equal "Net::Http[venus]: get", m.developer_name
- assert_equal "calls to Net::Http[venus]: get", m.tooltip_name
- assert_equal "Net::Http[venus]: get", m.legend_name
- assert_equal 'get', m.operation
- assert_equal 'Net::Http', m.library
-
-
- end
-
- context "with apdex" do
-
- context "client" do
- setup do
- @client_name = NewRelic::MetricParser::Apdex.client_metric(NewRelic::Control.instance.apdex_t)
- @apdex_client = NewRelic::MetricParser::MetricParser.for_metric_named(@client_name)
- end
- should "produce a client metric name" do
- assert_equal "Apdex/Client/#{NewRelic::Control.instance.apdex_t}", @client_name
- end
- should "display the apdex value in " do
- assert_equal "Apdex Client (1.1)", @apdex_client.developer_name
- end
- should "act like a client score" do
- assert ! @apdex_client.is_summary?
- assert @apdex_client.is_client?
- end
- should "display nicely" do
- assert_equal "Apdex Client (#{NewRelic::Control.instance.apdex_t})", @apdex_client.developer_name
- end
-
- end
-
- context "summary" do
- setup do
- @apdex_summary = NewRelic::MetricParser::MetricParser.for_metric_named('Apdex')
- end
-
- should "act like a summary" do
- assert @apdex_summary.is_summary?
- assert ! @apdex_summary.is_client?
- end
- end
- context "controller score" do
- setup do
- @controller_apdex = NewRelic::MetricParser::MetricParser.for_metric_named('Apdex/sessions/guest_index')
- end
- should "act like a controller" do
- assert ! @controller_apdex.is_summary?
- assert ! @controller_apdex.is_client?
- end
- should "display nicely" do
- assert_equal "Apdex sessions/guest_index", @controller_apdex.developer_name
- end
- end
- end
-end
@@ -0,0 +1,116 @@
+--- !ruby/object:Gem::Specification
+name: metric_parser
+version: !ruby/object:Gem::Version
+ hash: 270495464
+ prerelease: true
+ segments:
+ - 0
+ - 1
+ - 0
+ - pre1
+ version: 0.1.0.pre1
+platform: ruby
+authors:
+- Justin George
+autorequire:
+bindir: bin
+cert_chain: []
+
+date: 2010-08-12 00:00:00 +00:00
+default_executable:
+dependencies: []
+
+description: A standard way to parse New Relic metric names
+email:
+- justin@newrelic.com
+executables: []
+
+extensions: []
+
+extra_rdoc_files: []
+
+files:
+- lib/metric_parser.rb
+- lib/new_relic/metric_parser/action_mailer.rb
+- lib/new_relic/metric_parser/active_merchant.rb
+- lib/new_relic/metric_parser/active_record.rb
+- lib/new_relic/metric_parser/apdex.rb
+- lib/new_relic/metric_parser/background_transaction.rb
+- lib/new_relic/metric_parser/client.rb
+- lib/new_relic/metric_parser/controller.rb
+- lib/new_relic/metric_parser/controller_cpu.rb
+- lib/new_relic/metric_parser/controller_ext.rb
+- lib/new_relic/metric_parser/database.rb
+- lib/new_relic/metric_parser/database_pool.rb
+- lib/new_relic/metric_parser/dot_net.rb
+- lib/new_relic/metric_parser/dot_net_parser.rb
+- lib/new_relic/metric_parser/errors.rb
+- lib/new_relic/metric_parser/external.rb
+- lib/new_relic/metric_parser/frontend.rb
+- lib/new_relic/metric_parser/gc.rb
+- lib/new_relic/metric_parser/hibernate_session.rb
+- lib/new_relic/metric_parser/java.rb
+- lib/new_relic/metric_parser/java_parser.rb
+- lib/new_relic/metric_parser/jsp.rb
+- lib/new_relic/metric_parser/jsp_tag.rb
+- lib/new_relic/metric_parser/mem_cache.rb
+- lib/new_relic/metric_parser/metric_parser.rb
+- lib/new_relic/metric_parser/orm.rb
+- lib/new_relic/metric_parser/other_transaction.rb
+- lib/new_relic/metric_parser/servlet.rb
+- lib/new_relic/metric_parser/servlet_context_listener.rb
+- lib/new_relic/metric_parser/servlet_filter.rb
+- lib/new_relic/metric_parser/servlet_init.rb
+- lib/new_relic/metric_parser/solr.rb
+- lib/new_relic/metric_parser/solr_request_handler.rb
+- lib/new_relic/metric_parser/spring.rb
+- lib/new_relic/metric_parser/spring_controller.rb
+- lib/new_relic/metric_parser/spring_view.rb
+- lib/new_relic/metric_parser/struts_action.rb
+- lib/new_relic/metric_parser/struts_result.rb
+- lib/new_relic/metric_parser/version.rb
+- lib/new_relic/metric_parser/view.rb
+- lib/new_relic/metric_parser/web_frontend.rb
+- lib/new_relic/metric_parser/web_service.rb
+- lib/new_relic/metric_parser/web_transaction.rb
+- lib/new_relic/metric_parser.rb
+- LICENSE
+- README
+has_rdoc: true
+homepage: http://www.newrelic.com
+licenses: []
+
+post_install_message:
+rdoc_options: []
+
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+required_rubygems_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 31
+ segments:
+ - 1
+ - 2
+ - 0
+ version: 1.2.0
+requirements: []
+
+rubyforge_project:
+rubygems_version: 1.3.7
+signing_key:
+specification_version: 3
+summary: A standard way to parse New Relic metric names
+test_files: []
+
@@ -0,0 +1 @@
+require 'new_relic/metric_parser'
Oops, something went wrong.

0 comments on commit 2eed5bc

Please sign in to comment.