solarwinds_apm 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'comment'
4
-
5
- module SolarWindsAPM
6
- module SWOMarginalia
7
- mattr_accessor :application_name
8
-
9
- # This ActiveRecordInstrumentation should only work for activerecord < 7.0 since after rails 7
10
- # this module won't be prepend to activerecord
11
- module ActiveRecordInstrumentation
12
- def execute(sql, *args, **options)
13
- super(annotate_sql(sql), *args, **options)
14
- end
15
-
16
- # only for postgresql adapter
17
- def execute_and_clear(sql, *args, **options)
18
- super(annotate_sql(sql), *args, **options)
19
- end
20
-
21
- def exec_query(sql, *args, **options)
22
- super(annotate_sql(sql), *args, **options)
23
- end
24
-
25
- def exec_delete(sql, *args)
26
- super(annotate_sql(sql), *args)
27
- end
28
-
29
- def exec_update(sql, *args)
30
- super(annotate_sql(sql), *args)
31
- end
32
-
33
- def annotate_sql(sql)
34
- SWOMarginalia::Comment.update_adapter!(self) # switch to current sql adapter
35
- comment = SWOMarginalia::Comment.construct_comment # comment will include traceparent
36
- if comment.present? && !sql.include?(comment)
37
- sql = if SWOMarginalia::Comment.prepend_comment
38
- "/*#{comment}*/ #{sql}"
39
- else
40
- "#{sql} /*#{comment}*/"
41
- end
42
- end
43
-
44
- inline_comment = SWOMarginalia::Comment.construct_inline_comment # this is for customized_swo_inline_annotations (user-defined value)
45
- if inline_comment.present? && !sql.include?(inline_comment)
46
- sql = if SWOMarginalia::Comment.prepend_comment
47
- "/*#{inline_comment}*/ #{sql}"
48
- else
49
- "#{sql} /*#{inline_comment}*/"
50
- end
51
- end
52
-
53
- sql
54
- end
55
-
56
- # We don't want to trace framework caches.
57
- # Only instrument SQL that directly hits the database.
58
- def ignore_payload?(name)
59
- %w[SCHEMA EXPLAIN CACHE].include?(name.to_s)
60
- end
61
- end
62
-
63
- module ActionControllerInstrumentation
64
- def self.included(instrumented_class)
65
- instrumented_class.class_eval do
66
- if respond_to?(:around_action)
67
- around_action :record_query_comment
68
- else
69
- around_filter :record_query_comment
70
- end
71
- end
72
- end
73
-
74
- def record_query_comment
75
- SWOMarginalia::Comment.update!(self)
76
- yield
77
- ensure
78
- SWOMarginalia::Comment.clear!
79
- end
80
- end
81
-
82
- def self.with_annotation(comment, &block)
83
- SWOMarginalia::Comment.inline_annotations.push(comment)
84
- yield if block.present?
85
- ensure
86
- SWOMarginalia::Comment.inline_annotations.pop
87
- end
88
- end
89
- end