scout_apm 1.4.6 → 1.5.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +9 -0
  3. data/lib/scout_apm/agent/reporting.rb +8 -6
  4. data/lib/scout_apm/agent.rb +10 -6
  5. data/lib/scout_apm/background_job_integrations/sidekiq.rb +23 -11
  6. data/lib/scout_apm/call_set.rb +61 -0
  7. data/lib/scout_apm/config.rb +2 -1
  8. data/lib/scout_apm/environment.rb +12 -7
  9. data/lib/scout_apm/histogram.rb +124 -0
  10. data/lib/scout_apm/instruments/.DS_Store +0 -0
  11. data/lib/scout_apm/instruments/action_controller_rails_2.rb +1 -0
  12. data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +1 -0
  13. data/lib/scout_apm/instruments/delayed_job.rb +1 -0
  14. data/lib/scout_apm/instruments/process/process_memory.rb +1 -1
  15. data/lib/scout_apm/instruments/sinatra.rb +1 -1
  16. data/lib/scout_apm/job_record.rb +76 -0
  17. data/lib/scout_apm/layaway.rb +4 -1
  18. data/lib/scout_apm/layaway_file.rb +4 -4
  19. data/lib/scout_apm/layer.rb +14 -4
  20. data/lib/scout_apm/layer_converters/converter_base.rb +30 -0
  21. data/lib/scout_apm/layer_converters/depth_first_walker.rb +36 -0
  22. data/lib/scout_apm/layer_converters/error_converter.rb +20 -0
  23. data/lib/scout_apm/layer_converters/job_converter.rb +84 -0
  24. data/lib/scout_apm/layer_converters/metric_converter.rb +45 -0
  25. data/lib/scout_apm/layer_converters/request_queue_time_converter.rb +60 -0
  26. data/lib/scout_apm/layer_converters/slow_job_converter.rb +88 -0
  27. data/lib/scout_apm/layer_converters/slow_request_converter.rb +111 -0
  28. data/lib/scout_apm/metric_meta.rb +9 -0
  29. data/lib/scout_apm/metric_set.rb +44 -0
  30. data/lib/scout_apm/reporter.rb +12 -5
  31. data/lib/scout_apm/serializers/jobs_serializer_to_json.rb +28 -0
  32. data/lib/scout_apm/serializers/metrics_to_json_serializer.rb +54 -0
  33. data/lib/scout_apm/serializers/payload_serializer.rb +5 -3
  34. data/lib/scout_apm/serializers/payload_serializer_to_json.rb +9 -4
  35. data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +29 -0
  36. data/lib/scout_apm/slow_item_set.rb +80 -0
  37. data/lib/scout_apm/slow_job_policy.rb +29 -0
  38. data/lib/scout_apm/slow_job_record.rb +33 -0
  39. data/lib/scout_apm/slow_transaction.rb +0 -22
  40. data/lib/scout_apm/stackprof_tree_collapser.rb +7 -8
  41. data/lib/scout_apm/store.rb +55 -35
  42. data/lib/scout_apm/tracked_request.rb +67 -10
  43. data/lib/scout_apm/utils/active_record_metric_name.rb +13 -0
  44. data/lib/scout_apm/utils/backtrace_parser.rb +31 -0
  45. data/lib/scout_apm/utils/fake_stack_prof.rb +1 -1
  46. data/lib/scout_apm/utils/sql_sanitizer.rb +6 -0
  47. data/lib/scout_apm/version.rb +1 -1
  48. data/lib/scout_apm.rb +25 -5
  49. data/test/unit/histogram_test.rb +93 -0
  50. data/test/unit/serializers/payload_serializer_test.rb +5 -5
  51. data/test/unit/{slow_transaction_set_test.rb → slow_item_set_test.rb} +8 -8
  52. data/test/unit/slow_job_policy_test.rb +55 -0
  53. metadata +30 -9
  54. data/lib/scout_apm/layer_converter.rb +0 -222
  55. data/lib/scout_apm/request_queue_time.rb +0 -57
  56. data/lib/scout_apm/slow_transaction_set.rb +0 -67
@@ -1,67 +0,0 @@
1
- # In order to keep load down, only record a sample of Slow Transactions. In
2
- # order to make that sampling as fair as possible, follow a basic algorithm:
3
- #
4
- # When adding a new SlowTransaction:
5
- # * Just add it if there is an open spot
6
- # * If there isn't an open spot, attempt to remove an over-represented
7
- # endpoint instead ("attempt_to_evict"). Overrepresented is simply "has more
8
- # than @fair number of SlowTransactions for that end point"
9
- # * If there isn't an open spot, and nobody is valid to evict, drop the
10
- # incoming SlowTransaction without adding.
11
- #
12
- # There is no way to remove SlowTransactions from this set, create a new object
13
- # for each reporting period.
14
- module ScoutApm
15
- class SlowTransactionSet
16
- include Enumerable
17
-
18
- DEFAULT_TOTAL = 10
19
- DEFAULT_FAIR = 1
20
-
21
- attr_reader :total, :fair
22
-
23
- def initialize(total=DEFAULT_TOTAL, fair=DEFAULT_FAIR)
24
- @total = total
25
- @fair = fair
26
- @slow_transactions = []
27
- end
28
-
29
- def each
30
- @slow_transactions.each { |s| yield s }
31
- end
32
-
33
- def <<(slow_transaction)
34
- return if attempt_append(slow_transaction)
35
- attempt_to_evict
36
- attempt_append(slow_transaction)
37
- end
38
-
39
- def empty_slot?
40
- @slow_transactions.length < total
41
- end
42
-
43
- def attempt_append(slow_transaction)
44
- if empty_slot?
45
- @slow_transactions.push(slow_transaction)
46
- true
47
- else
48
- false
49
- end
50
- end
51
-
52
- def attempt_to_evict
53
- return if @slow_transactions.length == 0
54
-
55
- overrepresented = @slow_transactions.
56
- group_by { |st| st.metric_name }.
57
- to_a.
58
- sort_by { |(_, sts)| sts.length }.
59
- last
60
-
61
- if overrepresented[1].length > fair
62
- fastest = overrepresented[1].sort_by { |st| st.total_call_time }.first
63
- @slow_transactions.delete(fastest)
64
- end
65
- end
66
- end
67
- end