wd_newrelic_rpm 3.3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/CHANGELOG +591 -0
  2. data/LICENSE +64 -0
  3. data/README.rdoc +179 -0
  4. data/bin/mongrel_rpm +33 -0
  5. data/bin/newrelic +13 -0
  6. data/bin/newrelic_cmd +5 -0
  7. data/cert/cacert.pem +118 -0
  8. data/cert/oldsite.pem +28 -0
  9. data/cert/site.pem +27 -0
  10. data/install.rb +9 -0
  11. data/lib/conditional_vendored_dependency_detection.rb +3 -0
  12. data/lib/conditional_vendored_metric_parser.rb +5 -0
  13. data/lib/new_relic/agent.rb +467 -0
  14. data/lib/new_relic/agent/agent.rb +1325 -0
  15. data/lib/new_relic/agent/beacon_configuration.rb +121 -0
  16. data/lib/new_relic/agent/browser_monitoring.rb +142 -0
  17. data/lib/new_relic/agent/busy_calculator.rb +99 -0
  18. data/lib/new_relic/agent/chained_call.rb +13 -0
  19. data/lib/new_relic/agent/database.rb +223 -0
  20. data/lib/new_relic/agent/error_collector.rb +251 -0
  21. data/lib/new_relic/agent/instrumentation.rb +9 -0
  22. data/lib/new_relic/agent/instrumentation/active_merchant.rb +29 -0
  23. data/lib/new_relic/agent/instrumentation/active_record.rb +137 -0
  24. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +68 -0
  25. data/lib/new_relic/agent/instrumentation/authlogic.rb +19 -0
  26. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +443 -0
  27. data/lib/new_relic/agent/instrumentation/data_mapper.rb +238 -0
  28. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +52 -0
  29. data/lib/new_relic/agent/instrumentation/memcache.rb +80 -0
  30. data/lib/new_relic/agent/instrumentation/merb/controller.rb +41 -0
  31. data/lib/new_relic/agent/instrumentation/merb/errors.rb +29 -0
  32. data/lib/new_relic/agent/instrumentation/metric_frame.rb +353 -0
  33. data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
  34. data/lib/new_relic/agent/instrumentation/net.rb +29 -0
  35. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +37 -0
  36. data/lib/new_relic/agent/instrumentation/queue_time.rb +210 -0
  37. data/lib/new_relic/agent/instrumentation/rack.rb +98 -0
  38. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +114 -0
  39. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +42 -0
  40. data/lib/new_relic/agent/instrumentation/rails/errors.rb +42 -0
  41. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +180 -0
  42. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +37 -0
  43. data/lib/new_relic/agent/instrumentation/sinatra.rb +78 -0
  44. data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
  45. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +21 -0
  46. data/lib/new_relic/agent/method_tracer.rb +528 -0
  47. data/lib/new_relic/agent/sampler.rb +50 -0
  48. data/lib/new_relic/agent/samplers/cpu_sampler.rb +58 -0
  49. data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +40 -0
  50. data/lib/new_relic/agent/samplers/memory_sampler.rb +143 -0
  51. data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
  52. data/lib/new_relic/agent/shim_agent.rb +29 -0
  53. data/lib/new_relic/agent/sql_sampler.rb +286 -0
  54. data/lib/new_relic/agent/stats_engine.rb +26 -0
  55. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
  56. data/lib/new_relic/agent/stats_engine/metric_stats.rb +187 -0
  57. data/lib/new_relic/agent/stats_engine/samplers.rb +95 -0
  58. data/lib/new_relic/agent/stats_engine/transactions.rb +125 -0
  59. data/lib/new_relic/agent/transaction_info.rb +74 -0
  60. data/lib/new_relic/agent/transaction_sample_builder.rb +116 -0
  61. data/lib/new_relic/agent/transaction_sampler.rb +468 -0
  62. data/lib/new_relic/agent/worker_loop.rb +89 -0
  63. data/lib/new_relic/collection_helper.rb +77 -0
  64. data/lib/new_relic/command.rb +85 -0
  65. data/lib/new_relic/commands/deployments.rb +105 -0
  66. data/lib/new_relic/commands/install.rb +80 -0
  67. data/lib/new_relic/control.rb +46 -0
  68. data/lib/new_relic/control/class_methods.rb +53 -0
  69. data/lib/new_relic/control/configuration.rb +206 -0
  70. data/lib/new_relic/control/frameworks.rb +10 -0
  71. data/lib/new_relic/control/frameworks/external.rb +16 -0
  72. data/lib/new_relic/control/frameworks/merb.rb +31 -0
  73. data/lib/new_relic/control/frameworks/rails.rb +164 -0
  74. data/lib/new_relic/control/frameworks/rails3.rb +75 -0
  75. data/lib/new_relic/control/frameworks/ruby.rb +42 -0
  76. data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
  77. data/lib/new_relic/control/instance_methods.rb +179 -0
  78. data/lib/new_relic/control/instrumentation.rb +100 -0
  79. data/lib/new_relic/control/logging_methods.rb +143 -0
  80. data/lib/new_relic/control/profiling.rb +25 -0
  81. data/lib/new_relic/control/server_methods.rb +114 -0
  82. data/lib/new_relic/data_serialization.rb +151 -0
  83. data/lib/new_relic/delayed_job_injection.rb +51 -0
  84. data/lib/new_relic/language_support.rb +73 -0
  85. data/lib/new_relic/local_environment.rb +428 -0
  86. data/lib/new_relic/merbtasks.rb +6 -0
  87. data/lib/new_relic/metric_data.rb +51 -0
  88. data/lib/new_relic/metric_spec.rb +76 -0
  89. data/lib/new_relic/metrics.rb +9 -0
  90. data/lib/new_relic/noticed_error.rb +29 -0
  91. data/lib/new_relic/rack/browser_monitoring.rb +76 -0
  92. data/lib/new_relic/rack/developer_mode.rb +268 -0
  93. data/lib/new_relic/recipes.rb +77 -0
  94. data/lib/new_relic/stats.rb +335 -0
  95. data/lib/new_relic/timer_lib.rb +27 -0
  96. data/lib/new_relic/transaction_analysis.rb +77 -0
  97. data/lib/new_relic/transaction_analysis/segment_summary.rb +49 -0
  98. data/lib/new_relic/transaction_sample.rb +261 -0
  99. data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
  100. data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
  101. data/lib/new_relic/transaction_sample/segment.rb +203 -0
  102. data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
  103. data/lib/new_relic/url_rule.rb +14 -0
  104. data/lib/new_relic/version.rb +55 -0
  105. data/lib/newrelic_rpm.rb +49 -0
  106. data/lib/tasks/all.rb +4 -0
  107. data/lib/tasks/install.rake +7 -0
  108. data/lib/tasks/tests.rake +19 -0
  109. data/newrelic.yml +265 -0
  110. data/newrelic_rpm.gemspec +312 -0
  111. data/recipes/newrelic.rb +6 -0
  112. data/test/active_record_fixtures.rb +77 -0
  113. data/test/config/newrelic.yml +48 -0
  114. data/test/config/test_control.rb +48 -0
  115. data/test/fixtures/proc_cpuinfo.txt +575 -0
  116. data/test/new_relic/agent/agent/connect_test.rb +403 -0
  117. data/test/new_relic/agent/agent/start_test.rb +255 -0
  118. data/test/new_relic/agent/agent/start_worker_thread_test.rb +153 -0
  119. data/test/new_relic/agent/agent_test.rb +140 -0
  120. data/test/new_relic/agent/agent_test_controller.rb +77 -0
  121. data/test/new_relic/agent/agent_test_controller_test.rb +382 -0
  122. data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
  123. data/test/new_relic/agent/beacon_configuration_test.rb +111 -0
  124. data/test/new_relic/agent/browser_monitoring_test.rb +323 -0
  125. data/test/new_relic/agent/busy_calculator_test.rb +81 -0
  126. data/test/new_relic/agent/database_test.rb +149 -0
  127. data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
  128. data/test/new_relic/agent/error_collector_test.rb +192 -0
  129. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +576 -0
  130. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +34 -0
  131. data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
  132. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +171 -0
  133. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +50 -0
  134. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +84 -0
  135. data/test/new_relic/agent/instrumentation/queue_time_test.rb +382 -0
  136. data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
  137. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +184 -0
  138. data/test/new_relic/agent/memcache_instrumentation_test.rb +143 -0
  139. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +164 -0
  140. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +234 -0
  141. data/test/new_relic/agent/method_tracer_test.rb +386 -0
  142. data/test/new_relic/agent/mock_scope_listener.rb +23 -0
  143. data/test/new_relic/agent/rpm_agent_test.rb +149 -0
  144. data/test/new_relic/agent/sampler_test.rb +19 -0
  145. data/test/new_relic/agent/shim_agent_test.rb +20 -0
  146. data/test/new_relic/agent/sql_sampler_test.rb +192 -0
  147. data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
  148. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +82 -0
  149. data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
  150. data/test/new_relic/agent/stats_engine_test.rb +220 -0
  151. data/test/new_relic/agent/transaction_info_test.rb +13 -0
  152. data/test/new_relic/agent/transaction_sample_builder_test.rb +219 -0
  153. data/test/new_relic/agent/transaction_sampler_test.rb +967 -0
  154. data/test/new_relic/agent/worker_loop_test.rb +66 -0
  155. data/test/new_relic/agent_test.rb +187 -0
  156. data/test/new_relic/collection_helper_test.rb +149 -0
  157. data/test/new_relic/command/deployments_test.rb +68 -0
  158. data/test/new_relic/control/class_methods_test.rb +62 -0
  159. data/test/new_relic/control/configuration_test.rb +84 -0
  160. data/test/new_relic/control/logging_methods_test.rb +185 -0
  161. data/test/new_relic/control_test.rb +256 -0
  162. data/test/new_relic/data_serialization_test.rb +208 -0
  163. data/test/new_relic/delayed_job_injection_test.rb +16 -0
  164. data/test/new_relic/local_environment_test.rb +85 -0
  165. data/test/new_relic/metric_data_test.rb +125 -0
  166. data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
  167. data/test/new_relic/metric_spec_test.rb +95 -0
  168. data/test/new_relic/rack/all_test.rb +11 -0
  169. data/test/new_relic/rack/browser_monitoring_test.rb +142 -0
  170. data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
  171. data/test/new_relic/rack/developer_mode_test.rb +74 -0
  172. data/test/new_relic/stats_test.rb +411 -0
  173. data/test/new_relic/transaction_analysis/segment_summary_test.rb +91 -0
  174. data/test/new_relic/transaction_analysis_test.rb +121 -0
  175. data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
  176. data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
  177. data/test/new_relic/transaction_sample/segment_test.rb +389 -0
  178. data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
  179. data/test/new_relic/transaction_sample_subtest_test.rb +56 -0
  180. data/test/new_relic/transaction_sample_test.rb +177 -0
  181. data/test/new_relic/version_number_test.rb +89 -0
  182. data/test/script/build_test_gem.sh +51 -0
  183. data/test/script/ci.sh +94 -0
  184. data/test/script/ci_bench.sh +52 -0
  185. data/test/test_contexts.rb +29 -0
  186. data/test/test_helper.rb +155 -0
  187. data/ui/helpers/developer_mode_helper.rb +357 -0
  188. data/ui/helpers/google_pie_chart.rb +48 -0
  189. data/ui/views/layouts/newrelic_default.rhtml +47 -0
  190. data/ui/views/newrelic/_explain_plans.rhtml +27 -0
  191. data/ui/views/newrelic/_sample.rhtml +20 -0
  192. data/ui/views/newrelic/_segment.rhtml +28 -0
  193. data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
  194. data/ui/views/newrelic/_segment_row.rhtml +12 -0
  195. data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
  196. data/ui/views/newrelic/_show_sample_sql.rhtml +24 -0
  197. data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
  198. data/ui/views/newrelic/_sql_row.rhtml +16 -0
  199. data/ui/views/newrelic/_stack_trace.rhtml +15 -0
  200. data/ui/views/newrelic/_table.rhtml +12 -0
  201. data/ui/views/newrelic/explain_sql.rhtml +43 -0
  202. data/ui/views/newrelic/file/images/arrow-close.png +0 -0
  203. data/ui/views/newrelic/file/images/arrow-open.png +0 -0
  204. data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
  205. data/ui/views/newrelic/file/images/file_icon.png +0 -0
  206. data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
  207. data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
  208. data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
  209. data/ui/views/newrelic/file/images/textmate.png +0 -0
  210. data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +6240 -0
  211. data/ui/views/newrelic/file/javascript/transaction_sample.js +120 -0
  212. data/ui/views/newrelic/file/stylesheets/style.css +490 -0
  213. data/ui/views/newrelic/index.rhtml +71 -0
  214. data/ui/views/newrelic/sample_not_found.rhtml +2 -0
  215. data/ui/views/newrelic/show_sample.rhtml +80 -0
  216. data/ui/views/newrelic/show_source.rhtml +3 -0
  217. data/ui/views/newrelic/threads.rhtml +53 -0
  218. data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +5 -0
  219. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +67 -0
  220. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +3 -0
  221. data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +1 -0
  222. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
  223. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +14 -0
  224. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +31 -0
  225. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +33 -0
  226. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +89 -0
  227. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +7 -0
  228. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +46 -0
  229. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +67 -0
  230. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +43 -0
  231. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +17 -0
  232. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +48 -0
  233. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +24 -0
  234. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +28 -0
  235. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +17 -0
  236. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +11 -0
  237. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +55 -0
  238. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +40 -0
  239. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +20 -0
  240. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +7 -0
  241. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +31 -0
  242. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +17 -0
  243. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +34 -0
  244. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +7 -0
  245. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +55 -0
  246. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +135 -0
  247. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +27 -0
  248. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +40 -0
  249. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +7 -0
  250. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +7 -0
  251. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +7 -0
  252. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +27 -0
  253. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +15 -0
  254. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +54 -0
  255. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +6 -0
  256. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +6 -0
  257. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +20 -0
  258. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +20 -0
  259. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +5 -0
  260. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +70 -0
  261. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +18 -0
  262. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +14 -0
  263. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +133 -0
  264. metadata +376 -0
@@ -0,0 +1,121 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
2
+ require 'new_relic/transaction_analysis'
3
+ class NewRelic::TransactionAnalysisTest < Test::Unit::TestCase
4
+ include NewRelic::TransactionAnalysis
5
+
6
+ # these are mostly stub tests just making sure that the API doesn't
7
+ # change if anyone ever needs to modify it.
8
+
9
+ def test_database_time
10
+ self.expects(:time_percentage).with(/^Database\/.*/)
11
+ database_time
12
+ end
13
+
14
+ def test_render_time
15
+ self.expects(:time_percentage).with(/^View\/.*/)
16
+ render_time
17
+ end
18
+
19
+ def test_breakdown_data_default
20
+ root_segment = mock('root_segment')
21
+ # this is for 1.9 compatibility - calling each on something calls
22
+ # #to_a on it - which is fun and exciting
23
+ root_segment.stubs(:to_a).returns([root_segment])
24
+ other_segment = mock('other_segment')
25
+ # this is for 1.9 compatibility - calling each on something calls
26
+ # #to_a on it - which is fun and exciting
27
+ other_segment.stubs(:to_a).returns([other_segment])
28
+ other_segment.expects(:metric_name).twice.returns('Controller/foo')
29
+ other_segment.expects(:duration).returns(0.1)
30
+ other_segment.expects(:exclusive_duration).returns(0.1)
31
+ self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment)
32
+ self.expects(:root_segment).twice.returns(root_segment)
33
+ self.expects(:duration).returns(0.1)
34
+ data = breakdown_data
35
+ assert_equal 'Controller/foo', data[0].metric_name
36
+ end
37
+
38
+ # kind of a hairy test, we're making sure that the data is truncated
39
+ # to one element by the limit
40
+ def test_breakdown_data_limit_one
41
+ root_segment = mock('root_segment')
42
+ # this is for 1.9 compatibility - calling each on something calls
43
+ # #to_a on it - which is fun and exciting
44
+ root_segment.stubs(:to_a).returns([root_segment])
45
+ other_segment = mock('other_segment')
46
+ # this is for 1.9 compatibility - calling each on something calls
47
+ # #to_a on it - which is fun and exciting
48
+ other_segment.stubs(:to_a).returns([other_segment])
49
+ other_segment.expects(:metric_name).twice.returns('Controller/foo')
50
+ other_segment.expects(:duration).returns(0.1)
51
+ other_segment.expects(:exclusive_duration).returns(0.1)
52
+ yet_another = mock('another segment')
53
+ # this is for 1.9 compatibility - calling each on something calls
54
+ # #to_a on it - which is fun and exciting
55
+ yet_another.stubs(:to_a).returns([yet_another])
56
+ yet_another.expects(:metric_name).twice.returns('Controller/bar')
57
+ yet_another.expects(:duration).returns(0.2)
58
+ yet_another.expects(:exclusive_duration).returns(0.2)
59
+ self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment, yet_another)
60
+ self.expects(:root_segment).times(3).returns(root_segment)
61
+ self.expects(:duration).returns(0.1)
62
+ data = breakdown_data(1)
63
+ assert_equal 1, data.size
64
+ assert_equal 'Controller/bar', data[0].metric_name
65
+ end
66
+
67
+ def test_breakdown_data_remainder
68
+ root_segment = mock('root_segment')
69
+ # this is for 1.9 compatibility - calling each on something calls
70
+ # #to_a on it - which is fun and exciting
71
+ root_segment.stubs(:to_a).returns([root_segment])
72
+ other_segment = mock('other_segment')
73
+ # this is for 1.9 compatibility - calling each on something calls
74
+ # #to_a on it - which is fun and exciting
75
+ other_segment.stubs(:to_a).returns([other_segment])
76
+ other_segment.expects(:metric_name).twice.returns('Controller/foo')
77
+ other_segment.expects(:duration).returns(0.1)
78
+ other_segment.expects(:exclusive_duration).returns(0.1)
79
+ self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment)
80
+ self.expects(:root_segment).twice.returns(root_segment)
81
+ self.expects(:duration).returns(0.2)
82
+ data = breakdown_data
83
+ assert_equal 2, data.size
84
+ assert_equal 'Controller/foo', data[0].metric_name
85
+ assert_equal 'Remainder', data[1].metric_name
86
+ end
87
+
88
+ def test_sql_segments_default
89
+ root_segment = mock('root_segment') # a segment with no data
90
+ root_segment.expects(:[]).with(:sql).returns(false)
91
+ root_segment.expects(:[]).with(:sql_obfuscated).returns(false)
92
+ root_segment.expects(:[]).with(:key).returns(nil)
93
+ # this is for 1.9 compatibility - calling each on something calls
94
+ # #to_a on it - which is fun and exciting
95
+ root_segment.stubs(:to_a).returns([root_segment])
96
+ other_segment = mock('other_segment') # a sql segment
97
+ other_segment.expects(:[]).with(:sql).returns(true)
98
+ # this is for 1.9 compatibility - calling each on something calls
99
+ # #to_a on it - which is fun and exciting
100
+ other_segment.stubs(:to_a).returns([other_segment])
101
+ self.expects(:each_segment).multiple_yields(root_segment, other_segment)
102
+ assert_equal [other_segment], sql_segments
103
+ end
104
+
105
+ def test_time_percentage_default
106
+ root_segment = mock('root_segment')
107
+ root_segment.expects(:metric_name).returns('ROOT')
108
+ # this is for 1.9 compatibility - calling each on something calls
109
+ # #to_a on it - which is fun and exciting
110
+ root_segment.stubs(:to_a).returns([root_segment])
111
+ other_segment = mock('other_segment')
112
+ other_segment.expects(:metric_name).returns('Controller/foo')
113
+ other_segment.expects(:duration).returns(0.1)
114
+ # this is for 1.9 compatibility - calling each on something calls
115
+ # #to_a on it - which is fun and exciting
116
+ other_segment.stubs(:to_a).returns([other_segment])
117
+ self.expects(:duration).returns(0.2)
118
+ self.expects(:each_segment).multiple_yields(root_segment, other_segment)
119
+ assert_equal 50.0, time_percentage(/Controller\/.*/)
120
+ end
121
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
2
+ require 'new_relic/transaction_sample/composite_segment'
3
+ class NewRelic::TransactionSample::CompositeSegmentTest < Test::Unit::TestCase
4
+ def test_composite_segment_creation
5
+ fake_segment = mock_segment
6
+ NewRelic::TransactionSample::CompositeSegment.new([fake_segment])
7
+ end
8
+
9
+ def test_detail_segments_equals
10
+ fake_segment = mock_segment
11
+ cs = NewRelic::TransactionSample::CompositeSegment.new([fake_segment])
12
+
13
+ # note that this is a bare mock
14
+ # nothing should be called on it, for now
15
+ other_fake_segment = mock('other segment')
16
+ cs.detail_segments = [other_fake_segment]
17
+
18
+ assert_equal cs.detail_segments, [other_fake_segment]
19
+ end
20
+
21
+ private
22
+
23
+ @@seg_count = 0
24
+ def mock_segment
25
+ @@seg_count += 1
26
+ segment = mock('segment ' + @@seg_count.to_s)
27
+ segment.expects(:entry_timestamp).returns(Time.now)
28
+ # note the following 'twice' - different than SummarySegment
29
+ segment.expects(:exit_timestamp).returns(Time.now).twice
30
+ segment.expects(:metric_name).returns('Custom/test/metric')
31
+ segment.expects(:called_segments).returns([])
32
+ segment
33
+ end
34
+ end
35
+
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
2
+ require 'new_relic/transaction_sample/fake_segment'
3
+ class NewRelic::TransactionSample::FakeSegmentTest < Test::Unit::TestCase
4
+ def test_fake_segment_creation
5
+ assert_nothing_raised do
6
+ NewRelic::TransactionSample::FakeSegment.new(0.1, 'Custom/test/metric', nil)
7
+ end
8
+ end
9
+
10
+ def test_parent_segment
11
+ # should be public in this class, but not in the parent class
12
+ s = NewRelic::TransactionSample::FakeSegment.new(0.1, 'Custom/test/metric', nil)
13
+ s.parent_segment = 'foo'
14
+ assert_equal('foo', s.instance_eval { @parent_segment } )
15
+ end
16
+ end
17
+
@@ -0,0 +1,389 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
2
+ require 'new_relic/transaction_sample/segment'
3
+ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
4
+ def test_segment_creation
5
+ # basic smoke test
6
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
7
+ assert_equal NewRelic::TransactionSample::Segment, s.class
8
+ end
9
+
10
+ def test_readers
11
+ t = Time.now
12
+ s = NewRelic::TransactionSample::Segment.new(t, 'Custom/test/metric', nil)
13
+ assert_equal(t, s.entry_timestamp)
14
+ assert_equal(nil, s.exit_timestamp)
15
+ assert_equal(nil, s.parent_segment)
16
+ assert_equal('Custom/test/metric', s.metric_name)
17
+ assert_equal(s.object_id, s.segment_id)
18
+ end
19
+
20
+ def test_end_trace
21
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
22
+ t = Time.now
23
+ s.end_trace(t)
24
+ assert_equal(t, s.exit_timestamp)
25
+ end
26
+
27
+ def test_add_called_segment
28
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
29
+ assert_equal [], s.called_segments
30
+ fake_segment = mock('segment')
31
+ fake_segment.expects(:parent_segment=).with(s)
32
+ s.add_called_segment(fake_segment)
33
+ assert_equal([fake_segment], s.called_segments)
34
+ end
35
+
36
+ def test_to_s
37
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
38
+ s.expects(:to_debug_str).with(0)
39
+ s.to_s
40
+ end
41
+
42
+ def test_to_json
43
+ t = Time.now
44
+ s = NewRelic::TransactionSample::Segment.new(t, 'Custom/test/metric', nil)
45
+ assert_equal({ :entry_timestamp => t, :exit_timestamp => nil, :metric_name => 'Custom/test/metric', :segment_id => s.object_id }.to_json, s.to_json)
46
+ end
47
+
48
+ def test_path_string
49
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
50
+ assert_equal("Custom/test/metric[]", s.path_string)
51
+
52
+ fake_segment = mock('segment')
53
+ fake_segment.expects(:parent_segment=).with(s)
54
+ fake_segment.expects(:path_string).returns('Custom/other/metric[]')
55
+
56
+
57
+ s.add_called_segment(fake_segment)
58
+ assert_equal("Custom/test/metric[Custom/other/metric[]]", s.path_string)
59
+ end
60
+
61
+ def test_to_s_compact
62
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
63
+ assert_equal("Custom/test/metric", s.to_s_compact)
64
+
65
+ fake_segment = mock('segment')
66
+ fake_segment.expects(:parent_segment=).with(s)
67
+ fake_segment.expects(:to_s_compact).returns('Custom/other/metric')
68
+ s.add_called_segment(fake_segment)
69
+
70
+ assert_equal("Custom/test/metric{Custom/other/metric}", s.to_s_compact)
71
+ end
72
+
73
+ def test_to_debug_str_basic
74
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
75
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n<< n/a Custom/test/metric\n", s.to_debug_str(0))
76
+ end
77
+
78
+ def test_to_debug_str_with_params
79
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
80
+ s.params = {:whee => 'a param'}
81
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n -whee : a param\n<< n/a Custom/test/metric\n", s.to_debug_str(0))
82
+ end
83
+
84
+ def test_to_debug_str_closed
85
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
86
+ s.end_trace(0.1)
87
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n<< 100 ms Custom/test/metric\n", s.to_debug_str(0))
88
+ end
89
+
90
+ def test_to_debug_str_closed_with_nonnumeric
91
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
92
+ s.end_trace("0.1")
93
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n<< 0.1 Custom/test/metric\n", s.to_debug_str(0))
94
+ end
95
+
96
+ def test_to_debug_str_one_child
97
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
98
+ s.add_called_segment(NewRelic::TransactionSample::Segment.new(0.1, 'Custom/test/other', nil))
99
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/other \n << n/a Custom/test/other\n<< n/a Custom/test/metric\n", s.to_debug_str(0))
100
+ # try closing it
101
+ s.called_segments.first.end_trace(0.15)
102
+ s.end_trace(0.2)
103
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/other \n << 150 ms Custom/test/other\n<< 200 ms Custom/test/metric\n", s.to_debug_str(0))
104
+ end
105
+
106
+ def test_to_debug_str_multichild
107
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
108
+ s.add_called_segment(NewRelic::TransactionSample::Segment.new(0.1, 'Custom/test/other', nil))
109
+ s.add_called_segment(NewRelic::TransactionSample::Segment.new(0.11, 'Custom/test/extra', nil))
110
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/other \n << n/a Custom/test/other\n >> 110 ms [Segment] Custom/test/extra \n << n/a Custom/test/extra\n<< n/a Custom/test/metric\n", s.to_debug_str(0))
111
+ ending = 0.12
112
+ s.called_segments.each { |x| x.end_trace(ending += 0.01) }
113
+ s.end_trace(0.2)
114
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/other \n << 130 ms Custom/test/other\n >> 110 ms [Segment] Custom/test/extra \n << 140 ms Custom/test/extra\n<< 200 ms Custom/test/metric\n", s.to_debug_str(0))
115
+ end
116
+
117
+ def test_to_debug_str_nested
118
+ inner = NewRelic::TransactionSample::Segment.new(0.2, 'Custom/test/inner', nil)
119
+ middle = NewRelic::TransactionSample::Segment.new(0.1, 'Custom/test/middle', nil)
120
+ s = NewRelic::TransactionSample::Segment.new(0.0, 'Custom/test/metric', nil)
121
+ middle.add_called_segment(inner)
122
+ s.add_called_segment(middle)
123
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/middle \n >> 200 ms [Segment] Custom/test/inner \n << n/a Custom/test/inner\n << n/a Custom/test/middle\n<< n/a Custom/test/metric\n", s.to_debug_str(0))
124
+
125
+ # close them
126
+ inner.end_trace(0.21)
127
+ middle.end_trace(0.22)
128
+ s.end_trace(0.23)
129
+ assert_equal(">> 0 ms [Segment] Custom/test/metric \n >> 100 ms [Segment] Custom/test/middle \n >> 200 ms [Segment] Custom/test/inner \n << 210 ms Custom/test/inner\n << 220 ms Custom/test/middle\n<< 230 ms Custom/test/metric\n", s.to_debug_str(0))
130
+ end
131
+
132
+ def test_called_segments_default
133
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
134
+ assert_equal([], s.called_segments)
135
+ end
136
+
137
+ def test_called_segments_with_segments
138
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
139
+ fake_segment = mock('segment')
140
+ fake_segment.expects(:parent_segment=).with(s)
141
+ s.add_called_segment(fake_segment)
142
+
143
+ assert_equal([fake_segment], s.called_segments)
144
+ end
145
+
146
+ def test_duration
147
+ fake_entry_timestamp = mock('entry timestamp')
148
+ fake_exit_timestamp = mock('exit timestamp')
149
+ fake_result = mock('numeric')
150
+ fake_exit_timestamp.expects(:-).with(fake_entry_timestamp).returns(fake_result)
151
+ fake_result.expects(:to_f).returns(0.5)
152
+
153
+ s = NewRelic::TransactionSample::Segment.new(fake_entry_timestamp, 'Custom/test/metric', nil)
154
+ s.end_trace(fake_exit_timestamp)
155
+ assert_equal(0.5, s.duration)
156
+ end
157
+
158
+ def test_exclusive_duration_no_children
159
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
160
+ s.expects(:duration).returns(0.5)
161
+ assert_equal(0.5, s.exclusive_duration)
162
+ end
163
+
164
+ def test_exclusive_duration_with_children
165
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
166
+
167
+ s.expects(:duration).returns(0.5)
168
+
169
+ fake_segment = mock('segment')
170
+ fake_segment.expects(:parent_segment=).with(s)
171
+ fake_segment.expects(:duration).returns(0.1)
172
+
173
+ s.add_called_segment(fake_segment)
174
+
175
+ assert_equal(0.4, s.exclusive_duration)
176
+ end
177
+
178
+ def test_count_segments_default
179
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
180
+ assert_equal(1, s.count_segments)
181
+ end
182
+
183
+ def test_count_segments_with_children
184
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
185
+
186
+ fake_segment = mock('segment')
187
+ fake_segment.expects(:parent_segment=).with(s)
188
+ fake_segment.expects(:count_segments).returns(1)
189
+
190
+ s.add_called_segment(fake_segment)
191
+
192
+ assert_equal(2, s.count_segments)
193
+ end
194
+
195
+ def test_truncate_returns_number_of_elements
196
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
197
+ assert_equal(1, s.truncate(1))
198
+ dup = s.dup
199
+ s.called_segments = [dup]
200
+ assert_equal(2, s.truncate(2))
201
+
202
+ s.called_segments = [dup, dup]
203
+ assert_equal(3, s.truncate(3))
204
+ end
205
+
206
+
207
+ def test_truncate_default
208
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
209
+
210
+ assert_equal(1, s.truncate(1))
211
+ end
212
+
213
+ def test_truncate_with_a_child
214
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
215
+
216
+ fake_segment = mock('segment')
217
+ fake_segment.expects(:parent_segment=).with(s)
218
+ fake_segment.expects(:truncate).with(1).returns(1)
219
+
220
+ s.add_called_segment(fake_segment)
221
+
222
+ assert_equal(2, s.truncate(2))
223
+ assert_equal([fake_segment], s.called_segments)
224
+
225
+ assert_equal(1, s.truncate(1))
226
+ assert_equal([], s.called_segments)
227
+ end
228
+
229
+ def test_truncate_with_multiple_children
230
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
231
+
232
+ fake_segment = mock('segment')
233
+ fake_segment.expects(:truncate).with(2).returns(1)
234
+
235
+ other_segment = mock('other segment')
236
+ other_segment.expects(:truncate).with(1).returns(1)
237
+
238
+ s.called_segments = [fake_segment, other_segment]
239
+ assert_equal(3, s.truncate(3))
240
+ assert_equal([fake_segment, other_segment], s.called_segments)
241
+ end
242
+
243
+ def test_truncate_removes_elements
244
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
245
+
246
+ fake_segment = mock('segment')
247
+ fake_segment.expects(:truncate).with(1).returns(1)
248
+
249
+ other_segment = mock('other segment')
250
+
251
+ s.called_segments = [fake_segment, other_segment]
252
+ assert_equal(2, s.truncate(2))
253
+ assert_equal([fake_segment], s.called_segments)
254
+ end
255
+
256
+ def test_key_equals
257
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
258
+ # doing this to hold the reference to the hash
259
+ params = {}
260
+ s.params = params
261
+ assert_equal(params, s.params)
262
+
263
+ # should delegate to the same hash we have above
264
+ s[:foo] = 'correct'
265
+
266
+ assert_equal('correct', params[:foo])
267
+ end
268
+
269
+ def test_key
270
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
271
+ s.params = {:foo => 'correct'}
272
+ assert_equal('correct', s[:foo])
273
+ end
274
+
275
+ def test_params
276
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
277
+
278
+ # should have a default value
279
+ assert_equal(nil, s.instance_eval { @params })
280
+ assert_equal({}, s.params)
281
+
282
+ # should otherwise take the value from the @params var
283
+ s.instance_eval { @params = {:foo => 'correct'} }
284
+ assert_equal({:foo => 'correct'}, s.params)
285
+ end
286
+
287
+ def test_each_segment_default
288
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
289
+ # in the base case it just yields the block to itself
290
+ count = 0
291
+ s.each_segment do |x|
292
+ count += 1
293
+ assert_equal(s, x)
294
+ end
295
+ # should only run once
296
+ assert_equal(1, count)
297
+ end
298
+
299
+ def test_each_segment_with_children
300
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
301
+
302
+ fake_segment = mock('segment')
303
+ fake_segment.expects(:parent_segment=).with(s)
304
+ fake_segment.expects(:each_segment).yields(fake_segment)
305
+
306
+ s.add_called_segment(fake_segment)
307
+
308
+ count = 0
309
+ s.each_segment do |x|
310
+ count += 1
311
+ end
312
+
313
+ assert_equal(2, count)
314
+ end
315
+
316
+ def test_each_segment_with_nest_tracking
317
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
318
+
319
+ summary = mock('summary')
320
+ summary.expects(:current_nest_count).twice.returns(0).then.returns(1)
321
+ summary.expects(:current_nest_count=).twice
322
+ s.each_segment_with_nest_tracking do |x|
323
+ summary
324
+ end
325
+ end
326
+
327
+ def test_find_segment_default
328
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
329
+ id_to_find = s.segment_id
330
+ # should return itself in the base case
331
+ assert_equal(s, s.find_segment(id_to_find))
332
+ end
333
+
334
+ def test_find_segment_not_found
335
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
336
+ assert_equal(nil, s.find_segment(-1))
337
+ end
338
+
339
+ def test_find_segment_with_children
340
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
341
+ id_to_find = s.segment_id
342
+ # should return itself in the base case
343
+ assert_equal(s, s.find_segment(id_to_find))
344
+ end
345
+
346
+ def test_explain_sql_raising_an_error
347
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
348
+ config = mock('config')
349
+ s.params = {:sql => 'SELECT', :connection_config => config}
350
+ connection = mock('connection')
351
+ NewRelic::Agent::Database.expects(:get_connection).with(config).raises(RuntimeError.new("whee"))
352
+ assert_nothing_raised do
353
+ s.explain_sql
354
+ end
355
+ end
356
+
357
+ def test_params_equal
358
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
359
+ assert_equal(nil, s.instance_eval { @params })
360
+
361
+ params = {:foo => 'correct'}
362
+
363
+ s.params = params
364
+ assert_equal(params, s.instance_eval { @params })
365
+ end
366
+
367
+ def test_obfuscated_sql
368
+ sql = 'select * from table where id = 1'
369
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
370
+ s[:sql] = sql
371
+ assert_equal('select * from table where id = ?', s.obfuscated_sql)
372
+ end
373
+
374
+ def test_called_segments_equals
375
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
376
+ assert_equal(nil, s.instance_eval { @called_segments })
377
+ s.called_segments = [1, 2, 3]
378
+ assert_equal([1, 2, 3], s.instance_eval { @called_segments })
379
+ end
380
+
381
+ def test_parent_segment_equals
382
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
383
+ assert_equal(nil, s.instance_eval { @parent_segment })
384
+ fake_segment = mock('segment')
385
+ s.send(:parent_segment=, fake_segment)
386
+ assert_equal(fake_segment, s.parent_segment)
387
+ end
388
+ end
389
+