solarwinds_apm 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/.dockerignore +5 -0
  3. data/.github/ISSUE_TEMPLATE/bug-or-feature-request.md +16 -0
  4. data/.github/workflows/build_and_release_gem.yml +112 -0
  5. data/.github/workflows/build_for_packagecloud.yml +70 -0
  6. data/.github/workflows/docker-images.yml +47 -0
  7. data/.github/workflows/run_cpluplus_tests.yml +73 -0
  8. data/.github/workflows/run_tests.yml +155 -0
  9. data/.github/workflows/scripts/test_install.rb +23 -0
  10. data/.github/workflows/swig/swig-v4.0.2.tar.gz +0 -0
  11. data/.github/workflows/test_on_4_linux.yml +161 -0
  12. data/.gitignore +39 -0
  13. data/.rubocop.yml +29 -0
  14. data/.yardopts +7 -0
  15. data/CHANGELOG.md +769 -0
  16. data/CONFIG.md +31 -0
  17. data/Gemfile +14 -0
  18. data/LICENSE +202 -0
  19. data/README.md +383 -0
  20. data/bin/solarwinds_apm_config +15 -0
  21. data/examples/prepend.rb +13 -0
  22. data/examples/sdk_examples.rb +158 -0
  23. data/ext/oboe_metal/README.md +69 -0
  24. data/ext/oboe_metal/extconf.rb +141 -0
  25. data/ext/oboe_metal/extconf_local.rb +75 -0
  26. data/ext/oboe_metal/lib/.keep +0 -0
  27. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.0.0.0.sha256 +1 -0
  28. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256 +1 -0
  29. data/ext/oboe_metal/noop/noop.c +8 -0
  30. data/ext/oboe_metal/src/README.md +6 -0
  31. data/ext/oboe_metal/src/VERSION +2 -0
  32. data/ext/oboe_metal/src/bson/bson.h +220 -0
  33. data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
  34. data/ext/oboe_metal/src/frames.cc +247 -0
  35. data/ext/oboe_metal/src/frames.h +40 -0
  36. data/ext/oboe_metal/src/init_solarwinds_apm.cc +21 -0
  37. data/ext/oboe_metal/src/logging.cc +95 -0
  38. data/ext/oboe_metal/src/logging.h +35 -0
  39. data/ext/oboe_metal/src/oboe.h +1169 -0
  40. data/ext/oboe_metal/src/oboe_api.cpp +658 -0
  41. data/ext/oboe_metal/src/oboe_api.hpp +433 -0
  42. data/ext/oboe_metal/src/oboe_debug.h +59 -0
  43. data/ext/oboe_metal/src/oboe_swig_wrap.cc +7562 -0
  44. data/ext/oboe_metal/src/profiling.cc +435 -0
  45. data/ext/oboe_metal/src/profiling.h +78 -0
  46. data/ext/oboe_metal/test/CMakeLists.txt +53 -0
  47. data/ext/oboe_metal/test/FindGMock.cmake +43 -0
  48. data/ext/oboe_metal/test/README.md +56 -0
  49. data/ext/oboe_metal/test/frames_test.cc +164 -0
  50. data/ext/oboe_metal/test/profiling_test.cc +93 -0
  51. data/ext/oboe_metal/test/ruby_inc_dir.rb +8 -0
  52. data/ext/oboe_metal/test/ruby_prefix.rb +8 -0
  53. data/ext/oboe_metal/test/ruby_test_helper.rb +67 -0
  54. data/ext/oboe_metal/test/test.h +11 -0
  55. data/ext/oboe_metal/test/test_main.cc +32 -0
  56. data/init.rb +4 -0
  57. data/lib/oboe.rb +7 -0
  58. data/lib/oboe_metal.rb +172 -0
  59. data/lib/rails/generators/solarwinds_apm/install_generator.rb +47 -0
  60. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +424 -0
  61. data/lib/solarwinds_apm/api/layerinit.rb +41 -0
  62. data/lib/solarwinds_apm/api/logging.rb +356 -0
  63. data/lib/solarwinds_apm/api/memcache.rb +37 -0
  64. data/lib/solarwinds_apm/api/metrics.rb +63 -0
  65. data/lib/solarwinds_apm/api/util.rb +98 -0
  66. data/lib/solarwinds_apm/api.rb +21 -0
  67. data/lib/solarwinds_apm/base.rb +160 -0
  68. data/lib/solarwinds_apm/config.rb +301 -0
  69. data/lib/solarwinds_apm/frameworks/grape.rb +96 -0
  70. data/lib/solarwinds_apm/frameworks/padrino.rb +78 -0
  71. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +100 -0
  72. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +50 -0
  73. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +50 -0
  74. data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +88 -0
  75. data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +26 -0
  76. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +29 -0
  77. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +22 -0
  78. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +103 -0
  79. data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +14 -0
  80. data/lib/solarwinds_apm/frameworks/rails.rb +100 -0
  81. data/lib/solarwinds_apm/frameworks/sinatra.rb +96 -0
  82. data/lib/solarwinds_apm/inst/bunny-client.rb +157 -0
  83. data/lib/solarwinds_apm/inst/bunny-consumer.rb +102 -0
  84. data/lib/solarwinds_apm/inst/curb.rb +288 -0
  85. data/lib/solarwinds_apm/inst/dalli.rb +89 -0
  86. data/lib/solarwinds_apm/inst/delayed_job.rb +100 -0
  87. data/lib/solarwinds_apm/inst/excon.rb +113 -0
  88. data/lib/solarwinds_apm/inst/faraday.rb +96 -0
  89. data/lib/solarwinds_apm/inst/graphql.rb +206 -0
  90. data/lib/solarwinds_apm/inst/grpc_client.rb +147 -0
  91. data/lib/solarwinds_apm/inst/grpc_server.rb +119 -0
  92. data/lib/solarwinds_apm/inst/httpclient.rb +181 -0
  93. data/lib/solarwinds_apm/inst/logger_formatter.rb +46 -0
  94. data/lib/solarwinds_apm/inst/logging_log_event.rb +24 -0
  95. data/lib/solarwinds_apm/inst/lumberjack_formatter.rb +9 -0
  96. data/lib/solarwinds_apm/inst/memcached.rb +86 -0
  97. data/lib/solarwinds_apm/inst/mongo.rb +246 -0
  98. data/lib/solarwinds_apm/inst/mongo2.rb +225 -0
  99. data/lib/solarwinds_apm/inst/moped.rb +466 -0
  100. data/lib/solarwinds_apm/inst/net_http.rb +60 -0
  101. data/lib/solarwinds_apm/inst/rack.rb +217 -0
  102. data/lib/solarwinds_apm/inst/rack_cache.rb +35 -0
  103. data/lib/solarwinds_apm/inst/redis.rb +273 -0
  104. data/lib/solarwinds_apm/inst/resque.rb +129 -0
  105. data/lib/solarwinds_apm/inst/rest-client.rb +43 -0
  106. data/lib/solarwinds_apm/inst/sequel.rb +241 -0
  107. data/lib/solarwinds_apm/inst/sidekiq-client.rb +63 -0
  108. data/lib/solarwinds_apm/inst/sidekiq-worker.rb +64 -0
  109. data/lib/solarwinds_apm/inst/typhoeus.rb +90 -0
  110. data/lib/solarwinds_apm/instrumentation.rb +22 -0
  111. data/lib/solarwinds_apm/loading.rb +65 -0
  112. data/lib/solarwinds_apm/logger.rb +14 -0
  113. data/lib/solarwinds_apm/noop/README.md +9 -0
  114. data/lib/solarwinds_apm/noop/context.rb +26 -0
  115. data/lib/solarwinds_apm/noop/metadata.rb +25 -0
  116. data/lib/solarwinds_apm/noop/profiling.rb +21 -0
  117. data/lib/solarwinds_apm/oboe_init_options.rb +191 -0
  118. data/lib/solarwinds_apm/ruby.rb +35 -0
  119. data/lib/solarwinds_apm/sdk/current_trace_info.rb +123 -0
  120. data/lib/solarwinds_apm/sdk/custom_metrics.rb +94 -0
  121. data/lib/solarwinds_apm/sdk/logging.rb +37 -0
  122. data/lib/solarwinds_apm/sdk/trace_context_headers.rb +69 -0
  123. data/lib/solarwinds_apm/sdk/tracing.rb +432 -0
  124. data/lib/solarwinds_apm/support/profiling.rb +22 -0
  125. data/lib/solarwinds_apm/support/trace_context.rb +53 -0
  126. data/lib/solarwinds_apm/support/trace_state.rb +69 -0
  127. data/lib/solarwinds_apm/support/trace_string.rb +89 -0
  128. data/lib/solarwinds_apm/support/transaction_metrics.rb +67 -0
  129. data/lib/solarwinds_apm/support/transaction_settings.rb +233 -0
  130. data/lib/solarwinds_apm/support/x_trace_options.rb +113 -0
  131. data/lib/solarwinds_apm/support.rb +12 -0
  132. data/lib/solarwinds_apm/support_report.rb +113 -0
  133. data/lib/solarwinds_apm/test.rb +165 -0
  134. data/lib/solarwinds_apm/thread_local.rb +26 -0
  135. data/lib/solarwinds_apm/util.rb +334 -0
  136. data/lib/solarwinds_apm/version.rb +17 -0
  137. data/lib/solarwinds_apm.rb +72 -0
  138. data/log/.keep +0 -0
  139. data/log/postgresql/.keep +0 -0
  140. data/solarwinds_apm.gemspec +52 -0
  141. data/yardoc_frontpage.md +24 -0
  142. metadata +228 -0
@@ -0,0 +1,158 @@
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 solarwinds_apm
11
+ #
12
+ # SDK documentation:
13
+ # https://rubydoc.info/gems/solarwinds_apm/SolarWindsAPM/SDK
14
+
15
+ ###############################################################
16
+ # Prerequisits
17
+ # export SW_APM_SERVICE_KEY=<API token>:<service_name>
18
+ # `bundle exec ruby sdk_examples.rb`
19
+ # 5 traced requests will show up in the backend
20
+ ###############################################################
21
+
22
+ require 'solarwinds_apm'
23
+
24
+ unless SolarWindsAPM::SDK.solarwinds_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
+ # SolarWindsAPM::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
+ SolarWindsAPM::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
+ # SolarWindsAPM::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
+ SolarWindsAPM::SDK.start_trace('outer_span') do
55
+ SolarWindsAPM::SDK.trace('first_child_span') do
56
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
57
+ SolarWindsAPM::SDK.log_info({ some: :fancy, hash: :to, send: 1 })
58
+ end
59
+ end
60
+
61
+ ###############################################################
62
+ # LOG AN ERROR EVENT
63
+ ###############################################################
64
+ #
65
+ # SolarWindsAPM::SDK.log_exception()
66
+ # This method adds an error event to the trace, which will be
67
+ # displayed and counted as exception on the solarwinds_apm dashboard.
68
+
69
+ def do_raise
70
+ raise StandardError.new("oops")
71
+ end
72
+
73
+ SolarWindsAPM::SDK.start_trace('with_error') do
74
+ begin
75
+ do_raise
76
+ rescue => e
77
+ SolarWindsAPM::SDK.log_exception(e)
78
+ end
79
+ end
80
+
81
+ ###############################################################
82
+ # TRACE A METHOD
83
+ ###############################################################
84
+ #
85
+ # SolarWindsAPM::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
+ SolarWindsAPM::SDK.trace_method(ExampleModule,
97
+ :do_sum,
98
+ config: { name: 'computation', backtrace: true },
99
+ kvs: { CustomKey: "some_info" })
100
+
101
+ SolarWindsAPM::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
+ # SolarWindsAPM::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
+ SolarWindsAPM::SDK.set_transaction_name("fake.#{params[:type]}")
121
+ # redirect_to @fake
122
+ end
123
+ end
124
+
125
+ SolarWindsAPM::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
+ # SolarWindsAPM::SDK.current_trace_info
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
+ SolarWindsAPM::Config[:log_traceId] = :always
138
+
139
+ SolarWindsAPM::SDK.start_trace('log_trace_id') do
140
+ trace = SolarWindsAPM::SDK.current_trace_info
141
+ SolarWindsAPM.logger.warn "Some log message #{trace.for_log}"
142
+ end
143
+
144
+ ###############################################################
145
+ # START A TRACE AND PROFILE
146
+ ###############################################################
147
+ #
148
+ # SolarWindsAPM::Profiling.run
149
+ # This method adds profiling for the code executed in the block
150
+
151
+ SolarWindsAPM::SDK.start_trace("#{name}_profiling") do
152
+ SolarWindsAPM::Profiling.run do
153
+ 10.times do
154
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
155
+ sleep 0.2
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,69 @@
1
+ # Debug the c-code with gdb
2
+
3
+ inspired by: https://dev.to/wataash/how-to-create-and-debug-ruby-gem-with-c-native-extension-3l8b
4
+
5
+
6
+ ## install ruby with sources
7
+
8
+ rbenv is your friend ;) -k means keep sources
9
+
10
+ ```
11
+ rbenv install -k 2.7.5
12
+ rbenv shell 2.7.5
13
+
14
+ # check that ruby is debuggable
15
+ type ruby # => ruby is /home/wsh/.rbenv/shims/ruby
16
+ rbenv which ruby # => /home/wsh/.rbenv/versions/2.6.3/bin/ruby
17
+ ```
18
+
19
+
20
+ ##
21
+ ## add debug info when compiling solarwinds_apm
22
+ add this line to extconf.rb to turn off optimization
23
+
24
+ ```
25
+ CONFIG["optflags"] = "-O0"
26
+ ```
27
+
28
+
29
+ ##
30
+ ## start ruby app with gdb
31
+
32
+ This will run ruby and load the app with a breakpoint in the Reporter::startThread
33
+ c-function.
34
+
35
+ `bundle exec gdb -q -ex 'set breakpoint pending on' -ex 'b Reporter::startThread' -ex run --args ruby -e 'require "./app"'`
36
+
37
+ If there is a bug in the ruby code or a ruby byebug binding that halts the
38
+ script, the debugger will hang without showing any output.
39
+ So, make sure `bundle exec ruby app.rb` runs.
40
+
41
+ use the gdb navigation commands to step through the code. If it says:
42
+
43
+ ```
44
+ (gdb) n
45
+ Single stepping until exit from function _ZN8Reporter11startThreadEv@plt,
46
+ which has no line number information.
47
+ ```
48
+
49
+ type `c` and it may end up stopping in the right location.
50
+
51
+ ##
52
+ ## make ruby .gdbinit macros available
53
+
54
+ These macros are pretty elaborate. They are checked in the ruby github
55
+ repo: https://github.com/ruby/ruby/blob/master/.gdbinit
56
+ The code is nicely formatted and colorized in github and easiest to read there.
57
+
58
+ installation in the user's home dir:
59
+ ```
60
+ wget https://github.com/ruby/ruby/blob/master/.gdbinit
61
+ ```
62
+ ##
63
+ ## examples
64
+
65
+ Some inspiring examples here:
66
+
67
+ https://jvns.ca/blog/2016/06/12/a-weird-system-call-process-vm-readv/
68
+
69
+ https://medium.com/@zanker/finding-a-ruby-bug-with-gdb-56d6b321bc86
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2016 SolarWinds, LLC.
4
+ # All rights reserved.
5
+
6
+ require 'mkmf'
7
+ require 'rbconfig'
8
+ require 'open-uri'
9
+ require 'no_proxy_fix'
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
+
21
+ ext_dir = File.expand_path(File.dirname(__FILE__))
22
+
23
+ # Set the mkmf lib paths so we have no issues linking to
24
+ # the SolarWindsAPM libs.
25
+ ao_lib_dir = File.join(ext_dir, 'lib')
26
+ ao_include = File.join(ext_dir, 'src')
27
+
28
+ # Download the appropriate liboboe from S3(via rake for testing) or files.appoptics.com (production)
29
+ version = File.read(File.join(ao_include, 'VERSION')).strip
30
+ if ENV['OBOE_FROM_S3'].to_s.downcase == 'true'
31
+ ao_path = File.join('https://rc-files-t2.s3-us-west-2.amazonaws.com/c-lib/', version)
32
+ puts 'Fetching c-lib from S3'
33
+ else
34
+ ao_path = File.join('https://files.appoptics.com/c-lib', version)
35
+ end
36
+
37
+ ao_arch = 'x86_64'
38
+ if File.exist?('/etc/alpine-release')
39
+ version = File.read('/etc/alpine-release').strip
40
+
41
+ ao_arch =
42
+ if Gem::Version.new(version) < Gem::Version.new('3.9')
43
+ 'alpine-libressl-x86_64'
44
+ else # openssl
45
+ 'alpine-x86_64'
46
+ end
47
+ end
48
+
49
+ ao_clib = "liboboe-1.0-#{ao_arch}.so.0.0.0"
50
+ ao_item = File.join(ao_path, ao_clib)
51
+ ao_checksum_file = File.join(ao_lib_dir, "#{ao_clib}.sha256")
52
+ clib = File.join(ao_lib_dir, ao_clib)
53
+
54
+ retries = 3
55
+ success = false
56
+ while retries > 0
57
+ begin
58
+ download = URI.open(ao_item, 'rb')
59
+ IO.copy_stream(download, clib)
60
+
61
+ clib_checksum = Digest::SHA256.file(clib).hexdigest
62
+ download.close
63
+ checksum = File.read(ao_checksum_file).strip
64
+
65
+ # unfortunately these messages only show if the install command is run
66
+ # with the `--verbose` flag
67
+ if clib_checksum != checksum
68
+ $stderr.puts '== ERROR ================================================================='
69
+ $stderr.puts 'Checksum Verification failed for the c-extension of the solarwinds_apm gem'
70
+ $stderr.puts 'Installation cannot continue'
71
+ $stderr.puts "\nChecksum packaged with gem: #{checksum}"
72
+ $stderr.puts "Checksum calculated from lib: #{clib_checksum}"
73
+ $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists'
74
+ $stderr.puts '=========================================================================='
75
+ exit 1
76
+ else
77
+ success = true
78
+ retries = 0
79
+ end
80
+ rescue => e
81
+ File.write(clib, '')
82
+ retries -= 1
83
+ if retries == 0
84
+ $stderr.puts '== ERROR =========================================================='
85
+ $stderr.puts 'Download of the c-extension for the solarwinds_apm gem failed.'
86
+ $stderr.puts 'solarwinds_apm will not instrument the code. No tracing will occur.'
87
+ $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists.'
88
+ $stderr.puts "error: #{ao_item}\n#{e.message}"
89
+ $stderr.puts '==================================================================='
90
+ create_makefile('oboe_noop', 'noop')
91
+ end
92
+ sleep 0.5
93
+ end
94
+ end
95
+
96
+ if success
97
+ # Create relative symlinks for the SolarWindsAPM library
98
+ Dir.chdir(ao_lib_dir) do
99
+ File.symlink(ao_clib, 'liboboe.so')
100
+ File.symlink(ao_clib, 'liboboe-1.0.so.0')
101
+ end
102
+
103
+ dir_config('oboe', 'src', 'lib')
104
+
105
+ # create Makefile
106
+ if have_library('oboe', 'oboe_config_get_revision', 'oboe.h')
107
+ $libs = append_library($libs, 'oboe')
108
+ $libs = append_library($libs, 'stdc++')
109
+
110
+ $CFLAGS << " #{ENV['CFLAGS']}"
111
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11"
112
+ # TODO for debugging: -pg -gdwarf-2, remove for production
113
+ # -pg does not work on alpine https://www.openwall.com/lists/musl/2014/11/05/2
114
+ $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/include -I$$ORIGIN/../ext/oboe_metal/src"
115
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/include"
116
+ $LIBS << " #{ENV['LIBS']}"
117
+
118
+ # use "z,defs" to see what happens during linking
119
+ # $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib,-z,defs' -lrt"
120
+ $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib' -lrt"
121
+ $CXXFLAGS += " -std=c++11 "
122
+
123
+ # ____ include debug info, comment out when not debugging
124
+ # ____ -pg -> profiling info for gprof
125
+ CONFIG["debugflags"] = "-ggdb3 "
126
+ CONFIG["optflags"] = "-O0"
127
+
128
+ create_makefile('libsolarwinds_apm', 'src')
129
+ else
130
+ $stderr.puts '== ERROR ========================================================='
131
+ if have_library('oboe')
132
+ $stderr.puts "The c-library either needs to be updated or doesn't match the OS."
133
+ $stderr.puts 'No tracing will occur.'
134
+ else
135
+ $stderr.puts 'Could not find a matching c-library. No tracing will occur.'
136
+ end
137
+ $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists.'
138
+ $stderr.puts '=================================================================='
139
+ create_makefile('oboe_noop', 'noop')
140
+ end
141
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2016 SolarWinds, LLC.
4
+ # All rights reserved.
5
+
6
+ require 'mkmf'
7
+ require 'rbconfig'
8
+ require 'open-uri'
9
+ require 'no_proxy_fix'
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
+
21
+ ext_dir = File.expand_path(File.dirname(__FILE__))
22
+
23
+ # Set the mkmf lib paths so we have no issues linking to
24
+ # the SolarWindsAPM libs.
25
+ ao_lib_dir = File.join(ext_dir, 'lib')
26
+ ao_path = '../../../oboe/factory-output'
27
+ ao_clib = "liboboe-1.0-x86_64.so.0.0.0"
28
+ ao_item = File.join(ao_path, ao_clib)
29
+ clib = File.join(ao_lib_dir, ao_clib)
30
+
31
+ FileUtils.cp(ao_item, clib)
32
+
33
+ # Create relative symlinks for the SolarWindsAPM library
34
+ Dir.chdir(ao_lib_dir) do
35
+ File.symlink(ao_clib, 'liboboe.so')
36
+ File.symlink(ao_clib, 'liboboe-1.0.so.0')
37
+ end
38
+
39
+ dir_config('oboe', 'src', 'lib')
40
+
41
+ if have_library('oboe', 'oboe_config_get_revision', 'oboe.h')
42
+ $libs = append_library($libs, 'oboe')
43
+ $libs = append_library($libs, 'stdc++')
44
+
45
+ $CFLAGS << " #{ENV['CFLAGS']}"
46
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11"
47
+ # TODO for debugging: -pg -gdwarf-2, remove for production
48
+ # -pg does not work on alpine https://www.openwall.com/lists/musl/2014/11/05/2
49
+ $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/include -I$$ORIGIN/../ext/oboe_metal/src"
50
+ # $CPPFLAGS << " #{ENV['CPPFLAGS']} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/include"
51
+ $LIBS << " #{ENV['LIBS']}"
52
+
53
+ # use "z,defs" to see what happens during linking
54
+ # $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib,-z,defs' -lrt"
55
+ $LDFLAGS << " #{ENV['LDFLAGS']} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib' -lrt"
56
+ $CXXFLAGS += " -std=c++11 "
57
+
58
+ # ____ include debug info, comment out when not debugging
59
+ # ____ -pg -> profiling info for gprof
60
+ CONFIG["debugflags"] = "-ggdb3 "
61
+ CONFIG["optflags"] = "-O0"
62
+
63
+ create_makefile('libsolarwinds_apm', 'src')
64
+ else
65
+ $stderr.puts '== ERROR ========================================================='
66
+ if have_library('oboe')
67
+ $stderr.puts "The c-library either needs to be updated or doesn't match the OS."
68
+ $stderr.puts 'No tracing will occur.'
69
+ else
70
+ $stderr.puts 'Could not find a matching c-library. No tracing will occur.'
71
+ end
72
+ $stderr.puts 'Contact technicalsupport@solarwinds.com if the problem persists.'
73
+ $stderr.puts '=================================================================='
74
+ create_makefile('oboe_noop', 'noop')
75
+ end
File without changes
@@ -0,0 +1 @@
1
+ 32deed8447ef3b97ed92efe062c2c2c609458978ce8760b29e343cc60c3f93e6
@@ -0,0 +1 @@
1
+ 34b3413d417ff9c6c9b19b77cf335294a8cd04132d224651aba2706bdd6dff2f
@@ -0,0 +1,8 @@
1
+ #include <ruby.h>
2
+
3
+ /* ruby calls this to load the extension */
4
+ void Init_oboe_noop(void) {
5
+ /* assume we haven't yet defined Hola */
6
+ // VALUE klass = rb_define_class("OboeNoop", rb_cObject);
7
+ rb_define_class("OboeNoop", rb_cObject);
8
+ }
@@ -0,0 +1,6 @@
1
+
2
+ oboe_api.hpp and oboe_api.cpp are copied here from the oboe repo during install
3
+
4
+ it is best to edit these file in the oboe codebase and use the OBOE_WIP=true env
5
+ var to include the local development version while the changes aren't deployed to s3.
6
+
@@ -0,0 +1,2 @@
1
+ 10.3.3
2
+