appoptics_apm-zearn 4.13.1

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.
Files changed (145) 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 +103 -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 +168 -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 +159 -0
  12. data/.gitignore +36 -0
  13. data/.rubocop.yml +29 -0
  14. data/.travis.yml +130 -0
  15. data/.yardopts +6 -0
  16. data/CHANGELOG.md +769 -0
  17. data/CONFIG.md +33 -0
  18. data/Gemfile +14 -0
  19. data/LICENSE +202 -0
  20. data/README.md +393 -0
  21. data/appoptics_apm.gemspec +70 -0
  22. data/bin/appoptics_apm_config +15 -0
  23. data/examples/prepend.rb +13 -0
  24. data/examples/sdk_examples.rb +158 -0
  25. data/ext/oboe_metal/README.md +69 -0
  26. data/ext/oboe_metal/extconf.rb +151 -0
  27. data/ext/oboe_metal/lib/.keep +0 -0
  28. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.0.0.0.sha256 +1 -0
  29. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256 +1 -0
  30. data/ext/oboe_metal/noop/noop.c +8 -0
  31. data/ext/oboe_metal/src/README.md +6 -0
  32. data/ext/oboe_metal/src/VERSION +2 -0
  33. data/ext/oboe_metal/src/bson/bson.h +220 -0
  34. data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
  35. data/ext/oboe_metal/src/frames.cc +246 -0
  36. data/ext/oboe_metal/src/frames.h +40 -0
  37. data/ext/oboe_metal/src/init_appoptics_apm.cc +21 -0
  38. data/ext/oboe_metal/src/logging.cc +95 -0
  39. data/ext/oboe_metal/src/logging.h +35 -0
  40. data/ext/oboe_metal/src/oboe.h +1156 -0
  41. data/ext/oboe_metal/src/oboe_api.cpp +652 -0
  42. data/ext/oboe_metal/src/oboe_api.hpp +431 -0
  43. data/ext/oboe_metal/src/oboe_debug.h +59 -0
  44. data/ext/oboe_metal/src/oboe_swig_wrap.cc +7329 -0
  45. data/ext/oboe_metal/src/profiling.cc +435 -0
  46. data/ext/oboe_metal/src/profiling.h +78 -0
  47. data/ext/oboe_metal/test/CMakeLists.txt +53 -0
  48. data/ext/oboe_metal/test/FindGMock.cmake +43 -0
  49. data/ext/oboe_metal/test/README.md +56 -0
  50. data/ext/oboe_metal/test/frames_test.cc +164 -0
  51. data/ext/oboe_metal/test/profiling_test.cc +93 -0
  52. data/ext/oboe_metal/test/ruby_inc_dir.rb +8 -0
  53. data/ext/oboe_metal/test/ruby_prefix.rb +8 -0
  54. data/ext/oboe_metal/test/ruby_test_helper.rb +67 -0
  55. data/ext/oboe_metal/test/test.h +11 -0
  56. data/ext/oboe_metal/test/test_main.cc +32 -0
  57. data/init.rb +4 -0
  58. data/lib/appoptics_apm/api/layerinit.rb +41 -0
  59. data/lib/appoptics_apm/api/logging.rb +381 -0
  60. data/lib/appoptics_apm/api/memcache.rb +37 -0
  61. data/lib/appoptics_apm/api/metrics.rb +63 -0
  62. data/lib/appoptics_apm/api/tracing.rb +57 -0
  63. data/lib/appoptics_apm/api/util.rb +120 -0
  64. data/lib/appoptics_apm/api.rb +21 -0
  65. data/lib/appoptics_apm/base.rb +231 -0
  66. data/lib/appoptics_apm/config.rb +299 -0
  67. data/lib/appoptics_apm/frameworks/grape.rb +98 -0
  68. data/lib/appoptics_apm/frameworks/padrino.rb +78 -0
  69. data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +104 -0
  70. data/lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb +48 -0
  71. data/lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb +50 -0
  72. data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
  73. data/lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb +50 -0
  74. data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +88 -0
  75. data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +27 -0
  76. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
  77. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +29 -0
  78. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +31 -0
  79. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +119 -0
  80. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +114 -0
  81. data/lib/appoptics_apm/frameworks/rails/inst/logger_formatters.rb +27 -0
  82. data/lib/appoptics_apm/frameworks/rails.rb +100 -0
  83. data/lib/appoptics_apm/frameworks/sinatra.rb +96 -0
  84. data/lib/appoptics_apm/inst/bunny-client.rb +148 -0
  85. data/lib/appoptics_apm/inst/bunny-consumer.rb +89 -0
  86. data/lib/appoptics_apm/inst/curb.rb +332 -0
  87. data/lib/appoptics_apm/inst/dalli.rb +85 -0
  88. data/lib/appoptics_apm/inst/delayed_job.rb +92 -0
  89. data/lib/appoptics_apm/inst/em-http-request.rb +101 -0
  90. data/lib/appoptics_apm/inst/excon.rb +125 -0
  91. data/lib/appoptics_apm/inst/faraday.rb +106 -0
  92. data/lib/appoptics_apm/inst/graphql.rb +240 -0
  93. data/lib/appoptics_apm/inst/grpc_client.rb +159 -0
  94. data/lib/appoptics_apm/inst/grpc_server.rb +120 -0
  95. data/lib/appoptics_apm/inst/http.rb +81 -0
  96. data/lib/appoptics_apm/inst/httpclient.rb +174 -0
  97. data/lib/appoptics_apm/inst/logger_formatter.rb +50 -0
  98. data/lib/appoptics_apm/inst/logging_log_event.rb +28 -0
  99. data/lib/appoptics_apm/inst/lumberjack_formatter.rb +13 -0
  100. data/lib/appoptics_apm/inst/memcached.rb +86 -0
  101. data/lib/appoptics_apm/inst/mongo.rb +246 -0
  102. data/lib/appoptics_apm/inst/mongo2.rb +225 -0
  103. data/lib/appoptics_apm/inst/moped.rb +466 -0
  104. data/lib/appoptics_apm/inst/rack.rb +182 -0
  105. data/lib/appoptics_apm/inst/rack_cache.rb +35 -0
  106. data/lib/appoptics_apm/inst/redis.rb +274 -0
  107. data/lib/appoptics_apm/inst/resque.rb +151 -0
  108. data/lib/appoptics_apm/inst/rest-client.rb +48 -0
  109. data/lib/appoptics_apm/inst/sequel.rb +178 -0
  110. data/lib/appoptics_apm/inst/sidekiq-client.rb +55 -0
  111. data/lib/appoptics_apm/inst/sidekiq-worker.rb +66 -0
  112. data/lib/appoptics_apm/inst/twitter-cassandra.rb +294 -0
  113. data/lib/appoptics_apm/inst/typhoeus.rb +108 -0
  114. data/lib/appoptics_apm/instrumentation.rb +22 -0
  115. data/lib/appoptics_apm/loading.rb +65 -0
  116. data/lib/appoptics_apm/logger.rb +14 -0
  117. data/lib/appoptics_apm/noop/README.md +9 -0
  118. data/lib/appoptics_apm/noop/context.rb +27 -0
  119. data/lib/appoptics_apm/noop/metadata.rb +25 -0
  120. data/lib/appoptics_apm/noop/profiling.rb +21 -0
  121. data/lib/appoptics_apm/oboe_init_options.rb +211 -0
  122. data/lib/appoptics_apm/ruby.rb +35 -0
  123. data/lib/appoptics_apm/sdk/current_trace.rb +77 -0
  124. data/lib/appoptics_apm/sdk/custom_metrics.rb +94 -0
  125. data/lib/appoptics_apm/sdk/logging.rb +37 -0
  126. data/lib/appoptics_apm/sdk/tracing.rb +434 -0
  127. data/lib/appoptics_apm/support/profiling.rb +18 -0
  128. data/lib/appoptics_apm/support/transaction_metrics.rb +67 -0
  129. data/lib/appoptics_apm/support/transaction_settings.rb +219 -0
  130. data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
  131. data/lib/appoptics_apm/support_report.rb +119 -0
  132. data/lib/appoptics_apm/test.rb +95 -0
  133. data/lib/appoptics_apm/thread_local.rb +26 -0
  134. data/lib/appoptics_apm/util.rb +326 -0
  135. data/lib/appoptics_apm/version.rb +16 -0
  136. data/lib/appoptics_apm/xtrace.rb +115 -0
  137. data/lib/appoptics_apm.rb +77 -0
  138. data/lib/joboe_metal.rb +212 -0
  139. data/lib/oboe.rb +7 -0
  140. data/lib/oboe_metal.rb +172 -0
  141. data/lib/rails/generators/appoptics_apm/install_generator.rb +47 -0
  142. data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +425 -0
  143. data/log/.keep +0 -0
  144. data/yardoc_frontpage.md +26 -0
  145. metadata +231 -0
@@ -0,0 +1,164 @@
1
+
2
+
3
+ #include <string.h>
4
+
5
+ #include <algorithm>
6
+
7
+ #include "../src/profiling.h"
8
+ #include "../src/frames.h"
9
+ #include "gtest/gtest.h"
10
+ #include "ruby/debug.h"
11
+ #include "ruby/ruby.h"
12
+ #include "test.h"
13
+
14
+ extern unordered_map<VALUE, FrameData> cached_frames;
15
+
16
+ static VALUE test_frames[BUF_SIZE];
17
+ static int test_lines[BUF_SIZE];
18
+ int test_num;
19
+
20
+ static int ruby_version;
21
+
22
+ VALUE RubyCallsFrames::c_get_frames() {
23
+ test_num = rb_profile_frames(1, sizeof(test_frames) / sizeof(VALUE), test_frames, test_lines);
24
+ return Qnil;
25
+ }
26
+
27
+ void Init_RubyCallsFrames() {
28
+ static VALUE cTest = rb_define_module("RubyCalls");
29
+ rb_define_singleton_method(cTest, "get_frames", reinterpret_cast<VALUE (*)(...)>(RubyCallsFrames::c_get_frames), 0);
30
+
31
+ VALUE result;
32
+ result = rb_eval_string("RUBY_VERSION[0].to_i");
33
+ ruby_version = NUM2INT(result);
34
+ };
35
+
36
+ TEST(Frames, reserve_cached_frames) {
37
+ // it should only reserve once used during init
38
+ // unordered_map grows automatically
39
+ cached_frames.clear();
40
+
41
+ Frames::reserve_cached_frames();
42
+ int bucket_count = cached_frames.bucket_count();
43
+
44
+ Frames::reserve_cached_frames();
45
+ EXPECT_EQ(bucket_count, cached_frames.bucket_count());
46
+ }
47
+
48
+ TEST(Frames, collect_frame_data) {
49
+ rb_eval_string("TestMe::Snapshot::all_kinds");
50
+
51
+ int num = Frames::remove_garbage(test_frames, test_num);
52
+
53
+ vector<FrameData> data;
54
+ // Ruby 3 reports a <cfunc>, before the "take_snapshot" method
55
+ // we have to adjust the index of the trace we are checking
56
+ int i = ruby_version == 2 ? 0 : 1;
57
+ Frames::collect_frame_data(test_frames, i + 1, data);
58
+
59
+ EXPECT_EQ("take_snapshot", data[i].method) << "method name incorrect";
60
+ EXPECT_EQ("TestMe::Snapshot", data[i].klass) << "klass name incorrect";
61
+ std::size_t found = data[i].file.find("ext/oboe_metal/test/ruby_test_helper.rb");
62
+ EXPECT_EQ(data[i].file.length() - 39, found)
63
+ << "filename incorrect " << found << " " << data[i].file.length();
64
+ EXPECT_EQ(7, data[i].lineno) << "line number incorrect";
65
+ }
66
+
67
+ TEST(Frames, remove_garbage) {
68
+ // run some Ruby code and get a snapshot
69
+ rb_eval_string("TestMe::Snapshot::all_kinds");
70
+
71
+ int num = Frames::remove_garbage(test_frames, test_num);
72
+
73
+ int expected = (ruby_version == 2) ? 7 : 9;
74
+ EXPECT_EQ(expected, num)
75
+ << "wrong number of expected frames after remove_garbage";
76
+ // check no lineno 0 frame at top
77
+ VALUE val;
78
+ int i = (ruby_version == 2) ? 0 : 1;
79
+ val = rb_profile_frame_first_lineno(test_frames[i]); // returns line number
80
+ if (RB_TYPE_P(val, T_FIXNUM)) {
81
+ EXPECT_NE(0, NUM2INT(val))
82
+ << "the frame with linenumber 0 was not removed";
83
+ } else {
84
+ EXPECT_TRUE(false) << " ************ line number not an int **********";
85
+ }
86
+ // check no repeated frames
87
+ for (i = 0; i < num; i++)
88
+ for (int j = i + 1; j < num; j++)
89
+ EXPECT_NE(test_frames[i], test_frames[j])
90
+ << "not all repeated frames were removed";
91
+ }
92
+
93
+ TEST(Frames, num_matching) {
94
+ VALUE a[BUF_SIZE];
95
+ VALUE b[BUF_SIZE];
96
+
97
+ int a_num = 0;
98
+ int b_num = 0;
99
+ EXPECT_EQ(0, Frames::num_matching(a, a_num, b, b_num))
100
+ << "* empty frames array should have 0 matches";
101
+
102
+ a[0] = (VALUE)11;
103
+ a[1] = (VALUE)12;
104
+ a[2] = (VALUE)13;
105
+ b[0] = (VALUE)11;
106
+ b[1] = (VALUE)12;
107
+ b[2] = (VALUE)13;
108
+ a_num = 3;
109
+ b_num = 3;
110
+ EXPECT_EQ(3, Frames::num_matching(a, a_num, b, b_num))
111
+ << "* equal frames array should have matched";
112
+
113
+ b[1] = (VALUE)222;
114
+ EXPECT_EQ(1, Frames::num_matching(a, a_num, b, b_num))
115
+ << "* only one should match for same length but different content";
116
+
117
+ b[1] = (VALUE)12;
118
+ a[3] = 14;
119
+ a_num = 4;
120
+ EXPECT_EQ(0, Frames::num_matching(a, a_num, b, b_num))
121
+ << "* different length, frames NOT matching from the end";
122
+
123
+ a[0] = 10;
124
+ a[1] = 11;
125
+ a[2] = 12;
126
+ a[3] = 13;
127
+ EXPECT_EQ(3, Frames::num_matching(a, a_num, b, b_num))
128
+ << "* different length, frames matching from the end";
129
+
130
+ b[0] = (VALUE)18;
131
+ b[1] = (VALUE)19;
132
+ b[2] = (VALUE)11;
133
+ b[3] = (VALUE)12;
134
+ b[4] = (VALUE)13;
135
+ b_num = 5;
136
+
137
+ EXPECT_EQ(3, Frames::num_matching(a, a_num, b, b_num))
138
+ << "* different length, frames matching from the end";
139
+ }
140
+
141
+ TEST(Frames, cached_frames) {
142
+ cached_frames.clear();
143
+ // run some Ruby code and get a snapshot
144
+ rb_eval_string("TestMe::Snapshot::all_kinds");
145
+
146
+ Frames::remove_garbage(test_frames, test_num);
147
+
148
+ // Check the expected size
149
+ int expected = (ruby_version == 2) ? 8 : 10;
150
+ EXPECT_EQ(expected, cached_frames.size());
151
+
152
+ // check that each frame is cached
153
+ for (int i = 0; i < test_num; i++)
154
+ EXPECT_EQ(1, cached_frames.count(test_frames[i]));
155
+
156
+ // repeat
157
+ rb_eval_string("TestMe::Snapshot::all_kinds");
158
+ Frames::remove_garbage(test_frames, test_num);
159
+
160
+ expected = (ruby_version == 2) ? 9 : 11;
161
+ EXPECT_EQ(expected, cached_frames.size()); // +1 for an extra main frame
162
+ for (int i = 0; i < test_num; i++)
163
+ EXPECT_EQ(1, cached_frames.count(test_frames[i]));
164
+ }
@@ -0,0 +1,93 @@
1
+
2
+ #include "../src/frames.h"
3
+
4
+ #include <string.h>
5
+
6
+ #include <algorithm>
7
+ #include <thread>
8
+ #include <array>
9
+
10
+ #include "../src/profiling.h"
11
+ #include "gtest/gtest.h"
12
+ #include "ruby/debug.h"
13
+ #include "ruby/ruby.h"
14
+ #include "test.h"
15
+
16
+ extern atomic_bool profiling_shut_down;
17
+ // extern oboe_reporter_t *cur_reporter;
18
+
19
+ // FIXME how can I access profiling_shut_down ?
20
+ TEST(Profiling, try_catch_shutdown) {
21
+ EXPECT_FALSE(profiling_shut_down);
22
+
23
+ int result;
24
+ result = Profiling::try_catch_shutdown([] {
25
+ // provoke exception
26
+ std::string ().replace (100, 1, 1, 'c');
27
+ return 0;
28
+ }, "Profiling::try_catch()");
29
+
30
+ EXPECT_NE(0, result);
31
+ EXPECT_TRUE(profiling_shut_down);
32
+
33
+ // reset global var
34
+ profiling_shut_down = false;
35
+ }
36
+
37
+ TEST(Profiling, oboe_0_profiling) {
38
+ atomic_bool atomic_a1{true};
39
+ atomic_bool atomic_a2{false};
40
+
41
+ atomic_bool running;
42
+
43
+ cout << running << endl;
44
+ cout << running.exchange(true) << endl;
45
+ cout << running.exchange(true) << endl;
46
+
47
+ // cout << "prev val " << atomic_a2.exchange(false) << endl;
48
+ // cout << atomic_a2 << endl;
49
+ // cout << "prev val " << atomic_a2.exchange(true) << endl;
50
+ // cout << atomic_a2 << endl;
51
+ // cout << "prev val " << atomic_a2.exchange(true) << endl;
52
+ // cout << atomic_a2 << endl;
53
+ // cout << "prev val " << atomic_a2.exchange(false) << endl;
54
+ // cout << atomic_a2 << endl;
55
+
56
+
57
+
58
+ // static bool b1{true};
59
+ // static bool b2{false};
60
+
61
+ // array<thread, 4> threads;
62
+
63
+ // for (auto& t : threads) {
64
+ // t = thread([] { Profiling::profiler_signal_handler(0, NULL, NULL); });
65
+ // }
66
+
67
+ // cout << "waiting..." << endl;
68
+
69
+ // for (auto& t : threads) {
70
+ // t.join();
71
+ // }
72
+
73
+ // cout << "Done." << endl;
74
+
75
+
76
+ // cout << atomic_a1 << ", " << b1 << endl;
77
+ // cout << atomic_a1 << ", " << b1 << ", " << atomic_a1.compare_exchange_weak(b1, false) << endl;
78
+ // cout << atomic_a1 << ", " << b1 << endl;
79
+ // cout << atomic_a2 << ", " << b2 << endl;
80
+ // cout << atomic_a2 << ", " << b2 << ", " << atomic_a2.compare_exchange_weak(b2, true) << endl;
81
+ // cout << atomic_a2 << ", " << b2 << endl;
82
+ // cout << endl;
83
+
84
+ // cout << atomic_a1 << ", " << b1 << endl;
85
+ // cout << atomic_a1 << ", " << b1 << ", " << atomic_a1.compare_exchange_weak(b1, false) << endl;
86
+ // cout << atomic_a1 << ", " << b1 << endl;
87
+ // cout << atomic_a2 << ", " << b2 << endl;
88
+ // cout << atomic_a2 << ", " << b2 << ", " << atomic_a2.compare_exchange_weak(b2, true) << endl;
89
+ // cout << atomic_a2 << ", " << b2 << endl;
90
+ // cout << endl;
91
+
92
+
93
+ }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2021 SolarWinds, LLC.
4
+ # All rights reserved.
5
+
6
+ require 'mkmf'
7
+ puts $topdir
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2021 SolarWinds, LLC.
4
+ # All rights reserved.
5
+
6
+ require 'mkmf'
7
+ puts CONFIG["prefix"]
8
+
@@ -0,0 +1,67 @@
1
+ class TestMe
2
+ class Snapshot
3
+
4
+ class << self
5
+ # !!! do not shift the definition of take_snapshot from line 7 !!!
6
+ # the line number is used to verify a test in frames_test.cc
7
+ def take_snapshot
8
+ # puts "getting frames ...."
9
+ begin
10
+ ::RubyCalls::get_frames
11
+ rescue => e
12
+ puts "oops, getting frames didn't work"
13
+ puts e
14
+ end
15
+ end
16
+
17
+ def all_kinds
18
+ begin
19
+ Teddy.new.sing do
20
+ take_snapshot
21
+ end
22
+ rescue => e
23
+ puts "Ruby call did not work"
24
+ puts e
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ class Teddy
31
+
32
+ attr_accessor :name
33
+
34
+ def sing
35
+ 3.times do
36
+ yodel do
37
+ html_wrap("title", "Hello") { |_html| yield }
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def yodel
45
+ a_proc = -> (x) { x * x; yield }
46
+ in_block(&a_proc)
47
+ end
48
+
49
+ def in_block(&block)
50
+ begin
51
+ yield 7
52
+ # puts "block called!"
53
+ rescue => e
54
+ puts "no, this should never happen"
55
+ puts e
56
+ end
57
+ end
58
+
59
+ def html_wrap(tag, text)
60
+ html = "<#{tag}>#{text}</#{tag}>"
61
+ yield html
62
+ end
63
+
64
+ end
65
+ end
66
+
67
+
@@ -0,0 +1,11 @@
1
+ #ifndef TEST_H
2
+ #define TEST_H
3
+
4
+ class RubyCallsFrames {
5
+ public:
6
+ static VALUE c_get_frames();
7
+ };
8
+
9
+ void Init_RubyCallsFrames();
10
+
11
+ #endif //TEST_H
@@ -0,0 +1,32 @@
1
+ #include "gtest/gtest.h"
2
+ // #include "gmock/gmock.h"
3
+ #include <ruby/ruby.h>
4
+ #include "../src/profiling.h"
5
+ #include "../src/frames.h"
6
+ #include "test.h"
7
+
8
+ #ifndef FRAMES_BUFFER
9
+ #define FRAMES_BUFFER
10
+
11
+ using namespace std;
12
+
13
+ int main(int argc, char **argv) {
14
+ int state = -1;
15
+
16
+ // order important! init ruby before adding functions!
17
+ ruby_init();
18
+ Init_RubyCallsFrames();
19
+
20
+ // !!! if the require path is wrong, cmake will segfault !!!
21
+ string path(std::getenv("TEST_DIR"));
22
+ string cmd("require '" + path + "/" + "ruby_test_helper.rb" + "'");
23
+ rb_eval_string(cmd.c_str());
24
+
25
+ ::testing::InitGoogleTest(&argc, argv);
26
+
27
+ state = RUN_ALL_TESTS();
28
+
29
+ ruby_cleanup(0);
30
+ return state;
31
+ }
32
+ #endif //FRAMES_BUFFER
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ # Copyright (c) 2016 SolarWinds, LLC.
2
+ # All rights reserved.
3
+
4
+ require 'appoptics_apm'
@@ -0,0 +1,41 @@
1
+ #--
2
+ # Copyright (c) 2016 SolarWinds, LLC.
3
+ # All rights reserved.
4
+ #++
5
+
6
+ module AppOpticsAPM
7
+ module API
8
+ ##
9
+ # Provides methods related to layer initialization and reporting
10
+ module LayerInit #:nodoc:
11
+ # Internal: Report that instrumentation for the given layer has been
12
+ # installed, as well as the version of instrumentation and version of
13
+ # layer.
14
+ #
15
+ def report_init(layer = :rack) #:nodoc:
16
+ # Don't send __Init in test or if AppOpticsAPM
17
+ # isn't fully loaded (e.g. missing c-extension)
18
+ return if ENV.key?('APPOPTICS_GEM_TEST') || !AppOpticsAPM.loaded
19
+
20
+ platform_info = AppOpticsAPM::Util.build_init_report
21
+ log_init(layer, platform_info)
22
+ end
23
+
24
+ ##
25
+ # :nodoc:
26
+ # Deprecated:
27
+ # force_trace has been deprecated and will be removed in a subsequent version.
28
+ #
29
+ def force_trace
30
+ AppOpticsAPM.logger.warn '[appoptics_apm/api] AppOpticsAPM::API::LayerInit.force_trace has been deprecated and will be ' \
31
+ 'removed in a subsequent version.'
32
+
33
+ saved_mode = AppOpticsAPM::Config[:tracing_mode]
34
+ AppOpticsAPM::Config[:tracing_mode] = :enabled
35
+ yield
36
+ ensure
37
+ AppOpticsAPM::Config[:tracing_mode] = saved_mode
38
+ end
39
+ end
40
+ end
41
+ end