solarwinds_apm 6.0.0.preV1 → 6.0.0.preV3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +28 -54
  3. data/ext/oboe_metal/extconf.rb +23 -23
  4. data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
  5. data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
  6. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
  7. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
  8. data/ext/oboe_metal/src/VERSION +1 -2
  9. data/ext/oboe_metal/src/init_solarwinds_apm.cc +0 -6
  10. data/ext/oboe_metal/src/oboe.h +0 -12
  11. data/ext/oboe_metal/src/oboe_swig_wrap.cc +5 -5
  12. data/lib/oboe_metal.rb +3 -3
  13. data/lib/rails/generators/solarwinds_apm/install_generator.rb +0 -3
  14. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +8 -25
  15. data/lib/solarwinds_apm/api/current_trace_info.rb +1 -2
  16. data/lib/solarwinds_apm/api/opentelemetry.rb +39 -0
  17. data/lib/solarwinds_apm/api/transaction_name.rb +18 -17
  18. data/lib/solarwinds_apm/api.rb +2 -0
  19. data/lib/solarwinds_apm/config.rb +21 -63
  20. data/lib/solarwinds_apm/constants.rb +2 -4
  21. data/lib/solarwinds_apm/noop/context.rb +1 -1
  22. data/lib/solarwinds_apm/oboe_init_options.rb +11 -16
  23. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +92 -87
  24. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +27 -23
  25. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +28 -28
  26. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +9 -14
  27. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +132 -175
  28. data/lib/solarwinds_apm/otel_config.rb +55 -36
  29. data/lib/solarwinds_apm/support/lumberjack_formatter.rb +17 -2
  30. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +2 -2
  31. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +6 -5
  32. data/lib/solarwinds_apm/support/transaction_cache.rb +27 -2
  33. data/lib/solarwinds_apm/support/transaction_settings.rb +10 -10
  34. data/lib/solarwinds_apm/support/txn_name_manager.rb +34 -17
  35. data/lib/solarwinds_apm/support/utils.rb +24 -0
  36. data/lib/solarwinds_apm/support.rb +4 -2
  37. data/lib/solarwinds_apm/version.rb +1 -1
  38. data/lib/solarwinds_apm.rb +3 -4
  39. metadata +18 -33
  40. data/lib/oboe.rb +0 -7
  41. data/lib/solarwinds_apm/noop/profiling.rb +0 -17
  42. data/lib/solarwinds_apm/support/transformer.rb +0 -56
@@ -7,12 +7,13 @@ module SolarWindsAPM
7
7
  # This ActiveRecordInstrumentation should only work for activerecord < 7.0 since after rails 7
8
8
  # this module won't be prepend to activerecord
9
9
  module ActiveRecordInstrumentation
10
- def execute(sql, *args)
11
- super(annotate_sql(sql), *args)
10
+ def execute(sql, *args, **options)
11
+ super(annotate_sql(sql), *args, **options)
12
12
  end
13
13
 
14
- def execute_and_clear(sql, *args, &block)
15
- super(annotate_sql(sql), *args, &block)
14
+ # only for postgresql adapter
15
+ def execute_and_clear(sql, *args, **options)
16
+ super(annotate_sql(sql), *args, **options)
16
17
  end
17
18
 
18
19
  def exec_query(sql, *args, **options)
@@ -53,7 +54,7 @@ module SolarWindsAPM
53
54
  # We don't want to trace framework caches.
54
55
  # Only instrument SQL that directly hits the database.
55
56
  def ignore_payload?(name)
56
- %w(SCHEMA EXPLAIN CACHE).include?(name.to_s)
57
+ %w[SCHEMA EXPLAIN CACHE].include?(name.to_s)
57
58
  end
58
59
  end
59
60
 
@@ -1,21 +1,46 @@
1
1
  module SolarWindsAPM
2
- # Simple TransactionCache
3
- # TODO: improve cache to have lru mechanism that avoid too many values
2
+ # LRU TransactionCache with initial limit 1000
4
3
  module TransactionCache
4
+ attr_reader :capacity
5
+
5
6
  def self.initialize
7
+ @capacity = 1000
6
8
  @cache = {}
9
+ @order = []
7
10
  end
8
11
 
9
12
  def self.get(key)
13
+ return nil unless @cache.has_key?(key)
14
+
15
+ @order.delete(key)
16
+ @order.push(key)
10
17
  @cache[key]
11
18
  end
12
19
 
13
20
  def self.del(key)
14
21
  @cache.delete(key)
22
+ @order.delete(key)
23
+ end
24
+
25
+ def self.clear
26
+ @cache.clear
27
+ @order.clear
28
+ end
29
+
30
+ def self.size
31
+ @cache.size
15
32
  end
16
33
 
17
34
  def self.set(key, value)
35
+ if @cache.has_key?(key)
36
+ @cache.delete(key)
37
+ elsif @order.size >= @capacity
38
+ evict_key = @order.shift
39
+ @cache.delete(evict_key)
40
+ end
41
+
18
42
  @cache[key] = value
43
+ @order.push(key)
19
44
  SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] current TransactionCache #{@cache.inspect}"}
20
45
  end
21
46
  end
@@ -9,14 +9,14 @@ module SolarWindsAPM
9
9
  SWO_TRACING_ENABLED = 1
10
10
  SWO_TRACING_DISABLED = 0
11
11
 
12
- def initialize(url: '', name: '', kind: '')
13
- @url = url
14
- @name = name
15
- @kind = kind
12
+ def initialize(url_path: '', name: '', kind: '')
13
+ @url_path = url_path
14
+ @name = name
15
+ @kind = kind
16
16
  end
17
17
 
18
- # calculate trace mode to set either 1 or 0 based on url and name+kind
19
- # first check if url match, if not match, then match the name+kind
18
+ # calculate trace mode to set either 1 or 0 based on url_path and name+kind
19
+ # first check if url_path match, if not match, then match the name+kind
20
20
  def calculate_trace_mode
21
21
  tracing_mode_enabled? && tracing_enabled? ? SWO_TRACING_ENABLED : SWO_TRACING_DISABLED
22
22
  end
@@ -28,16 +28,16 @@ module SolarWindsAPM
28
28
  end
29
29
 
30
30
  def tracing_enabled?
31
- span_layer = "#{@name}:#{@kind}"
31
+ span_layer = "#{@kind}:#{@name}"
32
32
 
33
- enabled_regexps = SolarWindsAPM::Config[:enabled_regexps]
33
+ enabled_regexps = SolarWindsAPM::Config[:enabled_regexps]
34
34
  disabled_regexps = SolarWindsAPM::Config[:disabled_regexps]
35
35
 
36
36
  SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] enabled_regexps: #{enabled_regexps&.inspect}"}
37
37
  SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] disabled_regexps: #{disabled_regexps&.inspect}"}
38
38
 
39
- return false if disabled_regexps.is_a?(Array) && disabled_regexps.any? { |regex| regex.match?(@url) }
40
- return true if enabled_regexps.is_a?(Array) && enabled_regexps.any? { |regex| regex.match?(@url) }
39
+ return false if disabled_regexps.is_a?(Array) && disabled_regexps.any? { |regex| regex.match?(@url_path) }
40
+ return true if enabled_regexps.is_a?(Array) && enabled_regexps.any? { |regex| regex.match?(@url_path) }
41
41
  return false if disabled_regexps.is_a?(Array) && disabled_regexps.any? { |regex| regex.match?(span_layer) }
42
42
  return true if enabled_regexps.is_a?(Array) && enabled_regexps.any? { |regex| regex.match?(span_layer) }
43
43
 
@@ -1,25 +1,42 @@
1
1
  module SolarWindsAPM
2
- module OpenTelemetry
3
- # SolarWindsTxnNameManager
4
- class TxnNameManager
5
- def initialize
6
- @cache = {}
7
- end
2
+ # SolarWindsTxnNameManager
3
+ class TxnNameManager
4
+ def initialize
5
+ @cache = {}
6
+ @root_context_h = {}
7
+ @mutex = Mutex.new
8
+ end
8
9
 
9
- def get(key)
10
- @cache[key]
11
- end
10
+ def get(key)
11
+ @cache[key]
12
+ end
12
13
 
13
- def del(key)
14
- @cache.delete(key)
15
- end
14
+ def del(key)
15
+ @cache.delete(key)
16
+ end
16
17
 
17
- def set(key, value)
18
- SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] current cache #{@cache.inspect}"}
19
- @cache[key] = value
18
+ def set(key, value)
19
+ @cache[key] = value
20
+ SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] txn manager current cache #{@cache.inspect}"}
21
+ end
22
+
23
+ alias []= set
24
+
25
+ def set_root_context_h(key, value)
26
+ @mutex.synchronize do
27
+ @root_context_h[key] = value
20
28
  end
29
+ SolarWindsAPM.logger.debug {"[#{self.class}/#{__method__}] txn manager current root_context_h #{@root_context_h.inspect}"}
30
+ end
21
31
 
22
- alias []= set
32
+ def get_root_context_h(key)
33
+ @root_context_h[key]
34
+ end
35
+
36
+ def delete_root_context_h(key)
37
+ @mutex.synchronize do
38
+ @root_context_h.delete(key)
39
+ end
23
40
  end
24
41
  end
25
- end
42
+ end
@@ -0,0 +1,24 @@
1
+ module SolarWindsAPM
2
+ # Utils
3
+ class Utils
4
+ VERSION = '00'.freeze
5
+
6
+ def self.trace_state_header(trace_state)
7
+ return nil if trace_state.nil?
8
+
9
+ arr = []
10
+ trace_state.to_h.each { |key, value| arr << "#{key}=#{value}" }
11
+ header = arr.join(",")
12
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] generated trace_state_header: #{header}"}
13
+ header
14
+ end
15
+
16
+ # Generates a liboboe W3C compatible trace_context from provided OTel span context.
17
+ def self.traceparent_from_context(span_context)
18
+ flag = span_context.trace_flags.sampled?? 1 : 0
19
+ xtr = "#{VERSION}-#{span_context.hex_trace_id}-#{span_context.hex_span_id}-0#{flag}"
20
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] generated traceparent: #{xtr} from #{span_context.inspect}"}
21
+ xtr
22
+ end
23
+ end
24
+ end
@@ -11,7 +11,7 @@ require_relative './support/transaction_cache'
11
11
  require_relative './support/transaction_settings'
12
12
  require_relative './support/oboe_tracing_mode'
13
13
  require_relative './support/txn_name_manager'
14
- require_relative './support/transformer'
14
+ require_relative './support/utils'
15
15
  require_relative './support/x_trace_options'
16
16
 
17
17
  if SolarWindsAPM::Config[:tag_sql]
@@ -27,9 +27,11 @@ if SolarWindsAPM::Config[:tag_sql]
27
27
  # }
28
28
  # }
29
29
  # ]
30
+ SolarWindsAPM.logger.info {"In Rails 7, tag tracecontext on a query by including SolarWindsAPM::SWOMarginalia::Comment.traceparent as function in config.active_record.query_log_tags."}
31
+ SolarWindsAPM.logger.info {"For more information, please check https://api.rubyonrails.org/classes/ActiveRecord/QueryLogs.html"}
30
32
  require_relative './support/swomarginalia/comment'
31
33
  end
32
- else
34
+ elsif defined?(::ActiveRecord)
33
35
  require_relative './support/swomarginalia/load_swomarginalia'
34
36
  SolarWindsAPM::SWOMarginalia::LoadSWOMarginalia.insert
35
37
  end
@@ -9,7 +9,7 @@ module SolarWindsAPM
9
9
  MAJOR = 6 # breaking,
10
10
  MINOR = 0 # feature,
11
11
  PATCH = 0 # fix => BFF
12
- PRE = 'preV1' # for pre-releases into packagecloud, set to nil for production releases into rubygems
12
+ PRE = 'preV3'.freeze # for pre-releases into packagecloud, set to nil for production releases into rubygems
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
15
15
  end
@@ -1,10 +1,9 @@
1
1
  # Copyright (c) 2016 SolarWinds, LLC.
2
2
  # All rights reserved.
3
3
 
4
- begin
5
-
6
- if ENV.has_key?('SOLARWINDS_APM_ENABLED') && (ENV['SOLARWINDS_APM_ENABLED'] == 'false' || ENV['SOLARWINDS_APM_ENABLED'] == false)
7
- SolarWindsAPM.logger.warn 'SOLARWINDS_APM_ENABLED environment variable detected and was set to false; SolarWindsAPM disabled'
4
+ begin
5
+ if ENV.has_key?('SW_APM_ENABLED') && (ENV['SW_APM_ENABLED'] == 'false' || ENV['SW_APM_ENABLED'] == false)
6
+ SolarWindsAPM.logger.warn 'SW_APM_ENABLED environment variable detected and was set to false; SolarWindsAPM disabled'
8
7
  return
9
8
  end
10
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solarwinds_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.preV1
4
+ version: 6.0.0.preV3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maia Engeli
@@ -11,50 +11,36 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-07-14 00:00:00.000000000 Z
14
+ date: 2023-09-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: opentelemetry-sdk
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.0
22
+ version: 1.2.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2.0
29
+ version: 1.2.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: opentelemetry-instrumentation-all
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.31.0
36
+ version: 0.33.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.31.0
44
- - !ruby/object:Gem::Dependency
45
- name: ruby2_keywords
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - "~>"
49
- - !ruby/object:Gem::Version
50
- version: 0.0.5
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: 0.0.5
43
+ version: 0.33.0
58
44
  - !ruby/object:Gem::Dependency
59
45
  name: json
60
46
  requirement: !ruby/object:Gem::Requirement
@@ -73,16 +59,16 @@ dependencies:
73
59
  name: opentelemetry-exporter-otlp
74
60
  requirement: !ruby/object:Gem::Requirement
75
61
  requirements:
76
- - - "~>"
62
+ - - ">="
77
63
  - !ruby/object:Gem::Version
78
- version: 0.24.0
64
+ version: 0.24.2
79
65
  type: :development
80
66
  prerelease: false
81
67
  version_requirements: !ruby/object:Gem::Requirement
82
68
  requirements:
83
- - - "~>"
69
+ - - ">="
84
70
  - !ruby/object:Gem::Version
85
- version: 0.24.0
71
+ version: 0.24.2
86
72
  description: Automatic tracing and metrics for Ruby applications. Get started at cloud.solarwinds.com
87
73
  email: technicalsupport@solarwinds.com
88
74
  executables: []
@@ -106,13 +92,13 @@ files:
106
92
  - ext/oboe_metal/src/oboe_api.h
107
93
  - ext/oboe_metal/src/oboe_debug.h
108
94
  - ext/oboe_metal/src/oboe_swig_wrap.cc
109
- - lib/oboe.rb
110
95
  - lib/oboe_metal.rb
111
96
  - lib/rails/generators/solarwinds_apm/install_generator.rb
112
97
  - lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb
113
98
  - lib/solarwinds_apm.rb
114
99
  - lib/solarwinds_apm/api.rb
115
100
  - lib/solarwinds_apm/api/current_trace_info.rb
101
+ - lib/solarwinds_apm/api/opentelemetry.rb
116
102
  - lib/solarwinds_apm/api/tracing.rb
117
103
  - lib/solarwinds_apm/api/transaction_name.rb
118
104
  - lib/solarwinds_apm/base.rb
@@ -123,7 +109,6 @@ files:
123
109
  - lib/solarwinds_apm/noop/README.md
124
110
  - lib/solarwinds_apm/noop/context.rb
125
111
  - lib/solarwinds_apm/noop/metadata.rb
126
- - lib/solarwinds_apm/noop/profiling.rb
127
112
  - lib/solarwinds_apm/oboe_init_options.rb
128
113
  - lib/solarwinds_apm/opentelemetry.rb
129
114
  - lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb
@@ -145,8 +130,8 @@ files:
145
130
  - lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb
146
131
  - lib/solarwinds_apm/support/transaction_cache.rb
147
132
  - lib/solarwinds_apm/support/transaction_settings.rb
148
- - lib/solarwinds_apm/support/transformer.rb
149
133
  - lib/solarwinds_apm/support/txn_name_manager.rb
134
+ - lib/solarwinds_apm/support/utils.rb
150
135
  - lib/solarwinds_apm/support/x_trace_options.rb
151
136
  - lib/solarwinds_apm/support_report.rb
152
137
  - lib/solarwinds_apm/thread_local.rb
@@ -167,14 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
152
  requirements:
168
153
  - - ">="
169
154
  - !ruby/object:Gem::Version
170
- version: 2.5.0
155
+ version: 2.7.0
171
156
  required_rubygems_version: !ruby/object:Gem::Requirement
172
157
  requirements:
173
158
  - - ">"
174
159
  - !ruby/object:Gem::Version
175
160
  version: 1.3.1
176
161
  requirements: []
177
- rubygems_version: 3.1.6
162
+ rubygems_version: 3.3.26
178
163
  signing_key:
179
164
  specification_version: 4
180
165
  summary: SolarWindsAPM performance instrumentation gem for Ruby
data/lib/oboe.rb DELETED
@@ -1,7 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- # This module is provided for backward compatibility.
5
- # It simply redirects to the solarwinds_apm module which will
6
- # also load backward compatibility support.
7
- require 'solarwinds_apm'
@@ -1,17 +0,0 @@
1
- module SolarWindsAPM
2
- # override the Ruby method, so that no code related to profiling gets executed
3
- class Profiling
4
- def self.run
5
- yield
6
- end
7
- end
8
-
9
- # these put the c-functions into "noop"
10
- module CProfiler
11
- def self.interval_setup(_); end
12
-
13
- def self.tid
14
- 0
15
- end
16
- end
17
- end
@@ -1,56 +0,0 @@
1
- module SolarWindsAPM
2
- module OpenTelemetry
3
- # Transformer
4
- class Transformer
5
- VERSION = '00'.freeze
6
-
7
- def self.sw_from_context(span_context)
8
- flag = span_context.trace_flags.sampled?? 1 : 0
9
- "#{span_context.hex_span_id}-0#{flag}"
10
- end
11
-
12
- def self.trace_state_header(trace_state)
13
- arr = []
14
- trace_state.to_h.each do |key, value|
15
- arr << "#{key}=#{value}"
16
- end
17
- arr.join(",")
18
- end
19
-
20
- # Generates a liboboe W3C compatible trace_context from provided OTel span context.
21
- def self.traceparent_from_context(span_context)
22
- flag = span_context.trace_flags.sampled?? 1 : 0
23
- xtr = "#{VERSION}-#{span_context.hex_trace_id}-#{span_context.hex_span_id}-0#{flag}"
24
- SolarWindsAPM.logger.debug("Generated traceparent #{xtr} from #{span_context.inspect}")
25
- xtr
26
- end
27
-
28
- # Formats tracestate sw value from span_id and liboboe decision as 16-byte span_id with 8-bit trace_flags
29
- # e.g. 1a2b3c4d5e6f7g8h-01
30
- def self.sw_from_span_and_decision(span_id, decision)
31
- [span_id, decision].join("-")
32
- end
33
-
34
- # trace_flags [Integer]
35
- def self.trace_flags_from_int(trace_flags)
36
- "0#{trace_flags}"
37
- end
38
-
39
- def self.trace_flags_from_boolean(trace_flags)
40
- trace_flags == true ? "01" : "00"
41
- end
42
-
43
- def self.sampled?(decision)
44
- decision == ::OpenTelemetry::SDK::Trace::Samplers::Decision::RECORD_AND_SAMPLE
45
- end
46
-
47
- def self.span_id_from_sw(sw_value)
48
- sw_value.split("-")[0]
49
- end
50
-
51
- def self.create_key(name_)
52
- ::OpenTelemetry::Context.create_key(name_)
53
- end
54
- end
55
- end
56
- end