appsignal 3.9.2-java → 3.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3138 -0
  3. data/.rubocop.yml +28 -20
  4. data/.rubocop_todo.yml +7 -33
  5. data/CHANGELOG.md +130 -0
  6. data/README.md +0 -1
  7. data/Rakefile +80 -65
  8. data/appsignal.gemspec +1 -1
  9. data/build_matrix.yml +112 -184
  10. data/ext/base.rb +1 -1
  11. data/gemfiles/hanami-2.1.gemfile +7 -0
  12. data/gemfiles/webmachine1.gemfile +5 -4
  13. data/lib/appsignal/cli/diagnose.rb +1 -1
  14. data/lib/appsignal/config.rb +5 -1
  15. data/lib/appsignal/demo.rb +0 -1
  16. data/lib/appsignal/environment.rb +11 -2
  17. data/lib/appsignal/extension/jruby.rb +1 -1
  18. data/lib/appsignal/helpers/instrumentation.rb +164 -2
  19. data/lib/appsignal/hooks/active_job.rb +1 -6
  20. data/lib/appsignal/integrations/grape.rb +19 -47
  21. data/lib/appsignal/integrations/hanami.rb +8 -7
  22. data/lib/appsignal/integrations/padrino.rb +51 -52
  23. data/lib/appsignal/integrations/railtie.rb +0 -3
  24. data/lib/appsignal/integrations/rake.rb +46 -12
  25. data/lib/appsignal/integrations/sidekiq.rb +1 -11
  26. data/lib/appsignal/integrations/sinatra.rb +0 -1
  27. data/lib/appsignal/integrations/webmachine.rb +15 -9
  28. data/lib/appsignal/probes/gvl.rb +24 -2
  29. data/lib/appsignal/probes/sidekiq.rb +1 -1
  30. data/lib/appsignal/probes.rb +1 -1
  31. data/lib/appsignal/rack/abstract_middleware.rb +104 -33
  32. data/lib/appsignal/rack/body_wrapper.rb +143 -0
  33. data/lib/appsignal/rack/event_handler.rb +12 -3
  34. data/lib/appsignal/rack/generic_instrumentation.rb +5 -4
  35. data/lib/appsignal/rack/grape_middleware.rb +40 -0
  36. data/lib/appsignal/rack/hanami_middleware.rb +2 -12
  37. data/lib/appsignal/rack/instrumentation_middleware.rb +62 -0
  38. data/lib/appsignal/rack/rails_instrumentation.rb +14 -57
  39. data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -3
  40. data/lib/appsignal/rack/streaming_listener.rb +13 -59
  41. data/lib/appsignal/rack.rb +31 -0
  42. data/lib/appsignal/transaction.rb +50 -8
  43. data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
  44. data/lib/appsignal/utils.rb +1 -0
  45. data/lib/appsignal/version.rb +1 -1
  46. data/lib/appsignal.rb +36 -33
  47. data/spec/.rubocop.yml +1 -1
  48. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  49. data/spec/lib/appsignal/cli/install_spec.rb +3 -3
  50. data/spec/lib/appsignal/config_spec.rb +8 -5
  51. data/spec/lib/appsignal/demo_spec.rb +38 -41
  52. data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
  53. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
  54. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
  55. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
  56. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
  57. data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
  58. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
  59. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
  60. data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
  61. data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
  62. data/spec/lib/appsignal/hooks/rake_spec.rb +107 -34
  63. data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
  64. data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
  65. data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
  66. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
  67. data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
  68. data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
  69. data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
  70. data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
  71. data/spec/lib/appsignal/integrations/padrino_spec.rb +190 -163
  72. data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
  73. data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
  74. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
  75. data/spec/lib/appsignal/integrations/sinatra_spec.rb +10 -3
  76. data/spec/lib/appsignal/integrations/webmachine_spec.rb +77 -40
  77. data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
  78. data/spec/lib/appsignal/probes_spec.rb +7 -4
  79. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +302 -105
  80. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +263 -0
  81. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
  82. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +70 -27
  83. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
  84. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
  85. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +38 -0
  86. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
  87. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
  88. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +44 -139
  89. data/spec/lib/appsignal/transaction_spec.rb +239 -94
  90. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
  91. data/spec/lib/appsignal_spec.rb +556 -344
  92. data/spec/support/helpers/dependency_helper.rb +6 -1
  93. data/spec/support/helpers/std_streams_helper.rb +1 -1
  94. data/spec/support/helpers/transaction_helpers.rb +8 -0
  95. data/spec/support/matchers/transaction.rb +185 -0
  96. data/spec/support/mocks/dummy_app.rb +20 -0
  97. data/spec/support/shared_examples/instrument.rb +17 -12
  98. data/spec/support/testing.rb +18 -9
  99. metadata +20 -11
  100. data/.semaphore/semaphore.yml +0 -2347
  101. data/script/lint_git +0 -22
  102. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
  103. data/spec/support/matchers/be_completed.rb +0 -5
  104. data/support/check_versions +0 -22
  105. /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
@@ -0,0 +1,163 @@
1
+ describe Appsignal::Utils::IntegrationLogger do
2
+ let(:formatter) { nil }
3
+ let(:logger) do
4
+ Appsignal::Utils::IntegrationMemoryLogger.new.tap do |l|
5
+ l.formatter = formatter if formatter
6
+ end
7
+ end
8
+
9
+ describe "#add" do
10
+ it "adds a log message with the severity" do
11
+ logger.add(:DEBUG, "debug message")
12
+ logger.add(:INFO, "info message")
13
+ logger.add(:WARN, "warn message")
14
+ logger.add(:ERROR, "error message")
15
+ logger.add(:FATAL, "fatal message")
16
+ logger.add(:UNKNOWN, "unknown message")
17
+
18
+ expect(logger.messages[:DEBUG]).to eq(["debug message"])
19
+ expect(logger.messages[:INFO]).to eq(["info message"])
20
+ expect(logger.messages[:WARN]).to eq(["warn message"])
21
+ expect(logger.messages[:ERROR]).to eq(["error message"])
22
+ expect(logger.messages[:FATAL]).to eq(["fatal message"])
23
+ expect(logger.messages[:UNKNOWN]).to eq(["unknown message"])
24
+ end
25
+
26
+ context "without formatter" do
27
+ it "logs in the default format" do
28
+ logger.add(:DEBUG, "debug message")
29
+ expect(logger.messages[:DEBUG]).to eq(["debug message"])
30
+ end
31
+ end
32
+
33
+ context "with formatter" do
34
+ let(:formatter) do
35
+ proc do |severity, _datetime, _progname, msg|
36
+ "[TIME (process) #PID][#{severity}] #{msg}\n"
37
+ end
38
+ end
39
+
40
+ it "formats the logs using the formatter" do
41
+ logger.add(:DEBUG, "debug message")
42
+ expect(logger.messages[:DEBUG]).to eq(["[TIME (process) #PID][DEBUG] debug message\n"])
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#debug" do
48
+ it "adds a log message with the debug severity" do
49
+ logger.debug("debug message")
50
+
51
+ expect(logger.messages[:DEBUG]).to eq(["debug message"])
52
+ end
53
+ end
54
+
55
+ describe "#info" do
56
+ it "adds a log message with the info severity" do
57
+ logger.info("info message")
58
+
59
+ expect(logger.messages[:INFO]).to eq(["info message"])
60
+ end
61
+ end
62
+
63
+ describe "#warn" do
64
+ it "adds a log message with the warn severity" do
65
+ logger.warn("warn message")
66
+
67
+ expect(logger.messages[:WARN]).to eq(["warn message"])
68
+ end
69
+ end
70
+
71
+ describe "#warn_once_then_debug" do
72
+ it "only warns once, then uses debug" do
73
+ message = "This is a log line"
74
+ 3.times { logger.warn_once_then_debug(:key, message) }
75
+
76
+ expect(logger.messages[:WARN]).to eq([message])
77
+ expect(logger.messages[:DEBUG]).to eq([message, message])
78
+ end
79
+ end
80
+
81
+ describe "#error" do
82
+ it "adds a log message with the error severity" do
83
+ logger.error("error message")
84
+
85
+ expect(logger.messages[:ERROR]).to eq(["error message"])
86
+ end
87
+ end
88
+
89
+ describe "#fatal" do
90
+ it "adds a log message with the fatal severity" do
91
+ logger.fatal("fatal message")
92
+
93
+ expect(logger.messages[:FATAL]).to eq(["fatal message"])
94
+ end
95
+ end
96
+
97
+ describe "#unknown" do
98
+ it "adds a log message with the unknown severity" do
99
+ logger.unknown("unknown message")
100
+
101
+ expect(logger.messages[:UNKNOWN]).to eq(["unknown message"])
102
+ end
103
+ end
104
+
105
+ describe "#clear" do
106
+ it "clears all log messages" do
107
+ logger.add(:DEBUG, "debug message")
108
+ logger.add(:INFO, "info message")
109
+ logger.add(:WARN, "warn message")
110
+ logger.add(:ERROR, "error message")
111
+ logger.add(:FATAL, "fatal message")
112
+ logger.add(:UNKNOWN, "unknown message")
113
+ logger.clear
114
+
115
+ expect(logger.messages).to be_empty
116
+ end
117
+ end
118
+
119
+ describe "#messages_for_level" do
120
+ it "returns only log messages for level and higher" do
121
+ logger.add(:DEBUG, "debug message")
122
+ logger.add(:INFO, "info message")
123
+ logger.add(:WARN, "warn message")
124
+ logger.add(:ERROR, "error message")
125
+ logger.add(:FATAL, "fatal message")
126
+ logger.add(:UNKNOWN, "unknown message")
127
+
128
+ expect(logger.messages_for_level(Logger::DEBUG)).to eq([
129
+ "debug message",
130
+ "info message",
131
+ "warn message",
132
+ "error message",
133
+ "fatal message",
134
+ "unknown message"
135
+ ])
136
+ expect(logger.messages_for_level(Logger::INFO)).to eq([
137
+ "info message",
138
+ "warn message",
139
+ "error message",
140
+ "fatal message",
141
+ "unknown message"
142
+ ])
143
+ expect(logger.messages_for_level(Logger::WARN)).to eq([
144
+ "warn message",
145
+ "error message",
146
+ "fatal message",
147
+ "unknown message"
148
+ ])
149
+ expect(logger.messages_for_level(Logger::ERROR)).to eq([
150
+ "error message",
151
+ "fatal message",
152
+ "unknown message"
153
+ ])
154
+ expect(logger.messages_for_level(Logger::FATAL)).to eq([
155
+ "fatal message",
156
+ "unknown message"
157
+ ])
158
+ expect(logger.messages_for_level(Logger::UNKNOWN)).to eq([
159
+ "unknown message"
160
+ ])
161
+ end
162
+ end
163
+ end