appsignal 4.0.6 → 4.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/ext/agent.rb +27 -27
  6. data/lib/appsignal/check_in.rb +1 -1
  7. data/lib/appsignal/config.rb +1 -3
  8. data/lib/appsignal/integrations/resque.rb +1 -6
  9. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  10. data/lib/appsignal/version.rb +1 -1
  11. data/lib/appsignal.rb +10 -8
  12. metadata +2 -192
  13. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  14. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  15. data/.github/workflows/ci.yml +0 -3285
  16. data/.github/workflows/create_release_from_tag.yml +0 -62
  17. data/.gitignore +0 -35
  18. data/.gitmodules +0 -3
  19. data/.rspec +0 -4
  20. data/.yardopts +0 -8
  21. data/benchmark.rake +0 -139
  22. data/gemfiles/capistrano2.gemfile +0 -6
  23. data/gemfiles/capistrano3.gemfile +0 -7
  24. data/gemfiles/dry-monitor.gemfile +0 -5
  25. data/gemfiles/grape.gemfile +0 -5
  26. data/gemfiles/hanami-2.0.gemfile +0 -7
  27. data/gemfiles/hanami-2.1.gemfile +0 -7
  28. data/gemfiles/http5.gemfile +0 -5
  29. data/gemfiles/no_dependencies.gemfile +0 -10
  30. data/gemfiles/padrino.gemfile +0 -7
  31. data/gemfiles/psych-3.gemfile +0 -5
  32. data/gemfiles/psych-4.gemfile +0 -5
  33. data/gemfiles/que-1.gemfile +0 -5
  34. data/gemfiles/que-2.gemfile +0 -5
  35. data/gemfiles/rails-6.0.gemfile +0 -10
  36. data/gemfiles/rails-6.1.gemfile +0 -11
  37. data/gemfiles/rails-7.0.gemfile +0 -11
  38. data/gemfiles/rails-7.1.gemfile +0 -11
  39. data/gemfiles/rails-7.2.gemfile +0 -11
  40. data/gemfiles/redis-4.gemfile +0 -5
  41. data/gemfiles/redis-5.gemfile +0 -6
  42. data/gemfiles/resque-2.gemfile +0 -6
  43. data/gemfiles/sequel.gemfile +0 -10
  44. data/gemfiles/sinatra.gemfile +0 -5
  45. data/gemfiles/webmachine1.gemfile +0 -7
  46. data/gemfiles/webmachine2.gemfile +0 -6
  47. data/mono.yml +0 -16
  48. data/spec/.rubocop.yml +0 -7
  49. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  50. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  51. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  52. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -210
  53. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
  54. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  55. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  56. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  57. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  58. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  59. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  60. data/spec/lib/appsignal/cli_spec.rb +0 -56
  61. data/spec/lib/appsignal/config_spec.rb +0 -1380
  62. data/spec/lib/appsignal/demo_spec.rb +0 -83
  63. data/spec/lib/appsignal/environment_spec.rb +0 -190
  64. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  65. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  66. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  67. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  68. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  69. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  70. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  71. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  72. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  73. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  74. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  75. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  76. data/spec/lib/appsignal/extension_spec.rb +0 -178
  77. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  78. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  79. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  80. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  81. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  82. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  83. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  84. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  85. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  86. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  87. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  88. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  89. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  90. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  91. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  92. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  93. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  94. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  95. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  96. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  97. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  98. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  99. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  100. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  101. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  102. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  103. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  104. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  105. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  106. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  107. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  108. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  109. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  110. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  111. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  112. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  113. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  114. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  115. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  116. data/spec/lib/appsignal/integrations/que_spec.rb +0 -187
  117. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  118. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  119. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  120. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  121. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  122. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  123. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  124. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  125. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  126. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  127. data/spec/lib/appsignal/logger_spec.rb +0 -205
  128. data/spec/lib/appsignal/marker_spec.rb +0 -51
  129. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  130. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  131. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  132. data/spec/lib/appsignal/probes_spec.rb +0 -414
  133. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  134. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  135. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  136. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  137. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  138. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  139. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  140. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  141. data/spec/lib/appsignal/rack_spec.rb +0 -243
  142. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  143. data/spec/lib/appsignal/span_spec.rb +0 -141
  144. data/spec/lib/appsignal/system_spec.rb +0 -126
  145. data/spec/lib/appsignal/transaction_spec.rb +0 -2115
  146. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  147. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  148. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  149. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  150. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  151. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  152. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  153. data/spec/lib/appsignal_spec.rb +0 -1919
  154. data/spec/lib/puma/appsignal_spec.rb +0 -334
  155. data/spec/spec_helper.rb +0 -179
  156. data/spec/support/fixtures/generated_config.yml +0 -24
  157. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  158. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  159. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  160. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  162. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  163. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  164. data/spec/support/fixtures/uploaded_file.txt +0 -0
  165. data/spec/support/hanami/hanami_app.rb +0 -29
  166. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  167. data/spec/support/helpers/activejob_helpers.rb +0 -27
  168. data/spec/support/helpers/api_request_helper.rb +0 -60
  169. data/spec/support/helpers/cli_helpers.rb +0 -40
  170. data/spec/support/helpers/config_helpers.rb +0 -66
  171. data/spec/support/helpers/dependency_helper.rb +0 -155
  172. data/spec/support/helpers/directory_helper.rb +0 -27
  173. data/spec/support/helpers/env_helpers.rb +0 -41
  174. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  175. data/spec/support/helpers/example_exception.rb +0 -13
  176. data/spec/support/helpers/example_standard_error.rb +0 -13
  177. data/spec/support/helpers/loader_helper.rb +0 -21
  178. data/spec/support/helpers/log_helpers.rb +0 -36
  179. data/spec/support/helpers/rails_helper.rb +0 -28
  180. data/spec/support/helpers/std_streams_helper.rb +0 -94
  181. data/spec/support/helpers/system_helpers.rb +0 -8
  182. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  183. data/spec/support/helpers/time_helpers.rb +0 -11
  184. data/spec/support/helpers/transaction_helpers.rb +0 -122
  185. data/spec/support/helpers/wait_for_helper.rb +0 -39
  186. data/spec/support/matchers/contains_log.rb +0 -26
  187. data/spec/support/matchers/have_colorized_text.rb +0 -28
  188. data/spec/support/matchers/transaction.rb +0 -200
  189. data/spec/support/mocks/appsignal_mock.rb +0 -18
  190. data/spec/support/mocks/dummy_app.rb +0 -20
  191. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  192. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  193. data/spec/support/mocks/hash_like.rb +0 -10
  194. data/spec/support/mocks/mock_probe.rb +0 -13
  195. data/spec/support/mocks/puma_mock.rb +0 -43
  196. data/spec/support/shared_examples/instrument.rb +0 -48
  197. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  198. data/spec/support/stubs/delayed_job.rb +0 -0
  199. data/spec/support/stubs/sidekiq/api.rb +0 -4
  200. data/spec/support/testing.rb +0 -203
  201. data/support/bundler_wrapper +0 -12
  202. data/support/install_deps +0 -33
@@ -1,238 +0,0 @@
1
- describe Appsignal::SampleData do
2
- let(:data) { described_class.new(:data_key) }
3
-
4
- describe "#add" do
5
- it "sets the given value" do
6
- logs =
7
- capture_logs do
8
- data.add(:key1 => "value 1")
9
- end
10
-
11
- expect(data.value).to eq(:key1 => "value 1")
12
-
13
- expect(logs).to_not contains_log(
14
- :error,
15
- "Sample data 'data_key': Unsupported data type 'NilClass' received: nil"
16
- )
17
- end
18
-
19
- it "adds the given value with the block being leading" do
20
- data.add(:key1 => "value 1") { { :key2 => "value 2" } }
21
-
22
- expect(data.value).to eq(:key2 => "value 2")
23
- end
24
-
25
- it "doesn't add nil to the data" do
26
- logs =
27
- capture_logs do
28
- data.add([1])
29
- data.add(nil)
30
- data.add { nil }
31
- data.add([2, 3])
32
- end
33
-
34
- expect(data.value).to eq([1, 2, 3])
35
- expect(logs).to contains_log(
36
- :error,
37
- "Sample data 'data_key': Unsupported data type 'NilClass' received: nil"
38
- )
39
- expect(logs).to_not contains_log(:warn, "The sample data 'data_key' changed type")
40
- end
41
-
42
- it "merges multiple values" do
43
- data.add(:key1 => "value 1")
44
- data.add(:key2 => "value 2")
45
-
46
- expect(data.value).to eq(:key1 => "value 1", :key2 => "value 2")
47
- end
48
-
49
- it "merges only root level Hash keys" do
50
- data.add(:key => { :abc => "value" })
51
- data.add(:key => { :def => "value" })
52
-
53
- expect(data.value).to eq(:key => { :def => "value" })
54
- end
55
-
56
- it "merges values from arguments and blocks" do
57
- data.add(:key1 => "value 1")
58
- data.add { { :key2 => "value 2" } }
59
- data.add(:key3 => "value 3")
60
-
61
- expect(data.value).to eq(:key1 => "value 1", :key2 => "value 2", :key3 => "value 3")
62
- end
63
-
64
- it "merges array values" do
65
- data.add([:first_arg])
66
- data.add { [:from_block] }
67
- data.add([:second_arg])
68
-
69
- expect(data.value).to eq([:first_arg, :from_block, :second_arg])
70
- end
71
-
72
- it "overwrites the value if the new value is of a different type" do
73
- data.add(:key1 => "value 1")
74
- expect(data.value).to eq(:key1 => "value 1")
75
-
76
- data.add(["abc"])
77
- expect(data.value).to eq(["abc"])
78
-
79
- logs = capture_logs { data.value }
80
- expect(logs).to contains_log(
81
- :warn,
82
- "The sample data 'data_key' changed type from 'Hash' to 'Array'."
83
- )
84
- end
85
-
86
- it "ignores invalid values" do
87
- logs = capture_logs { data.add("string") }
88
- expect(data.value).to be_nil
89
- expect(logs).to contains_log(
90
- :error,
91
- "Sample data 'data_key': Unsupported data type 'String' received: \"string\""
92
- )
93
-
94
- set = Set.new
95
- set.add("abc")
96
- logs = capture_logs { data.add(set) }
97
- expect(data.value).to be_nil
98
- expect(logs).to contains_log(
99
- :error,
100
- "Sample data 'data_key': Unsupported data type 'Set' received: #<Set: {\"abc\"}>"
101
- )
102
-
103
- instance = Class.new
104
- logs = capture_logs { data.add(instance) }
105
- expect(data.value).to be_nil
106
- expect(logs).to contains_log(
107
- :error,
108
- "Sample data 'data_key': Unsupported data type 'Class' received: #<Class:"
109
- )
110
- end
111
-
112
- context "with a type specified" do
113
- it "only accepts values of Hash type" do
114
- data = described_class.new(:data_key, Hash)
115
-
116
- data.add(:key1 => "value 1")
117
- data.add(["abc"])
118
- data.add { { :key2 => "value 2" } }
119
- data.add { ["def"] }
120
- data.add(:key3 => "value 3")
121
-
122
- expect(data.value).to eq(:key1 => "value 1", :key2 => "value 2", :key3 => "value 3")
123
- end
124
-
125
- it "only accepts values of Array type" do
126
- data = described_class.new(:data_key, Array)
127
-
128
- data.add(:key1 => "value 1")
129
- data.add(["abc"])
130
- data.add { { :key2 => "value 2" } }
131
- data.add { ["def"] }
132
- data.add(:key3 => "value 3")
133
-
134
- expect(data.value).to eq(["abc", "def"])
135
- end
136
- end
137
- end
138
-
139
- describe "#value" do
140
- it "caches the block value after calling it once" do
141
- Appsignal::Testing.store[:block_call] = 0
142
- data.add do
143
- Appsignal::Testing.store[:block_call] += 1
144
- { :key => "value" }
145
- end
146
-
147
- expect(data.value).to eq(:key => "value")
148
- data.value
149
-
150
- expect(Appsignal::Testing.store[:block_call]).to eq(1)
151
- end
152
- end
153
-
154
- describe "#value?" do
155
- it "returns true when value is set" do
156
- data.add(["abc"])
157
- expect(data.value?).to be_truthy
158
- end
159
-
160
- it "returns true when value is set with a block" do
161
- data.add { ["abc"] }
162
- expect(data.value?).to be_truthy
163
- end
164
-
165
- it "returns false when the value is not set" do
166
- expect(data.value?).to be_falsey
167
- end
168
- end
169
-
170
- describe "#set_empty_value!" do
171
- it "clears the set values" do
172
- data.add(["abc"])
173
- data.add(["def"])
174
- data.set_empty_value!
175
-
176
- expect(data.value).to be_nil
177
- end
178
-
179
- it "allows values to be added afterwards" do
180
- data.add(["abc"])
181
- data.set_empty_value!
182
-
183
- expect(data.value).to be_nil
184
-
185
- data.add(["def"])
186
- expect(data.value).to eq(["def"])
187
- end
188
- end
189
-
190
- describe "#cleared?" do
191
- it "returns false if not cleared" do
192
- expect(data.empty?).to be(false)
193
- end
194
-
195
- it "returns true if cleared" do
196
- data.set_empty_value!
197
-
198
- expect(data.empty?).to be(true)
199
- end
200
-
201
- it "returns false if cleared and then new values were added" do
202
- data.set_empty_value!
203
- data.add(["abc"])
204
-
205
- expect(data.empty?).to be(false)
206
- end
207
- end
208
-
209
- describe "#duplicate" do
210
- it "duplicates the internal Hash state without modifying the original" do
211
- data = described_class.new(:my_key, Hash)
212
- data.add(:abc => :value)
213
-
214
- duplicate = data.dup
215
- duplicate.add(:def => :value)
216
-
217
- expect(data.value).to eq(:abc => :value)
218
- expect(duplicate.value).to eq(:abc => :value, :def => :value)
219
-
220
- expect(duplicate.instance_variable_get(:@key)).to eq(:my_key)
221
- expect(duplicate.instance_variable_get(:@accepted_type)).to eq(Hash)
222
- end
223
-
224
- it "duplicates the internal Array state without modifying the original" do
225
- data = described_class.new(:my_key, Array)
226
- data.add([:abc])
227
-
228
- duplicate = data.dup
229
- duplicate.add([:def])
230
-
231
- expect(data.value).to eq([:abc])
232
- expect(duplicate.value).to eq([:abc, :def])
233
-
234
- expect(duplicate.instance_variable_get(:@key)).to eq(:my_key)
235
- expect(duplicate.instance_variable_get(:@accepted_type)).to eq(Array)
236
- end
237
- end
238
- end
@@ -1,141 +0,0 @@
1
- require "appsignal/span"
2
-
3
- describe Appsignal::Span do
4
- before { start_agent }
5
-
6
- let(:namespace) { "web" }
7
- let(:root) { Appsignal::Span.new(namespace) }
8
-
9
- describe "creating a span" do
10
- it "creates an empty span" do
11
- expect(root.to_h["namespace"]).to eq "web"
12
- expect(root.to_h["trace_id"].length).to eq 16
13
- expect(root.to_h["span_id"].length).to eq 8
14
- expect(root.to_h["parent_span_id"]).to be_empty
15
- expect(root.to_h["name"]).to be_empty
16
- expect(root.to_h["start_time_seconds"]).to be > 1_600_000_000
17
- expect(root.to_h["start_time_nanoseconds"]).to be_kind_of(Numeric)
18
- expect(root.to_h["closed"]).to be false
19
- end
20
- end
21
-
22
- describe "#child" do
23
- let(:child) { root.child }
24
-
25
- it "creates a child span" do
26
- expect(child.to_h["namespace"]).to be_empty
27
- expect(child.to_h["trace_id"].length).to eq 16
28
- expect(child.to_h["span_id"].length).to eq 8
29
- expect(child.to_h["parent_span_id"]).to eq root.to_h["span_id"]
30
- expect(child.to_h["name"]).to be_empty
31
- expect(root.to_h["start_time_seconds"]).to be > 1_600_000_000
32
- expect(root.to_h["start_time_nanoseconds"]).to be_kind_of(Numeric)
33
- expect(child.to_h["closed"]).to be false
34
- end
35
- end
36
-
37
- describe "#add_error" do
38
- it "adds an error" do
39
- begin
40
- raise "Error"
41
- rescue => error
42
- root.add_error(error)
43
- end
44
-
45
- error = root.to_h["error"]
46
- expect(error["name"]).to eq "RuntimeError"
47
- expect(error["message"]).to eq "Error"
48
- expect(error["backtrace_json"]).not_to be_empty
49
- end
50
- end
51
-
52
- describe "set_sample_data" do
53
- it "sets sample data" do
54
- root.set_sample_data(:params, "key" => "value")
55
-
56
- sample_data = root.to_h["sample_data"]
57
- expect(sample_data["params"]).to eq "{\"key\":\"value\"}"
58
- end
59
- end
60
-
61
- describe "#name=" do
62
- it "sets the name" do
63
- root.name = "Span name"
64
-
65
- expect(root.to_h["name"]).to eq "Span name"
66
- end
67
- end
68
-
69
- describe "#[]=" do
70
- let(:attributes) { root.to_h["attributes"] }
71
-
72
- it "sets a string attribute" do
73
- root["string"] = "attribute"
74
-
75
- expect(attributes["string"]).to eq "attribute"
76
- end
77
-
78
- it "sets an integer attribute" do
79
- root["integer"] = 1001
80
-
81
- expect(attributes["integer"]).to eq 1001
82
- end
83
-
84
- it "sets a bigint attribute" do
85
- root["bigint"] = 1 << 64
86
-
87
- expect(attributes["bigint"]).to eq "bigint:#{1 << 64}"
88
- end
89
-
90
- it "sets a boolean attribute" do
91
- root["true"] = true
92
- root["false"] = false
93
-
94
- expect(attributes["true"]).to eq true
95
- expect(attributes["false"]).to eq false
96
- end
97
-
98
- it "sets a float attribute" do
99
- root["float"] = 10.01
100
-
101
- expect(attributes["float"]).to eq 10.01
102
- end
103
-
104
- it "raises an error for other types" do
105
- expect do
106
- root["something"] = Object.new
107
- end.to raise_error TypeError
108
- end
109
- end
110
-
111
- describe "#instrument" do
112
- it "closes the span after yielding" do
113
- root.instrument do
114
- # Nothing happening
115
- end
116
- expect(root.closed?).to eq true
117
- end
118
-
119
- context "with an error raised in the passed block" do
120
- it "closes the span after yielding" do
121
- expect do
122
- root.instrument do
123
- raise ExampleException, "foo"
124
- end
125
- end.to raise_error(ExampleException, "foo")
126
- expect(root.closed?).to eq true
127
- end
128
- end
129
- end
130
-
131
- describe "#close" do
132
- it "closes a span" do
133
- expect(root.closed?).to eq false
134
-
135
- root.close
136
-
137
- expect(root.to_h).to be_nil
138
- expect(root.closed?).to eq true
139
- end
140
- end
141
- end
@@ -1,126 +0,0 @@
1
- require "appsignal/system"
2
-
3
- describe Appsignal::System do
4
- describe ".heroku?" do
5
- subject { described_class.heroku? }
6
-
7
- context "when on Heroku" do
8
- around { |example| recognize_as_heroku { example.run } }
9
-
10
- it "returns true" do
11
- is_expected.to eq(true)
12
- end
13
- end
14
-
15
- context "when not on Heroku" do
16
- it "returns false" do
17
- is_expected.to eq(false)
18
- end
19
- end
20
- end
21
-
22
- describe ".agent_platform" do
23
- let(:os) { "linux-gnu" }
24
- let(:ldd_output) { "" }
25
- before do
26
- allow(described_class).to receive(:ldd_version_output).and_return(ldd_output)
27
- allow(RbConfig::CONFIG).to receive(:[])
28
- allow(RbConfig::CONFIG).to receive(:[]).with("host_os").and_return(os)
29
- end
30
- subject { described_class.agent_platform }
31
-
32
- context "when the system detection doesn't work" do
33
- it "returns the libc build" do
34
- is_expected.to eq("linux")
35
- end
36
- end
37
-
38
- context "when using the APPSIGNAL_BUILD_FOR_MUSL env var" do
39
- it "returns the musl build" do
40
- ENV["APPSIGNAL_BUILD_FOR_MUSL"] = "1"
41
- is_expected.to eq("linux-musl")
42
- ENV.delete("APPSIGNAL_BUILD_FOR_MUSL")
43
- end
44
- end
45
-
46
- context "when using the APPSIGNAL_BUILD_FOR_LINUX_ARM env var" do
47
- it "returns the linux build" do
48
- ENV["APPSIGNAL_BUILD_FOR_LINUX_ARM"] = "1"
49
- is_expected.to eq("linux")
50
- ENV.delete("APPSIGNAL_BUILD_FOR_LINUX_ARM")
51
- end
52
- end
53
-
54
- context "when on a musl system" do
55
- let(:ldd_output) { "musl libc (x86_64)\nVersion 1.1.16" }
56
-
57
- it "returns the musl build" do
58
- is_expected.to eq("linux-musl")
59
- end
60
- end
61
-
62
- context "when on a libc system" do
63
- let(:ldd_output) { "ldd (Debian GLIBC 2.15-18+deb8u7) 2.15" }
64
-
65
- it "returns the libc build" do
66
- is_expected.to eq("linux")
67
- end
68
-
69
- context "when on an old libc system" do
70
- let(:ldd_output) { "ldd (Debian GLIBC 2.14-18+deb8u7) 2.14" }
71
-
72
- it "returns the musl build" do
73
- is_expected.to eq("linux-musl")
74
- end
75
- end
76
-
77
- context "when on a very old libc system" do
78
- let(:ldd_output) { "ldd (Debian GLIBC 2.5-18+deb8u7) 2.5" }
79
-
80
- it "returns the musl build" do
81
- is_expected.to eq("linux-musl")
82
- end
83
- end
84
- end
85
-
86
- context "when on macOS" do
87
- let(:os) { "darwin16.7.0" }
88
- let(:ldd_output) { "ldd: command not found" }
89
-
90
- it "returns the darwin build" do
91
- is_expected.to eq("darwin")
92
- end
93
- end
94
-
95
- context "when on FreeBSD" do
96
- let(:os) { "freebsd11" }
97
- let(:ldd_output) { "ldd: illegal option -- -" }
98
-
99
- it "returns the FreeBSD build" do
100
- is_expected.to eq("freebsd")
101
- end
102
- end
103
- end
104
-
105
- describe ".agent_architecture" do
106
- let(:architecture) { "x86_64" }
107
- let(:ldd_output) { "" }
108
- before do
109
- allow(RbConfig::CONFIG).to receive(:[])
110
- allow(RbConfig::CONFIG).to receive(:[]).with("host_cpu").and_return(architecture)
111
- end
112
- subject { described_class.agent_architecture }
113
-
114
- it "returns the host CPU value" do
115
- is_expected.to eq(architecture)
116
- end
117
-
118
- context "when using the APPSIGNAL_BUILD_FOR_LINUX_ARM env var" do
119
- it "returns ARM 64 bit" do
120
- ENV["APPSIGNAL_BUILD_FOR_LINUX_ARM"] = "1"
121
- is_expected.to eq("aarch64")
122
- ENV.delete("APPSIGNAL_BUILD_FOR_LINUX_ARM")
123
- end
124
- end
125
- end
126
- end