appoptics_apm 4.11.0 → 4.12.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,8 +12,10 @@ It requires an [AppOptics](https://www.appoptics.com/) account to view metrics.
12
12
  [it's free](https://my.appoptics.com/sign_up).
13
13
 
14
14
  [![Gem Version](https://badge.fury.io/rb/appoptics_apm.svg)](https://badge.fury.io/rb/appoptics_apm)
15
- [![Build Status](https://travis-ci.org/appoptics/appoptics-apm-ruby.png?branch=master)](https://travis-ci.org/appoptics/appoptics-apm-ruby)
16
- [![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability)
15
+
16
+ [comment]: <> ([![Build Status]&#40;https://travis-ci.org/appoptics/appoptics-apm-ruby.png?branch=master&#41;]&#40;https://travis-ci.org/appoptics/appoptics-apm-ruby&#41;)
17
+
18
+ [comment]: <> ([![Maintainability]&#40;https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability&#41;]&#40;https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability&#41;)
17
19
 
18
20
  _Note: The repository is now at https://github.com/appoptics/appoptics-apm-ruby Please update your github remotes with
19
21
  `git remote set-url origin git@github.com:appoptics/appoptics-apm-ruby.git`._
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.version = AppOpticsAPM::Version::STRING
7
7
  s.date = Time.now.strftime('%Y-%m-%d')
8
8
 
9
- s.license = "Librato Open License, Version 1.0, https://bit.ly/2Kmm0mN"
9
+ s.license = "Apache-2.0"
10
10
 
11
11
  s.authors = ["Maia Engeli", "Peter Giacomo Lombardo", "Spiros Eliopoulos"]
12
12
  s.email = %q{support@appoptics.com}
@@ -26,9 +26,10 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
26
26
  s.extra_rdoc_files = ['LICENSE']
27
27
  s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|gemfiles)/}) }
28
28
  s.files += ['ext/oboe_metal/src/oboe.h',
29
- 'ext/oboe_metal/src/oboe.hpp',
29
+ 'ext/oboe_metal/src/oboe_api.cpp',
30
+ 'ext/oboe_metal/src/oboe_api.hpp',
30
31
  'ext/oboe_metal/src/oboe_debug.h',
31
- 'ext/oboe_metal/src/oboe_wrap.cxx',
32
+ 'ext/oboe_metal/src/oboe_swig_wrap.cc',
32
33
  'ext/oboe_metal/src/bson/bson.h',
33
34
  'ext/oboe_metal/src/bson/platform_hacks.h',
34
35
  'ext/oboe_metal/src/VERSION']
@@ -42,21 +43,21 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
42
43
 
43
44
  s.extensions = ['ext/oboe_metal/extconf.rb'] unless defined?(JRUBY_VERSION)
44
45
 
45
- s.add_runtime_dependency('json', '>= 0')
46
+ s.add_runtime_dependency('json')
46
47
  s.add_runtime_dependency('no_proxy_fix', '~> 0.1.2', '>= 0.1.2')
47
48
 
48
49
  # Development dependencies used in gem development & testing
49
- s.add_development_dependency('rake', '>= 0.9.0')
50
- s.add_development_dependency('simplecov', '>= 0.16.0') if ENV["SIMPLECOV_COVERAGE"]
51
- s.add_development_dependency('simplecov-console', '>= 0.4.0') if ENV["SIMPLECOV_COVERAGE"]
52
- s.add_development_dependency('irb', '>= 1.0.0') if RUBY_VERSION >= '2.6.0'
53
-
54
- unless defined?(JRUBY_VERSION)
55
- s.add_development_dependency('byebug', '>= 8.0.0')
56
- s.add_development_dependency('minitest-hooks', '>= 1.5.0')
57
- s.add_development_dependency('minitest-focus', '>=1.1.2')
58
- s.add_development_dependency('benchmark-ips', '>= 2.7.2')
59
- end
50
+ # s.add_development_dependency('rake', '>= 0.9.0')
51
+ # s.add_development_dependency('simplecov', '>= 0.16.0') if ENV["SIMPLECOV_COVERAGE"]
52
+ # s.add_development_dependency('simplecov-console', '>= 0.4.0') if ENV["SIMPLECOV_COVERAGE"]
53
+ # s.add_development_dependency('irb', '>= 1.0.0') if RUBY_VERSION >= '2.6.0'
54
+ #
55
+ # unless defined?(JRUBY_VERSION)
56
+ # s.add_development_dependency('byebug', '>= 8.0.0')
57
+ # s.add_development_dependency('minitest-hooks', '>= 1.5.0')
58
+ # s.add_development_dependency('minitest-focus', '>=1.1.2')
59
+ # s.add_development_dependency('benchmark-ips', '>= 2.7.2')
60
+ # end
60
61
 
61
62
  s.required_ruby_version = '>= 2.4.0'
62
63
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -0,0 +1,142 @@
1
+ # Copyright (c) 2020 SolarWinds, LLC.
2
+ # All rights reserved.
3
+
4
+ ###############################################################
5
+ # SDK EXAMPLES
6
+ ###############################################################
7
+ # The uses cases of the SDK include:
8
+ # - tracing a piece of your own code
9
+ # - tracing a method call of a gem that is not auto-instrumented
10
+ # by appoptics_apm
11
+ #
12
+ # SDK documentation:
13
+ # https://rubydoc.info/gems/appoptics_apm/AppOpticsAPM/SDK
14
+
15
+ ###############################################################
16
+ # Prerequisits
17
+ # export APPOPTICS_SERVICE_KEY=<API token>:<service_name>
18
+ # `bundle exec ruby sdk_examples.rb`
19
+ # 5 traced requests will show up at https://my.appoptics.com/
20
+ ###############################################################
21
+
22
+ require 'appoptics_apm'
23
+
24
+ unless AppOpticsAPM::SDK.appoptics_ready?(10_000)
25
+ puts "aborting!!! Agent not ready after 10 seconds"
26
+ exit false
27
+ end
28
+
29
+ ###############################################################
30
+ ### ADD A SPAN
31
+ ###############################################################
32
+ #
33
+ # AppOpticsAPM::SDK.trace()
34
+ # This method adds a span to a trace that has been started either
35
+ # by the auto-instrumentation of the gem handling incoming requests
36
+ # or the SDK method `start_trace`.
37
+ # If this method is called outside of the context of a started
38
+ # trace no spans will be created.
39
+ #
40
+ # The argument is the name for the span
41
+
42
+ AppOpticsAPM::SDK.trace('span_name') do
43
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
44
+ end
45
+
46
+ ###############################################################
47
+ # START A TRACE, ADD A SPAN, AND LOG AN INFO EVENT
48
+ ###############################################################
49
+ #
50
+ # AppOpticsAPM::SDK.start_trace()
51
+ # This method starts a trace. It is handy for background jobs,
52
+ # workers, or scripts, that are not part of a rack application
53
+
54
+ AppOpticsAPM::SDK.start_trace('outer_span') do
55
+ AppOpticsAPM::SDK.trace('first_child_span') do
56
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
57
+ AppOpticsAPM::SDK.log_info({ some: :fancy, hash: :to, send: 1 })
58
+ end
59
+ end
60
+
61
+ ###############################################################
62
+ # LOG AN ERROR EVENT
63
+ ###############################################################
64
+ #
65
+ # AppOpticsAPM::SDK.log_exception()
66
+ # This method adds an error event to the trace, which will be
67
+ # displayed and counted as exception on the appoptics dashboard.
68
+
69
+ def do_raise
70
+ raise StandardError.new("oops")
71
+ end
72
+
73
+ AppOpticsAPM::SDK.start_trace('with_error') do
74
+ begin
75
+ do_raise
76
+ rescue => e
77
+ AppOpticsAPM::SDK.log_exception(e)
78
+ end
79
+ end
80
+
81
+ ###############################################################
82
+ # TRACE A METHOD
83
+ ###############################################################
84
+ #
85
+ # AppOpticsAPM::SDK.trace_method()
86
+ # This creates a span every time the defined method is run.
87
+ # The method can be of any (accessible) type (instance,
88
+ # singleton, private, protected etc.).
89
+
90
+ module ExampleModule
91
+ def self.do_sum(a, b)
92
+ a + b
93
+ end
94
+ end
95
+
96
+ AppOpticsAPM::SDK.trace_method(ExampleModule,
97
+ :do_sum,
98
+ { name: 'computation', backtrace: true },
99
+ { CustomKey: "some_info"})
100
+
101
+ AppOpticsAPM::SDK.start_trace('trace_a_method') do
102
+ ExampleModule.do_sum(1, 2)
103
+ ExampleModule.do_sum(3, 4)
104
+ end
105
+
106
+ ###############################################################
107
+ # SET A CUSTOM TRANSACTION NAME
108
+ ###############################################################
109
+ #
110
+ # AppOpticsAPM::SDK.set_transaction_name()
111
+ #
112
+ # this method can be called anytime after a trace has been started to add a
113
+ # custom name for the whole transaction.
114
+ # In case of a controller the trace is usually started in rack.
115
+
116
+ class FakeController
117
+ def create(params)
118
+ # @fake = fake.new(params.permit(:type, :title))
119
+ # @fake.save
120
+ AppOpticsAPM::SDK.set_transaction_name("fake.#{params[:type]}")
121
+ # redirect_to @fake
122
+ end
123
+ end
124
+
125
+ AppOpticsAPM::SDK.start_trace('set_transaction_name') do
126
+ FakeController.new.create(type: 'news')
127
+ end
128
+
129
+ ###############################################################
130
+ # LOG INJECTION OF TRACE_ID
131
+ ###############################################################
132
+ #
133
+ # AppOpticsAPM::SDK.current_trace
134
+ # This method creates an object with the current trace ID and
135
+ # helper methods to add the ID to logs for cross-referencing.
136
+
137
+ AppOpticsAPM::Config[:log_traceId] = :always
138
+
139
+ AppOpticsAPM::SDK.start_trace('log_trace_id') do
140
+ trace = AppOpticsAPM::SDK.current_trace
141
+ AppOpticsAPM.logger.warn "Some log message #{trace.for_log}"
142
+ end
@@ -5,7 +5,7 @@ inspired by: https://dev.to/wataash/how-to-create-and-debug-ruby-gem-with-c-nati
5
5
 
6
6
  ## install ruby with sources
7
7
 
8
- rbenv is your friend ;) 😄 -k means keep sources
8
+ rbenv is your friend ;) -k means keep sources
9
9
 
10
10
  ```
11
11
  rbenv install -k 2.6.3
@@ -66,4 +66,4 @@ Some inspiring examples here:
66
66
 
67
67
  https://jvns.ca/blog/2016/06/12/a-weird-system-call-process-vm-readv/
68
68
 
69
- https://medium.com/@zanker/finding-a-ruby-bug-with-gdb-56d6b321bc86
69
+ https://medium.com/@zanker/finding-a-ruby-bug-with-gdb-56d6b321bc86
@@ -8,6 +8,16 @@ require 'rbconfig'
8
8
  require 'open-uri'
9
9
  require 'no_proxy_fix'
10
10
 
11
+ CONFIG['warnflags'] = CONFIG['warnflags'].gsub(/-Wdeclaration-after-statement/, '')
12
+ .gsub(/-Wimplicit-function-declaration/, '')
13
+ .gsub(/-Wimplicit-int/, '')
14
+ .gsub(/-Wno-tautological-compare/, '')
15
+ .gsub(/-Wno-self-assign/, '')
16
+ .gsub(/-Wno-parentheses-equality/, '')
17
+ .gsub(/-Wno-constant-logical-operand/, '')
18
+ .gsub(/-Wno-cast-function-type/, '')
19
+ init_mkmf(CONFIG)
20
+
11
21
  ext_dir = File.expand_path(File.dirname(__FILE__))
12
22
 
13
23
  # Check if we're running in JRuby
@@ -21,7 +31,7 @@ ao_include = File.join(ext_dir, 'src')
21
31
  # Download the appropriate liboboe from S3(via rake for testing) or files.appoptics.com (production)
22
32
  version = File.read(File.join(ao_include, 'VERSION')).chomp
23
33
  if ENV['APPOPTICS_FROM_S3'].to_s.downcase == 'true'
24
- ao_path = File.join('https://s3-us-west-2.amazonaws.com/rc-files-t2/c-lib/', version)
34
+ ao_path = File.join('https://rc-files-t2.s3-us-west-2.amazonaws.com/c-lib/', version)
25
35
  puts 'Fetching c-lib from S3'
26
36
  else
27
37
  ao_path = File.join('https://files.appoptics.com/c-lib', version)
@@ -29,7 +39,13 @@ end
29
39
 
30
40
  ao_arch = 'x86_64'
31
41
  if File.exist?('/etc/alpine-release')
32
- version = open('/etc/alpine-release').read.chomp
42
+
43
+ if RUBY_VERSION < '2.5.0'
44
+ version = open('/etc/alpine-release').read.chomp
45
+ else
46
+ version = URI.open('/etc/alpine-release').read.chomp
47
+ end
48
+
33
49
  ao_arch =
34
50
  if Gem::Version.new(version) < Gem::Version.new('3.9')
35
51
  'alpine-libressl-x86_64'
@@ -48,11 +64,16 @@ success = false
48
64
  while retries > 0
49
65
  begin
50
66
  # download
51
- download = open(ao_item, 'rb')
67
+ if RUBY_VERSION < '2.5.0'
68
+ download = open(ao_item, 'rb')
69
+ checksum = open(ao_checksum_item, 'r').read.chomp
70
+ else
71
+ download = URI.open(ao_item, 'rb')
72
+ checksum = URI.open(ao_checksum_item, 'r').read.chomp
73
+ end
52
74
  IO.copy_stream(download, clib)
53
-
54
- checksum = open(ao_checksum_item, 'r').read.chomp
55
75
  clib_checksum = Digest::SHA256.file(clib).hexdigest
76
+ download.close
56
77
 
57
78
  # verify_checksum
58
79
  if clib_checksum != checksum
@@ -75,7 +96,7 @@ while retries > 0
75
96
  $stderr.puts 'Download of the c-extension for the appoptics_apm gem failed.'
76
97
  $stderr.puts 'appoptics_apm will not instrument the code. No tracing will occur.'
77
98
  $stderr.puts 'Contact support@appoptics.com if the problem persists.'
78
- $stderr.puts "error:\n#{e.message}"
99
+ $stderr.puts "error: #{ao_item}\n#{e.message}"
79
100
  $stderr.puts '==================================================================='
80
101
  create_makefile('oboe_noop', 'noop')
81
102
  end
@@ -105,11 +126,21 @@ if success
105
126
  $libs = append_library($libs, 'stdc++')
106
127
 
107
128
  $CFLAGS << " #{ENV['CFLAGS']}"
108
- $CPPFLAGS << " #{ENV['CPPFLAGS']}"
129
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11"
130
+ # TODO for debugging: -pg -gdwarf-2, remove for production
131
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -pg -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/include -I$$ORIGIN/../ext/oboe_metal/src"
132
+ $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/include"
109
133
  $LIBS << " #{ENV['LIBS']}"
110
- $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib'"
134
+ $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib' -pg -lrt"
135
+ # $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib'"
136
+ $CXXFLAGS += " -std=c++11 "
137
+
138
+ # ____ include debug info, comment out when not debugging
139
+ # ____ -pg -> profiling info for gprof
140
+ # CONFIG["debugflags"] = "-ggdb3 -pg"
141
+ # CONFIG["optflags"] = "-O0"
111
142
 
112
- create_makefile('oboe_metal', 'src')
143
+ create_makefile('libappoptics_apm', 'src')
113
144
 
114
145
  else
115
146
  $stderr.puts '== ERROR ========================================================='
@@ -1 +1 @@
1
- 7.1.0
1
+ 10.1.0
@@ -0,0 +1,20 @@
1
+ #include <iostream>
2
+
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ void Init_oboe_metal(void);
8
+
9
+ //void Init_profiling(void);
10
+
11
+ void Init_libappoptics_apm() {
12
+ Init_oboe_metal();
13
+ // std::cout << "*** oboe_metal initialized ***" << std::endl;
14
+ // Init_profiling();
15
+ // std::cout << "*** profiling intitialized ***" << std::endl;
16
+ }
17
+
18
+ #ifdef __cplusplus
19
+ }
20
+ #endif
data/lib/appoptics_apm.rb CHANGED
@@ -20,7 +20,7 @@ begin
20
20
  require '/usr/local/tracelytics/tracelyticsagent.jar'
21
21
  require 'joboe_metal'
22
22
  elsif RUBY_PLATFORM =~ /linux/
23
- require_relative './oboe_metal.so'
23
+ require_relative './libappoptics_apm.so'
24
24
  require 'appoptics_apm/oboe_init_options'
25
25
  require 'oboe_metal.rb' # sets AppOpticsAPM.loaded = true if successful
26
26
  else
@@ -22,9 +22,12 @@ module AppOpticsAPM
22
22
  start = Time.now
23
23
  yield
24
24
  ensure
25
+ # TODO send_metrics is currently used in grpc, sdk
26
+ # ____ the error (0,1) would have to be returned from yield
27
+ error = 0
25
28
  duration = (1000 * 1000 * (Time.now - start)).to_i
26
29
  transaction_name = determine_transaction_name(span, kvs)
27
- kvs[:TransactionName] = AppOpticsAPM::Span.createSpan(transaction_name, nil, duration)
30
+ kvs[:TransactionName] = AppOpticsAPM::Span.createSpan(transaction_name, nil, duration, error)
28
31
  AppOpticsAPM.transaction_name = nil
29
32
  end
30
33
 
@@ -45,6 +48,8 @@ module AppOpticsAPM
45
48
  AppOpticsAPM.transaction_name
46
49
  elsif kvs['Controller'] && kvs['Action']
47
50
  [kvs['Controller'], kvs['Action']].join('.')
51
+ elsif kvs[:Controller] && kvs[:Action]
52
+ [kvs[:Controller], kvs[:Action]].join('.')
48
53
  else
49
54
  "custom-#{span}"
50
55
  end
@@ -52,4 +57,4 @@ module AppOpticsAPM
52
57
 
53
58
  end
54
59
  end
55
- end
60
+ end
@@ -65,15 +65,16 @@ module AppOpticsAPM
65
65
  config_file = File.join(Dir.pwd, 'appoptics_apm_config.rb')
66
66
  config_files << config_file if File.exist?(config_file)
67
67
 
68
- return if config_files.empty? # we use the defaults from the template in this case
69
-
70
- if config_files.size > 1
71
- AppOpticsAPM.logger.warn [
72
- '[appoptics_apm/config] Multiple configuration files configured, using the first one listed: ',
73
- config_files.join(', ')
74
- ].join(' ')
68
+ unless config_files.empty? # we use the defaults from the template if there are no config files
69
+ if config_files.size > 1
70
+ AppOpticsAPM.logger.warn [
71
+ '[appoptics_apm/config] Multiple configuration files configured, using the first one listed: ',
72
+ config_files.join(', ')
73
+ ].join(' ')
74
+ end
75
+ load(config_files[0])
75
76
  end
76
- load(config_files[0])
77
+
77
78
  # sets AppOpticsAPM::Config[:debug_level], AppOpticsAPM.logger.level
78
79
  set_log_level
79
80
 
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) 2016 SolarWinds, LLC.
2
2
  # All rights reserved.
3
3
 
4
+ require_relative '../../../lib/appoptics_apm/inst/logger_formatter'
5
+
4
6
  module AppOpticsAPM
5
7
  module Rails
6
8
  module Helpers
@@ -75,6 +77,10 @@ if defined?(::Rails)
75
77
  AppOpticsAPM::Rails.include_helpers
76
78
  end
77
79
 
80
+ initializer 'appoptics_apm.controller', before: 'wicked_pdf.register' do
81
+ AppOpticsAPM::Rails.load_instrumentation
82
+ end
83
+
78
84
  initializer 'appoptics_apm.rack' do |app|
79
85
  AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting rack' if AppOpticsAPM::Config[:verbose]
80
86
  app.config.middleware.insert 0, AppOpticsAPM::Rack
@@ -84,7 +90,7 @@ if defined?(::Rails)
84
90
  AppOpticsAPM.logger = ::Rails.logger if ::Rails.logger && !ENV.key?('APPOPTICS_GEM_TEST')
85
91
 
86
92
  AppOpticsAPM::Inst.load_instrumentation
87
- AppOpticsAPM::Rails.load_instrumentation
93
+ # AppOpticsAPM::Rails.load_instrumentation
88
94
 
89
95
  # Report __Init after fork when in Heroku
90
96
  AppOpticsAPM::API.report_init unless AppOpticsAPM.heroku?
@@ -6,35 +6,78 @@ if defined?(ActionView::Base) && AppOpticsAPM::Config[:action_view][:enabled]
6
6
  if Rails::VERSION::MAJOR >= 4
7
7
 
8
8
  AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting actionview' if AppOpticsAPM::Config[:verbose]
9
+ if ActionView.version >= Gem::Version.new('6.1.0') # the methods changed in this version
9
10
 
10
- ActionView::PartialRenderer.class_eval do
11
- alias :render_partial_without_appoptics :render_partial
12
- def render_partial(*args)
13
- entry_kvs = {}
14
- begin
15
- entry_kvs[:Partial] = AppOpticsAPM::Util.prettify(@options[:partial]) if @options.is_a?(Hash)
16
- rescue => e
17
- AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
11
+ ActionView::PartialRenderer.class_eval do
12
+ alias :render_partial_template_without_appoptics :render_partial_template
13
+
14
+ def render_partial_template(*args)
15
+ _, _, template, _, _ = args
16
+ entry_kvs = {}
17
+ begin
18
+ entry_kvs[:Partial] = template.virtual_path
19
+ rescue => e
20
+ AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
21
+ end
22
+ AppOpticsAPM::SDK.trace(:partial, entry_kvs) do
23
+ entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
24
+ render_partial_template_without_appoptics(*args)
25
+ end
18
26
  end
27
+ end
28
+
29
+ ActionView::CollectionRenderer.class_eval do
30
+ alias :render_collection_without_appoptics :render_collection
19
31
 
20
- AppOpticsAPM::SDK.trace('partial', entry_kvs) do
21
- entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
22
- render_partial_without_appoptics(*args)
32
+ def render_collection(*args)
33
+ _, _, _, template, _, _ = args
34
+ entry_kvs = {}
35
+ begin
36
+ entry_kvs[:Partial] = template.virtual_path
37
+ rescue => e
38
+ AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
39
+ end
40
+ AppOpticsAPM::SDK.trace(:collection, entry_kvs) do
41
+ entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
42
+ render_collection_without_appoptics(*args)
43
+ end
23
44
  end
24
45
  end
25
46
 
26
- alias :render_collection_without_appoptics :render_collection
27
- def render_collection(*args)
28
- entry_kvs = {}
29
- begin
30
- entry_kvs[:Partial] = AppOpticsAPM::Util.prettify(@path)
31
- rescue => e
32
- AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
47
+ else # Rails < 6.1.0
48
+
49
+ ActionView::PartialRenderer.class_eval do
50
+ alias :render_partial_without_appoptics :render_partial
51
+ def render_partial(*args)
52
+ template = @template || args[1]
53
+ entry_kvs = {}
54
+ begin
55
+ entry_kvs[:Partial] = template.virtual_path
56
+ # entry_kvs[:Partial] = AppOpticsAPM::Util.prettify(@options[:partial]) if @options.is_a?(Hash)
57
+ rescue => e
58
+ AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
59
+ end
60
+
61
+ AppOpticsAPM::SDK.trace('partial', entry_kvs) do
62
+ entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
63
+ render_partial_without_appoptics(*args)
64
+ end
33
65
  end
34
66
 
35
- AppOpticsAPM::SDK.trace('collection', entry_kvs) do
36
- entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
37
- render_collection_without_appoptics(*args)
67
+ alias :render_collection_without_appoptics :render_collection
68
+ def render_collection(*args)
69
+ template = @template || args[1]
70
+ entry_kvs = {}
71
+ begin
72
+ entry_kvs[:Partial] = template.virtual_path
73
+ rescue => e
74
+ AppOpticsAPM.logger.debug "[appoptics_apm/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if AppOpticsAPM::Config[:verbose]
75
+ end
76
+
77
+ AppOpticsAPM::SDK.trace('collection', entry_kvs) do
78
+ entry_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_view][:collect_backtraces]
79
+ render_collection_without_appoptics(*args)
80
+ end
38
81
  end
39
82
  end
40
83