solarwinds_apm 5.1.9 → 6.0.0.preV1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -1
  3. data/ext/oboe_metal/extconf.rb +19 -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 -1
  9. data/ext/oboe_metal/src/oboe_debug.h +1 -0
  10. data/lib/oboe_metal.rb +116 -80
  11. data/lib/rails/generators/solarwinds_apm/install_generator.rb +1 -2
  12. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +44 -260
  13. data/lib/solarwinds_apm/api/current_trace_info.rb +148 -0
  14. data/lib/solarwinds_apm/api/tracing.rb +30 -0
  15. data/lib/solarwinds_apm/api/transaction_name.rb +57 -0
  16. data/lib/solarwinds_apm/api.rb +8 -15
  17. data/lib/solarwinds_apm/base.rb +4 -131
  18. data/lib/solarwinds_apm/config.rb +128 -175
  19. data/lib/solarwinds_apm/constants.rb +32 -0
  20. data/lib/solarwinds_apm/logger.rb +1 -1
  21. data/lib/solarwinds_apm/noop/context.rb +2 -5
  22. data/lib/solarwinds_apm/noop/metadata.rb +1 -2
  23. data/lib/solarwinds_apm/noop/profiling.rb +3 -7
  24. data/lib/solarwinds_apm/oboe_init_options.rb +71 -33
  25. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +204 -0
  26. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +163 -0
  27. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +92 -0
  28. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +72 -0
  29. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +330 -0
  30. data/lib/solarwinds_apm/opentelemetry.rb +8 -0
  31. data/lib/solarwinds_apm/otel_config.rb +161 -0
  32. data/lib/solarwinds_apm/{inst → support}/logger_formatter.rb +5 -6
  33. data/lib/solarwinds_apm/{inst → support}/logging_log_event.rb +3 -6
  34. data/lib/solarwinds_apm/{inst → support}/lumberjack_formatter.rb +1 -4
  35. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +27 -0
  36. data/lib/solarwinds_apm/support/swomarginalia/LICENSE +20 -0
  37. data/lib/solarwinds_apm/support/swomarginalia/README.md +41 -0
  38. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +205 -0
  39. data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +48 -0
  40. data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +22 -0
  41. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +86 -0
  42. data/lib/solarwinds_apm/support/transaction_cache.rb +24 -0
  43. data/lib/solarwinds_apm/support/transaction_settings.rb +26 -209
  44. data/lib/solarwinds_apm/support/transformer.rb +56 -0
  45. data/lib/solarwinds_apm/support/txn_name_manager.rb +25 -0
  46. data/lib/solarwinds_apm/support/x_trace_options.rb +42 -26
  47. data/lib/solarwinds_apm/support.rb +33 -10
  48. data/lib/solarwinds_apm/support_report.rb +10 -32
  49. data/lib/solarwinds_apm/thread_local.rb +1 -1
  50. data/lib/solarwinds_apm/version.rb +4 -4
  51. data/lib/solarwinds_apm.rb +31 -26
  52. metadata +76 -121
  53. data/.dockerignore +0 -5
  54. data/.gitignore +0 -58
  55. data/.rubocop.yml +0 -29
  56. data/.whitesource +0 -22
  57. data/.yardopts +0 -7
  58. data/CHANGELOG-appoptics.md +0 -766
  59. data/CHANGELOG.md +0 -82
  60. data/CONFIG.md +0 -31
  61. data/Gemfile +0 -15
  62. data/README.md +0 -385
  63. data/bin/solarwinds_apm_config +0 -15
  64. data/examples/prepend.rb +0 -13
  65. data/examples/sdk_examples.rb +0 -158
  66. data/ext/oboe_metal/README.md +0 -69
  67. data/ext/oboe_metal/extconf_local.rb +0 -75
  68. data/ext/oboe_metal/lib/.keep +0 -0
  69. data/ext/oboe_metal/noop/noop.c +0 -8
  70. data/ext/oboe_metal/src/README.md +0 -6
  71. data/ext/oboe_metal/src/frames.cc +0 -247
  72. data/ext/oboe_metal/src/frames.h +0 -40
  73. data/ext/oboe_metal/src/logging.cc +0 -97
  74. data/ext/oboe_metal/src/logging.h +0 -34
  75. data/ext/oboe_metal/src/profiling.cc +0 -435
  76. data/ext/oboe_metal/src/profiling.h +0 -78
  77. data/ext/oboe_metal/test/CMakeLists.txt +0 -53
  78. data/ext/oboe_metal/test/FindGMock.cmake +0 -43
  79. data/ext/oboe_metal/test/README.md +0 -56
  80. data/ext/oboe_metal/test/frames_test.cc +0 -164
  81. data/ext/oboe_metal/test/profiling_test.cc +0 -93
  82. data/ext/oboe_metal/test/ruby_inc_dir.rb +0 -8
  83. data/ext/oboe_metal/test/ruby_prefix.rb +0 -8
  84. data/ext/oboe_metal/test/ruby_test_helper.rb +0 -67
  85. data/ext/oboe_metal/test/test.h +0 -11
  86. data/ext/oboe_metal/test/test_main.cc +0 -32
  87. data/init.rb +0 -4
  88. data/lib/solarwinds_apm/api/layerinit.rb +0 -41
  89. data/lib/solarwinds_apm/api/logging.rb +0 -356
  90. data/lib/solarwinds_apm/api/memcache.rb +0 -37
  91. data/lib/solarwinds_apm/api/metrics.rb +0 -63
  92. data/lib/solarwinds_apm/api/util.rb +0 -98
  93. data/lib/solarwinds_apm/frameworks/grape.rb +0 -96
  94. data/lib/solarwinds_apm/frameworks/padrino.rb +0 -78
  95. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +0 -100
  96. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +0 -50
  97. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +0 -50
  98. data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +0 -88
  99. data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +0 -26
  100. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +0 -29
  101. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +0 -22
  102. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +0 -103
  103. data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +0 -14
  104. data/lib/solarwinds_apm/frameworks/rails.rb +0 -100
  105. data/lib/solarwinds_apm/frameworks/sinatra.rb +0 -96
  106. data/lib/solarwinds_apm/inst/bunny-client.rb +0 -157
  107. data/lib/solarwinds_apm/inst/bunny-consumer.rb +0 -102
  108. data/lib/solarwinds_apm/inst/curb.rb +0 -289
  109. data/lib/solarwinds_apm/inst/dalli.rb +0 -89
  110. data/lib/solarwinds_apm/inst/delayed_job.rb +0 -100
  111. data/lib/solarwinds_apm/inst/excon.rb +0 -113
  112. data/lib/solarwinds_apm/inst/faraday.rb +0 -96
  113. data/lib/solarwinds_apm/inst/graphql.rb +0 -206
  114. data/lib/solarwinds_apm/inst/grpc_client.rb +0 -147
  115. data/lib/solarwinds_apm/inst/grpc_server.rb +0 -119
  116. data/lib/solarwinds_apm/inst/httpclient.rb +0 -182
  117. data/lib/solarwinds_apm/inst/memcached.rb +0 -86
  118. data/lib/solarwinds_apm/inst/mongo.rb +0 -246
  119. data/lib/solarwinds_apm/inst/mongo2.rb +0 -225
  120. data/lib/solarwinds_apm/inst/moped.rb +0 -466
  121. data/lib/solarwinds_apm/inst/net_http.rb +0 -60
  122. data/lib/solarwinds_apm/inst/rack.rb +0 -223
  123. data/lib/solarwinds_apm/inst/rack_cache.rb +0 -35
  124. data/lib/solarwinds_apm/inst/redis.rb +0 -280
  125. data/lib/solarwinds_apm/inst/redis_v4.rb +0 -273
  126. data/lib/solarwinds_apm/inst/resque.rb +0 -129
  127. data/lib/solarwinds_apm/inst/rest-client.rb +0 -43
  128. data/lib/solarwinds_apm/inst/sequel.rb +0 -241
  129. data/lib/solarwinds_apm/inst/sidekiq-client.rb +0 -63
  130. data/lib/solarwinds_apm/inst/sidekiq-worker.rb +0 -64
  131. data/lib/solarwinds_apm/inst/typhoeus.rb +0 -90
  132. data/lib/solarwinds_apm/instrumentation.rb +0 -22
  133. data/lib/solarwinds_apm/loading.rb +0 -65
  134. data/lib/solarwinds_apm/ruby.rb +0 -35
  135. data/lib/solarwinds_apm/sdk/current_trace_info.rb +0 -123
  136. data/lib/solarwinds_apm/sdk/custom_metrics.rb +0 -94
  137. data/lib/solarwinds_apm/sdk/logging.rb +0 -37
  138. data/lib/solarwinds_apm/sdk/trace_context_headers.rb +0 -69
  139. data/lib/solarwinds_apm/sdk/tracing.rb +0 -432
  140. data/lib/solarwinds_apm/support/profiling.rb +0 -25
  141. data/lib/solarwinds_apm/support/trace_context.rb +0 -53
  142. data/lib/solarwinds_apm/support/trace_state.rb +0 -69
  143. data/lib/solarwinds_apm/support/trace_string.rb +0 -89
  144. data/lib/solarwinds_apm/support/transaction_metrics.rb +0 -67
  145. data/lib/solarwinds_apm/test.rb +0 -165
  146. data/lib/solarwinds_apm/util.rb +0 -426
  147. data/log/.keep +0 -0
  148. data/log/postgresql/.keep +0 -0
  149. data/solarwinds_apm.gemspec +0 -55
  150. data/yardoc_frontpage.md +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e79b789228d9d0885289c825d1ae712bab1d9450334f6b27fd72e19763b436a
4
- data.tar.gz: 62ec2e7f017cfa2824d269d7db3a3330d9c5c5555424552f8c289f1401caa60d
3
+ metadata.gz: 78b2c4b54eaff62c93db5c06ebd9e85f73aea61943fa8eb90f0ba157dc81ab01
4
+ data.tar.gz: 2133540e0d8ec4ab097cd638d0cfd834649bc4898555ffb9cbfd7fa58a6e2355
5
5
  SHA512:
6
- metadata.gz: 210f5a2c53d302666b12a3afff04481bf3ea094f509b6275aedf5825cdce721d45dcd5dfd170b2c1ab484ef01c9e5bc098235213a066d0cb860caa99c9fbf00b
7
- data.tar.gz: 49280e85e07e7523c67b0bb848d71c9160c01c4861fffcccd526af7be436ca709fb31e9995f5326cf497ceffa1622244fc98ba5bba1c601fcf2e5687a49b7d01
6
+ metadata.gz: 2731e533815670079641e91865a502157162a4924d4c1c0950b50f3e42d7417619305f51a2db22f12ef45ea9111b826d59bcd091f9201b1375afdb06e940421a
7
+ data.tar.gz: 6c2053e792310de17c09a58b68e8b74ba100a01c025d703d8cee315b7c3ad7ae6f23da08fe0b5dda2a6328a710330c6ce1468db12703c4d16ce98f1564df5436
data/LICENSE CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  Apache License
3
2
  Version 2.0, January 2004
4
3
  http://www.apache.org/licenses/
@@ -6,19 +6,18 @@
6
6
  require 'mkmf'
7
7
  require 'rbconfig'
8
8
  require 'open-uri'
9
- require 'no_proxy_fix'
10
9
 
11
10
  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/, '')
11
+ .gsub(/-Wimplicit-function-declaration/, '')
12
+ .gsub(/-Wimplicit-int/, '')
13
+ .gsub(/-Wno-tautological-compare/, '')
14
+ .gsub(/-Wno-self-assign/, '')
15
+ .gsub(/-Wno-parentheses-equality/, '')
16
+ .gsub(/-Wno-constant-logical-operand/, '')
17
+ .gsub(/-Wno-cast-function-type/, '')
19
18
  init_mkmf(CONFIG)
20
19
 
21
- ext_dir = File.expand_path(File.dirname(__FILE__))
20
+ ext_dir = __dir__
22
21
 
23
22
  # Set the mkmf lib paths so we have no issues linking to
24
23
  # the SolarWindsAPM libs.
@@ -37,13 +36,13 @@ else
37
36
  ao_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version)
38
37
  end
39
38
 
40
- ao_arch = "x86_64"
39
+ ao_arch = 'x86_64'
41
40
  system_arch = `uname -m` # for mac, the command is `uname` # "Darwin\n"; try `uname -a`
42
41
  case system_arch.gsub("\n","")
43
- when "x86_64"
44
- ao_arch = "x86_64"
45
- when "aarch64"
46
- ao_arch = "aarch64"
42
+ when 'x86_64'
43
+ ao_arch = 'x86_64'
44
+ when 'aarch64'
45
+ ao_arch = 'aarch64'
47
46
  end
48
47
 
49
48
  if File.exist?('/etc/alpine-release')
@@ -67,12 +66,9 @@ retries = 3
67
66
  success = false
68
67
  while retries > 0
69
68
  begin
70
- download = URI.open(ao_item, 'rb')
71
- IO.copy_stream(download, clib)
72
-
69
+ IO.copy_stream(URI.parse(ao_item).open, clib)
73
70
  clib_checksum = Digest::SHA256.file(clib).hexdigest
74
- download.close
75
- checksum = File.read(ao_checksum_file).strip
71
+ checksum = File.read(ao_checksum_file).strip
76
72
 
77
73
  # unfortunately these messages only show if the install command is run
78
74
  # with the `--verbose` flag
@@ -89,7 +85,7 @@ while retries > 0
89
85
  success = true
90
86
  retries = 0
91
87
  end
92
- rescue => e
88
+ rescue StandardError => e
93
89
  File.write(clib, '')
94
90
  retries -= 1
95
91
  if retries == 0
@@ -139,15 +135,15 @@ if success
139
135
 
140
136
  create_makefile('libsolarwinds_apm', 'src')
141
137
  else
142
- $stderr.puts '== ERROR ========================================================='
138
+ $stderr.puts '== ERROR ========================================================='
143
139
  if have_library('oboe')
144
140
  $stderr.puts "The c-library either needs to be updated or doesn't match the OS."
145
141
  $stderr.puts 'No tracing will occur.'
146
142
  else
147
143
  $stderr.puts 'Could not find a matching c-library. No tracing will occur.'
148
144
  end
149
- $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists.'
150
- $stderr.puts '=================================================================='
145
+ $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists.'
146
+ $stderr.puts '=================================================================='
151
147
  create_makefile('oboe_noop', 'noop')
152
148
  end
153
149
  end
@@ -1 +1 @@
1
- 5403faf71b2d26bf2a0fd32d159f10b920d5fdafc0aef4b335e5e272d22c1b70
1
+ b931c715d8ddaa9f2b91c72ad708ed3467e6e68ee4255756123b2ca96f1b98d0
@@ -1 +1 @@
1
- 78964dc06204715aa29a8ff47b259984ae476ab72f3d0d983e2ef1c52ef70d6a
1
+ c8189fe6f5b31c15c31d3b005aebcff90f97ff82e92d9e0d3b254bbbe2a7367d
@@ -1 +1 @@
1
- 97c82835d4dbf1130b33a1c75a3c5d9923b1b5c5224e19db9902288c29d128c5
1
+ 2824ba630ba794ff6280358922b54e8e1be4ccdb145376f90601e6652d149525
@@ -1 +1 @@
1
- 6c04a460825bf130caa83433ad0aa01b56f4c5a4ca891df3ffa516db8dc9486a
1
+ 82a003ec82e3703260cdc215ef4c0c0bc7bc916cef27ef509034b60fd5ef9b35
@@ -1,2 +1,2 @@
1
- 12.3.0
1
+ 12.4.0
2
2
 
@@ -6,6 +6,7 @@ extern "C" {
6
6
  #endif
7
7
 
8
8
  #include <stdbool.h>
9
+ #include <stdio.h>
9
10
 
10
11
  /**
11
12
  * Defined diagnostic log detail levels.
data/lib/oboe_metal.rb CHANGED
@@ -1,15 +1,13 @@
1
1
  # Copyright (c) 2016 SolarWinds, LLC.
2
2
  # All rights reserved.
3
3
 
4
- require 'thread'
5
-
6
4
  # Disable docs and Camelcase warns since we're implementing
7
5
  # an interface here. See OboeBase for details.
8
- # rubocop:disable Style/Documentation, Naming/MethodName
9
6
  module SolarWindsAPM
10
7
  extend SolarWindsAPMBase
11
8
  include Oboe_metal
12
9
 
10
+ # Reporter that send span data to SWO
13
11
  class Reporter
14
12
  class << self
15
13
  ##
@@ -26,13 +24,8 @@ module SolarWindsAPM
26
24
 
27
25
  SolarWindsAPM.reporter = Oboe_metal::Reporter.new(*options)
28
26
 
29
- # Only report __Init from here if we are not instrumenting a framework.
30
- # Otherwise, frameworks will handle reporting __Init after full initialization
31
- unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
32
- SolarWindsAPM::API.report_init
33
- end
34
-
35
- rescue => e
27
+ report_init
28
+ rescue StandardError=> e
36
29
  $stderr.puts e.message
37
30
  raise
38
31
  end
@@ -44,8 +37,8 @@ module SolarWindsAPM
44
37
  #
45
38
  # Send the report for the given event
46
39
  #
47
- def sendReport(evt)
48
- SolarWindsAPM.reporter.sendReport(evt)
40
+ def send_report(evt, with_system_timestamp: true)
41
+ SolarWindsAPM.reporter.sendReport(evt, with_system_timestamp)
49
42
  end
50
43
 
51
44
  ##
@@ -53,8 +46,8 @@ module SolarWindsAPM
53
46
  #
54
47
  # Send the report for the given event
55
48
  #
56
- def sendStatus(evt, context = nil)
57
- SolarWindsAPM.reporter.sendStatus(evt, context)
49
+ def send_status(evt, context=nil, with_system_timestamp: true)
50
+ SolarWindsAPM.reporter.sendStatus(evt, context, with_system_timestamp)
58
51
  end
59
52
 
60
53
  ##
@@ -67,20 +60,11 @@ module SolarWindsAPM
67
60
  end
68
61
 
69
62
  ##
70
- # hard_clear_all_traces
71
- #
72
- # Truncates the trace output file to zero by deleting the original bson file
73
- #
74
- def hard_clear_all_traces
75
- File.delete(SolarWindsAPM::OboeInitOptions.instance.host) if File.exist?(SolarWindsAPM::OboeInitOptions.instance.host)
76
- end
77
-
78
- ##
79
- # get_all_traces
63
+ # obtain_all_traces
80
64
  #
81
65
  # Retrieves all traces written to the trace file
82
66
  #
83
- def get_all_traces
67
+ def obtain_all_traces
84
68
  io = File.open(SolarWindsAPM::OboeInitOptions.instance.host, 'r')
85
69
  contents = io.readlines(nil)
86
70
  io.close
@@ -106,68 +90,121 @@ module SolarWindsAPM
106
90
  end
107
91
  else
108
92
  bbb = ::BSON::ByteBuffer.new(contents[0])
109
- until bbb.length == 0
110
- traces << Hash.from_bson(bbb)
111
- end
93
+ traces << Hash.from_bson(bbb) until bbb.length == 0
112
94
  end
113
95
 
114
96
  traces
115
97
  end
116
- end
117
- end
118
98
 
119
- module EventUtil
120
- def self.metadataString(evt)
121
- evt.metadataString
99
+ private
100
+
101
+ # Internal: Report that instrumentation for the given layer has been
102
+ # installed, as well as the version of instrumentation and version of
103
+ # layer.
104
+ #
105
+ def report_init(layer=:rack) # :nodoc:
106
+ # Don't send __Init in test or if SolarWindsAPM
107
+ # isn't fully loaded (e.g. missing c-extension)
108
+ return if ENV.has_key?('SW_APM_GEM_TEST') || !SolarWindsAPM.loaded
109
+
110
+ platform_info = build_swo_init_report
111
+ log_init(layer, platform_info)
112
+ end
113
+
114
+ ##
115
+ # :nodoc:
116
+ # Internal: Reports agent init to the collector
117
+ #
118
+ # ==== Arguments
119
+ #
120
+ # * +layer+ - The layer the reported event belongs to
121
+ # * +kvs+ - A hash containing key/value pairs that will be reported along with this event
122
+ def log_init(layer=:rack, kvs={})
123
+ context = SolarWindsAPM::Metadata.makeRandom
124
+ return SolarWindsAPM::Context.toString unless context.isValid
125
+
126
+ event = context.createEvent
127
+ event.addInfo('Layer', layer.to_s)
128
+ event.addInfo('Label', 'single')
129
+ kvs.each do |k, v|
130
+ event.addInfo(k, v.to_s)
131
+ end
132
+
133
+ SolarWindsAPM::Reporter.send_status(event, context, with_system_timestamp: true)
134
+ SolarWindsAPM::Context.toString
135
+ end
136
+
137
+ ##
138
+ # build_swo_init_report
139
+ #
140
+ # Internal: Build a hash of KVs that reports on the status of the
141
+ # running environment for swo only. This is used on stack boot in __Init reporting
142
+ # and for SolarWindsAPM.support_report.
143
+ #
144
+ def build_swo_init_report
145
+
146
+ platform_info = {'__Init' => true}
147
+
148
+ begin
149
+ platform_info['APM.Version'] = SolarWindsAPM::Version::STRING
150
+ platform_info['APM.Extension.Version'] = extension_lib_version
151
+
152
+ # OTel Resource Attributes (Optional)
153
+ platform_info['process.executable.path'] = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
154
+ platform_info['process.executable.name'] = RbConfig::CONFIG['ruby_install_name']
155
+ platform_info['process.command_line'] = $PROGRAM_NAME
156
+ platform_info['process.telemetry.path'] = Gem::Specification.find_by_name('solarwinds_apm')&.full_gem_path
157
+ platform_info['os.type'] = RUBY_PLATFORM
158
+
159
+ platform_info.merge!(report_gem_in_use)
160
+
161
+ # Collect up opentelemetry sdk version (Instrumented Library Versions) (Required)
162
+ begin
163
+ require 'opentelemetry/sdk'
164
+ ::OpenTelemetry::SDK::Resources::Resource.telemetry_sdk.attribute_enumerator.each {|k,v| platform_info[k] = v}
165
+ ::OpenTelemetry::SDK::Resources::Resource.process.attribute_enumerator.each {|k,v| platform_info[k] = v}
166
+ rescue StandardError => e
167
+ SolarWindsAPM.logger.warn {"[#{self.class}/#{__method__}] Fail to extract telemetry attributes. Error: #{e.message}"}
168
+ end
169
+ rescue StandardError, ScriptError => e
170
+ # Also rescue ScriptError (aka SyntaxError) in case one of the expected
171
+ # version defines don't exist
172
+
173
+ platform_info['Error'] = "Error in build_report: #{e.message}"
174
+
175
+ SolarWindsAPM.logger.warn {"[#{self.class}/#{__method__}] Error in build_init_report: #{e.message}"}
176
+ SolarWindsAPM.logger.debug {e.backtrace}
177
+ end
178
+ platform_info
179
+ end
180
+
181
+ ##
182
+ # Collect up the loaded gems
183
+ ##
184
+ def report_gem_in_use
185
+ platform_info = {}
186
+ if defined?(Gem) && Gem.respond_to?(:loaded_specs)
187
+ Gem.loaded_specs.each_pair {|k, v| platform_info["Ruby.#{k}.Version"] = v.version.to_s}
188
+ else
189
+ platform_info.merge!(legacy_build_init_report)
190
+ end
191
+ platform_info
192
+ end
193
+
194
+ ##
195
+ # get extension library version by looking at the VERSION file
196
+ # oboe not loaded yet, can't use oboe_api function to read oboe VERSION
197
+ ##
198
+ def extension_lib_version
199
+ gem_location = Gem::Specification.find_by_name('solarwinds_apm')
200
+ clib_version_file = File.join(gem_location&.gem_dir, 'ext', 'oboe_metal', 'src', 'VERSION')
201
+ File.read(clib_version_file).strip
202
+ end
122
203
  end
123
204
  end
124
205
 
125
206
  class << self
126
- # def sample?(opts = {})
127
- # # Return false if no-op mode
128
- # return false unless SolarWindsAPM.loaded
129
- #
130
- # # Assure defaults since SWIG enforces Strings
131
- # xtrace = opts[:xtrace] ? opts[:xtrace].to_s.strip : SW_APM_STR_BLANK
132
- #
133
- # # the first arg has changed to be the service name, blank means to use the default (from the service key)
134
- # rv = SolarWindsAPM::Context.sampleRequest(SW_APM_STR_BLANK, xtrace)
135
- #
136
- # if rv == 0
137
- # SolarWindsAPM.sample_rate = -1
138
- # SolarWindsAPM.sample_source = -1
139
- # false
140
- # else
141
- # # liboboe version > 1.3.1 returning a bit masked integer with SampleRate and
142
- # # source embedded
143
- # SolarWindsAPM.sample_rate = (rv & SAMPLE_RATE_MASK)
144
- # SolarWindsAPM.sample_source = (rv & SAMPLE_SOURCE_MASK) >> 24
145
- # true
146
- # end
147
- # rescue StandardError => e
148
- # SolarWindsAPM.logger.debug "[oboe/error] sample? error: #{e.inspect}"
149
- # false
150
- # end
151
-
152
- # def set_tracing_mode(mode)
153
- # return unless SolarWindsAPM.loaded
154
- #
155
- # value = mode.to_sym
156
- #
157
- # case value
158
- # when :disabled, :never
159
- # SolarWindsAPM::Context.setTracingMode(SW_APM_TRACE_DISABLED)
160
- #
161
- # when :enabled, :always
162
- # SolarWindsAPM::Context.setTracingMode(SW_APM_TRACE_ENABLED)
163
- #
164
- # else
165
- # SolarWindsAPM.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
166
- # SolarWindsAPM::Context.setTracingMode(SW_APM_TRACE_DISABLED)
167
- # end
168
- # end
169
-
170
- def set_sample_rate(rate)
207
+ def sample_rate(rate)
171
208
  return unless SolarWindsAPM.loaded
172
209
 
173
210
  # Update liboboe with the new SampleRate value
@@ -175,7 +212,6 @@ module SolarWindsAPM
175
212
  end
176
213
  end
177
214
  end
178
- # rubocop:enable Style/Documentation
179
215
 
180
216
  SolarWindsAPM.loaded = true
181
- SolarWindsAPM.config_lock = Mutex.new
217
+ # rubocop:enable Style/Documentation
@@ -2,6 +2,7 @@
2
2
  # All rights reserved.
3
3
 
4
4
  module SolarWindsAPM
5
+ # InstallGenerator
5
6
  class InstallGenerator < ::Rails::Generators::Base
6
7
  source_root File.join(File.dirname(__FILE__), 'templates')
7
8
  desc "Copies a SolarWindsAPM gem initializer file to your application."
@@ -20,7 +21,6 @@ module SolarWindsAPM
20
21
 
21
22
  private
22
23
 
23
- # rubocop:disable Metrics/MethodLength
24
24
  def print_header
25
25
  say ""
26
26
  say shell.set_color "Welcome to the SolarWindsAPM Ruby instrumentation setup.", :green, :bold
@@ -34,7 +34,6 @@ module SolarWindsAPM
34
34
  say "More information on instrumenting Ruby applications can be found here:"
35
35
  say "https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent"
36
36
  end
37
- # rubocop:enable Metrics/MethodLength
38
37
 
39
38
  def print_footer
40
39
  say ""