appsignal 3.7.4 → 3.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e1761916266f8e937324fdd06fc35239e346cef46a5835b3a4f605a724a4b32
4
- data.tar.gz: 83a356f5c62b027e785a3ee5718d26df65301fb0adfad597a5699c59f754da5d
3
+ metadata.gz: 2efeb1057d0b9afac2d97367e7cc531c5ae0b5781da74d612ac8f1d27b3c1441
4
+ data.tar.gz: e55719783fdaad7abd0cf6fcdee6a27206e9b1f08ed0ef5ac577422e9258d5d4
5
5
  SHA512:
6
- metadata.gz: 6ddf7ffc0c9edfbe34ba1825f2e4abfc89df5238aa1866bae9652f11629c760ad7d638824650321b3e8728b409c0c9e30b64653ffd6ac1df07413490544bf7b0
7
- data.tar.gz: 41be1cf851cbf8c64b2a3c0e24811c47a838e77a9ed320a9ef1695690fd186a2101feb7603166e53f44a6de9992ebec306c2b4d513ea5e663b91354307a2cbe6
6
+ metadata.gz: 3cc5ce97c7050bad66f043c92fee70c7e1ad215aa8eec8cf72ddff2edd0a34f875fe3fb63794d010f534eba32a8c15c12f81b6b0f03c61a62b9fd6e48562aed0
7
+ data.tar.gz: a6a3da8e140002a3bb41b3135d4e23727aa77b21c33f533e926ea71b7d9fe96268e6a845837a0555a18e06eb7b443204c1814a6558a2622ef1efd38ed707458f
@@ -0,0 +1,59 @@
1
+ name: "Create release from tag"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v**"
7
+
8
+ permissions:
9
+ contents: write
10
+ actions: write
11
+
12
+ jobs:
13
+ release:
14
+ name: "Create release"
15
+ runs-on: ubuntu-latest
16
+ env:
17
+ PACKAGE_NAME: "Ruby gem"
18
+ CHANGELOG_LINK: "https://github.com/appsignal/appsignal-ruby/blob/main/CHANGELOG.md"
19
+ steps:
20
+ - name: Checkout repository at tag
21
+ uses: actions/checkout@v4
22
+ with:
23
+ ref: "${{ github.ref }}"
24
+
25
+ - name: Get tag name
26
+ run: |
27
+ echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
28
+
29
+ - name: Get changelog contents from tag
30
+ run: |
31
+ # Use sed to remove everything after "-----BEGIN PGP SIGNATURE-----" if it's present
32
+ # and also always remove the last line of the git show output
33
+ git show --format=oneline --no-color --no-patch "${{ env.TAG_NAME }}" \
34
+ | sed '1,2d' \
35
+ | sed '$d' \
36
+ | sed '/-----BEGIN PGP SIGNATURE-----/,$d' \
37
+ > CHANGELOG_TEXT.txt
38
+
39
+ echo "" >> CHANGELOG_TEXT.txt
40
+ echo "" >> CHANGELOG_TEXT.txt
41
+
42
+ TAG_NAME_FOR_LINK=$(echo "${{ env.TAG_NAME }}" | sed 's/^v//' | tr -d '.')
43
+ echo "View the [$PACKAGE_NAME ${{ env.TAG_NAME }} changelog]($CHANGELOG_LINK#$TAG_NAME_FOR_LINK) for more information." >> CHANGELOG_TEXT.txt
44
+
45
+ - name: Submit changelog entry
46
+ run: |
47
+ # Prepare JSON payload using jq to ensure proper escaping
48
+ payload=$(jq -n \
49
+ --arg package "Ruby gem" \
50
+ --arg version "${{ env.TAG_NAME }}" \
51
+ --arg changelog "$(cat CHANGELOG_TEXT.txt)" \
52
+ '{ref: "main", inputs: {package: $package, version: $version, changelog: $changelog}}')
53
+
54
+ curl -X POST \
55
+ -H "Authorization: token ${{ secrets.INTEGRATIONS_CHANGELOG_TOKEN }}" \
56
+ -H "Accept: application/vnd.github+json" \
57
+ --fail-with-body \
58
+ https://api.github.com/repos/appsignal/appsignal.com/actions/workflows/102125282/dispatches \
59
+ -d "$payload"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.7.6
4
+
5
+ _Published on 2024-06-11._
6
+
7
+ ### Changed
8
+
9
+ - [704a7d29](https://github.com/appsignal/appsignal-ruby/commit/704a7d29ae428f93549000a2c606bff948040c96) patch - When the minutely probes thread takes more than 60 seconds to run all the registered probes, log an error. This helps find issues with the metrics reported by the probes not being accurately reported for every minute.
10
+ - [5f4cc8be](https://github.com/appsignal/appsignal-ruby/commit/5f4cc8beb0ad88a0a58265d990626a7ee39fddd3) patch - Internal agent changes for the Ruby gem.
11
+
12
+ ## 3.7.5
13
+
14
+ _Published on 2024-05-14._
15
+
16
+ ### Added
17
+
18
+ - [bf81e165](https://github.com/appsignal/appsignal-ruby/commit/bf81e16593c7598e266d1e4cfb108aeef2ed7e73) patch - Support events emitted by ViewComponent. Rendering of ViewComponent-based components will appear as events in your performance samples' event timeline.
19
+
20
+ For AppSignal to instrument ViewComponent events, you must first configure ViewComponent to emit those events:
21
+
22
+ ```ruby
23
+ # config/application.rb
24
+ module MyRailsApp
25
+ class Application < Rails::Application
26
+ config.view_component.instrumentation_enabled = true
27
+ config.view_component.use_deprecated_instrumentation_name = false
28
+ end
29
+ end
30
+ ```
31
+
32
+ Thanks to Trae Robrock (@trobrock) for providing a starting point for this implementation!
33
+ - [ad5c9955](https://github.com/appsignal/appsignal-ruby/commit/ad5c99556421fe86501205465053466a91f28448) patch - Support Kamal-based deployments. Read the `KAMAL_VERSION` environment variable, which Kamal exposes within the deployed container, if present, and use it as the application revision if it is not set. This will automatically report deploy markers for applications using Kamal.
34
+
35
+ ### Fixed
36
+
37
+ - [30bb675f](https://github.com/appsignal/appsignal-ruby/commit/30bb675ffa99ec1949a613f309e6c1792b88d4ce) patch - Fix an issue where an error about the AppSignal internal logger is raised when sending a heartbeat.
38
+
3
39
  ## 3.7.4
4
40
 
5
41
  _Published on 2024-05-09._
data/Rakefile CHANGED
@@ -324,7 +324,7 @@ begin
324
324
 
325
325
  desc "Run the AppSignal gem test suite."
326
326
  RSpec::Core::RakeTask.new :test do |t|
327
- t.rspec_opts = exclude_pattern
327
+ t.rspec_opts = "#{exclude_pattern} --format documentation"
328
328
  end
329
329
 
330
330
  namespace :test do
data/ext/agent.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # Modifications to this file will be overwritten with the next agent release.
7
7
 
8
8
  APPSIGNAL_AGENT_CONFIG = {
9
- "version" => "0.35.5",
9
+ "version" => "0.35.12",
10
10
  "mirrors" => [
11
11
  "https://appsignal-agent-releases.global.ssl.fastly.net",
12
12
  "https://d135dj0rjqvssy.cloudfront.net"
@@ -14,131 +14,131 @@ APPSIGNAL_AGENT_CONFIG = {
14
14
  "triples" => {
15
15
  "x86_64-darwin" => {
16
16
  "static" => {
17
- "checksum" => "3985b53b2a2814d44737182890e6fbe31b4b88361025140477a598e0e41fd948",
17
+ "checksum" => "61210c40be70e0616a356d06040961b096e2d47332021a52f3779912a9fe0e4c",
18
18
  "filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
19
19
  },
20
20
  "dynamic" => {
21
- "checksum" => "d135e2daf5c041a4ce7a7ab720cfd977fbae8375a007995e33a96558d3635792",
21
+ "checksum" => "dd165289445c80e4dcc148ea09c613b23b001c90ad885aef1de08db65ab5bf1c",
22
22
  "filename" => "appsignal-x86_64-darwin-all-dynamic.tar.gz"
23
23
  }
24
24
  },
25
25
  "universal-darwin" => {
26
26
  "static" => {
27
- "checksum" => "3985b53b2a2814d44737182890e6fbe31b4b88361025140477a598e0e41fd948",
27
+ "checksum" => "61210c40be70e0616a356d06040961b096e2d47332021a52f3779912a9fe0e4c",
28
28
  "filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
29
29
  },
30
30
  "dynamic" => {
31
- "checksum" => "d135e2daf5c041a4ce7a7ab720cfd977fbae8375a007995e33a96558d3635792",
31
+ "checksum" => "dd165289445c80e4dcc148ea09c613b23b001c90ad885aef1de08db65ab5bf1c",
32
32
  "filename" => "appsignal-x86_64-darwin-all-dynamic.tar.gz"
33
33
  }
34
34
  },
35
35
  "aarch64-darwin" => {
36
36
  "static" => {
37
- "checksum" => "79d22436bfe32dab4661f2a4149c6ab34c71e810c5d808ee3e60cd9f8a1395e4",
37
+ "checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
38
38
  "filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
39
39
  },
40
40
  "dynamic" => {
41
- "checksum" => "2c49c8f24a9dd8f9d55c28015b3e1096180807e7b13d4a9cd8ed30f58bc6612f",
41
+ "checksum" => "0c81959ab5de3c98c70b7e308826d7deee8e208ee47b7637d505b0a1d70af8c4",
42
42
  "filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
43
43
  }
44
44
  },
45
45
  "arm64-darwin" => {
46
46
  "static" => {
47
- "checksum" => "79d22436bfe32dab4661f2a4149c6ab34c71e810c5d808ee3e60cd9f8a1395e4",
47
+ "checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
48
48
  "filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
49
49
  },
50
50
  "dynamic" => {
51
- "checksum" => "2c49c8f24a9dd8f9d55c28015b3e1096180807e7b13d4a9cd8ed30f58bc6612f",
51
+ "checksum" => "0c81959ab5de3c98c70b7e308826d7deee8e208ee47b7637d505b0a1d70af8c4",
52
52
  "filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
53
53
  }
54
54
  },
55
55
  "arm-darwin" => {
56
56
  "static" => {
57
- "checksum" => "79d22436bfe32dab4661f2a4149c6ab34c71e810c5d808ee3e60cd9f8a1395e4",
57
+ "checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
58
58
  "filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
59
59
  },
60
60
  "dynamic" => {
61
- "checksum" => "2c49c8f24a9dd8f9d55c28015b3e1096180807e7b13d4a9cd8ed30f58bc6612f",
61
+ "checksum" => "0c81959ab5de3c98c70b7e308826d7deee8e208ee47b7637d505b0a1d70af8c4",
62
62
  "filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
63
63
  }
64
64
  },
65
65
  "aarch64-linux" => {
66
66
  "static" => {
67
- "checksum" => "4a54587bb61f59d0b60032b2e0c1d14d2e726e20af049353c2ff279d07dd3028",
67
+ "checksum" => "358db07cfa85d6bd048bd2bb05fc9607d4fe0d4396fd023d658e945e4a675fba",
68
68
  "filename" => "appsignal-aarch64-linux-all-static.tar.gz"
69
69
  },
70
70
  "dynamic" => {
71
- "checksum" => "aa2d011c538ce547c87110e7c8e49a24597d60ea2d1418032fc3db06267efba2",
71
+ "checksum" => "9e76651d52f78882ab126d94a8af61794d1ce0cdffa6dd01a3e032599a1b2796",
72
72
  "filename" => "appsignal-aarch64-linux-all-dynamic.tar.gz"
73
73
  }
74
74
  },
75
75
  "i686-linux" => {
76
76
  "static" => {
77
- "checksum" => "01e2237029c3af23cc6f348fb63f65a92b8caf8f4731b78d014bb4001559aad5",
77
+ "checksum" => "315bf1fc5d9c97b6f26e61f5e39919e0ba425b1d96ea6243cdb2f650487c407e",
78
78
  "filename" => "appsignal-i686-linux-all-static.tar.gz"
79
79
  },
80
80
  "dynamic" => {
81
- "checksum" => "c1043ac92b000a406d9afb77b6ec1d3ab6cfffd63c218a720c11daa3edb7fd1f",
81
+ "checksum" => "8cf0b5e6ef70a7758b98457012bfebb7964acb2d47648f3817c9f32a70bc0ab1",
82
82
  "filename" => "appsignal-i686-linux-all-dynamic.tar.gz"
83
83
  }
84
84
  },
85
85
  "x86-linux" => {
86
86
  "static" => {
87
- "checksum" => "01e2237029c3af23cc6f348fb63f65a92b8caf8f4731b78d014bb4001559aad5",
87
+ "checksum" => "315bf1fc5d9c97b6f26e61f5e39919e0ba425b1d96ea6243cdb2f650487c407e",
88
88
  "filename" => "appsignal-i686-linux-all-static.tar.gz"
89
89
  },
90
90
  "dynamic" => {
91
- "checksum" => "c1043ac92b000a406d9afb77b6ec1d3ab6cfffd63c218a720c11daa3edb7fd1f",
91
+ "checksum" => "8cf0b5e6ef70a7758b98457012bfebb7964acb2d47648f3817c9f32a70bc0ab1",
92
92
  "filename" => "appsignal-i686-linux-all-dynamic.tar.gz"
93
93
  }
94
94
  },
95
95
  "x86_64-linux" => {
96
96
  "static" => {
97
- "checksum" => "beae1db2c122eb579f1ccb450177b0c64d65569d774efc7a1ee72c42d3382d39",
97
+ "checksum" => "3fe42df2a52706c23f967b8421ac816fa37a38998bd24b1d6aafd59a324b23ff",
98
98
  "filename" => "appsignal-x86_64-linux-all-static.tar.gz"
99
99
  },
100
100
  "dynamic" => {
101
- "checksum" => "67650f59d2ea9c99cde7dfe44da65a506522a3cdccabe697931d89ebaea96d18",
101
+ "checksum" => "8781f0a4c4810229f19000ebb882b7d8e5e0440ffcf8e5ffea7d68d082be8e69",
102
102
  "filename" => "appsignal-x86_64-linux-all-dynamic.tar.gz"
103
103
  }
104
104
  },
105
105
  "x86_64-linux-musl" => {
106
106
  "static" => {
107
- "checksum" => "521c4486d10cdafa1f72103cc439d6f0e4f549f1522c4473bf43dc487ec42436",
107
+ "checksum" => "1fe0ed0c0ca51eccd4c2ec3bb94bb1834bae19bc2c185b67c3f940f704abe9fc",
108
108
  "filename" => "appsignal-x86_64-linux-musl-all-static.tar.gz"
109
109
  },
110
110
  "dynamic" => {
111
- "checksum" => "0a94fcee8eb1f8fd06fce3eacffbcf9f2a52f5cde040796e19a589176525db4b",
111
+ "checksum" => "f241f905555e17178a72b217dc373ead33daa97757e100b895f2d1318e4dce0d",
112
112
  "filename" => "appsignal-x86_64-linux-musl-all-dynamic.tar.gz"
113
113
  }
114
114
  },
115
115
  "aarch64-linux-musl" => {
116
116
  "static" => {
117
- "checksum" => "c29aab31f4ca59efb1483f48c0cb3c27d799347b81655a28f24c146b55aa7db6",
117
+ "checksum" => "5027782008872f8091608cc5531a6dd90f0652e9ebb0404f7e86eb73f0807ba0",
118
118
  "filename" => "appsignal-aarch64-linux-musl-all-static.tar.gz"
119
119
  },
120
120
  "dynamic" => {
121
- "checksum" => "4b77ea0c1f50ada6e5f6ed693002e56db1e34e0e9d5fdb4ac80fc52fd51099b8",
121
+ "checksum" => "ae3147790f25cef200142f61eb6ce1f8b3ac5fa2647ad7a4234f1bbb976bde98",
122
122
  "filename" => "appsignal-aarch64-linux-musl-all-dynamic.tar.gz"
123
123
  }
124
124
  },
125
125
  "x86_64-freebsd" => {
126
126
  "static" => {
127
- "checksum" => "a3598e9df1b6b5970aabbbccbe4e77c2372d2320cd87bfa20f32fca53b8505e4",
127
+ "checksum" => "1337268caaddd66bb170298968d50d76cc66f17e808c46a677ba00d1b78eb317",
128
128
  "filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
129
129
  },
130
130
  "dynamic" => {
131
- "checksum" => "4cbfd5e16776c8ea4308ee7f3a096c5cc137f2506f8a05d9c8504e3483fcd8ac",
131
+ "checksum" => "2b93af244d1d214b59c2657677bf96445f67cade2fa1bfd6cda78c8bec75cbca",
132
132
  "filename" => "appsignal-x86_64-freebsd-all-dynamic.tar.gz"
133
133
  }
134
134
  },
135
135
  "amd64-freebsd" => {
136
136
  "static" => {
137
- "checksum" => "a3598e9df1b6b5970aabbbccbe4e77c2372d2320cd87bfa20f32fca53b8505e4",
137
+ "checksum" => "1337268caaddd66bb170298968d50d76cc66f17e808c46a677ba00d1b78eb317",
138
138
  "filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
139
139
  },
140
140
  "dynamic" => {
141
- "checksum" => "4cbfd5e16776c8ea4308ee7f3a096c5cc137f2506f8a05d9c8504e3483fcd8ac",
141
+ "checksum" => "2b93af244d1d214b59c2657677bf96445f67cade2fa1bfd6cda78c8bec75cbca",
142
142
  "filename" => "appsignal-x86_64-freebsd-all-dynamic.tar.gz"
143
143
  }
144
144
  }
@@ -1,6 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'grape'
4
- gem 'activesupport', '~> 4.2'
3
+ gem "grape"
5
4
 
6
- gemspec :path => '../'
5
+ gemspec :path => "../"
@@ -3,6 +3,7 @@ source "https://rubygems.org"
3
3
  gem "rails", "~> 7.1.0"
4
4
  gem "rake", "> 12.2"
5
5
  gem "sidekiq"
6
+ gem "view_component"
6
7
 
7
8
  # Fix install issue for jruby on gem 3.1.8.
8
9
  # No java stub is published.
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ class EventFormatter
5
+ # @api private
6
+ module ViewComponent
7
+ class RenderFormatter
8
+ BLANK = ""
9
+
10
+ attr_reader :root_path
11
+
12
+ def initialize
13
+ @root_path = "#{Rails.root}/"
14
+ end
15
+
16
+ def format(payload)
17
+ [payload[:name], payload[:identifier].sub(@root_path, BLANK)]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ if defined?(Rails) && defined?(ViewComponent)
25
+ Appsignal::EventFormatter.register(
26
+ "render.view_component",
27
+ Appsignal::EventFormatter::ViewComponent::RenderFormatter
28
+ )
29
+ Appsignal::EventFormatter.register(
30
+ "!render.view_component",
31
+ Appsignal::EventFormatter::ViewComponent::RenderFormatter
32
+ )
33
+ end
@@ -3,6 +3,7 @@
3
3
  module Appsignal
4
4
  class Heartbeat
5
5
  class << self
6
+ # @api private
6
7
  def transmitter
7
8
  @transmitter ||= Appsignal::Transmitter.new(
8
9
  "#{Appsignal.config[:logging_endpoint]}/heartbeats/json"
@@ -45,7 +46,7 @@ module Appsignal
45
46
  response = self.class.transmitter.transmit(event(kind))
46
47
 
47
48
  if response.code.to_i >= 200 && response.code.to_i < 300
48
- Appsignal.internal_logger.trace("Transmitted heartbeat `#{name}` (#{id}) #{kind} event")
49
+ Appsignal.internal_logger.debug("Transmitted heartbeat `#{name}` (#{id}) #{kind} event")
49
50
  else
50
51
  Appsignal.internal_logger.error(
51
52
  "Failed to transmit heartbeat event: status code was #{response.code}"
@@ -55,17 +56,4 @@ module Appsignal
55
56
  Appsignal.internal_logger.error("Failed to transmit heartbeat event: #{e}")
56
57
  end
57
58
  end
58
-
59
- def self.heartbeat(name)
60
- heartbeat = Appsignal::Heartbeat.new(:name => name)
61
- output = nil
62
-
63
- if block_given?
64
- heartbeat.start
65
- output = yield
66
- end
67
-
68
- heartbeat.finish
69
- output
70
- end
71
59
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Helpers
5
+ module Heartbeats
6
+ # Track heartbeats
7
+ #
8
+ # Track the execution of certain processes by sending a hearbeat.
9
+ #
10
+ # To track the duration of a piece of code, pass a block to {.heartbeat}
11
+ # to report both when the process starts, and when it finishes.
12
+ #
13
+ # If an exception is raised within the block, the finish event will not
14
+ # be reported, triggering a notification about the missing heartbeat. The
15
+ # exception will bubble outside of the heartbeat block.
16
+ #
17
+ # @example Send a heartbeat
18
+ # Appsignal.heartbeat("send_invoices")
19
+ #
20
+ # @example Send a heartbeat with duration
21
+ # Appsignal.heartbeat("send_invoices") do
22
+ # # your code
23
+ # end
24
+ #
25
+ # @param name [String] name of the heartbeat to report.
26
+ # @yield the block to monitor.
27
+ # @return [void]
28
+ # @since 3.7.0
29
+ # @see https://docs.appsignal.com/heartbeats
30
+ def heartbeat(name)
31
+ heartbeat = Appsignal::Heartbeat.new(:name => name)
32
+ output = nil
33
+
34
+ if block_given?
35
+ heartbeat.start
36
+ output = yield
37
+ end
38
+
39
+ heartbeat.finish
40
+ output
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- module Probes
4
+ module Probes # rubocop:disable Metrics/ModuleLength
5
+ ITERATION_IN_SECONDS = 60
6
+
5
7
  class ProbeCollection
6
8
  def initialize
7
9
  @probes = {}
@@ -180,6 +182,7 @@ module Appsignal
180
182
  sleep initial_wait_time
181
183
  initialize_probes
182
184
  loop do
185
+ start_time = Time.now
183
186
  logger = Appsignal.internal_logger
184
187
  mutex.synchronize do
185
188
  logger.debug("Gathering minutely metrics with #{probe_instances.count} probes")
@@ -191,6 +194,15 @@ module Appsignal
191
194
  logger.debug ex.backtrace.join("\n")
192
195
  end
193
196
  end
197
+ end_time = Time.now
198
+ duration = end_time - start_time
199
+ if duration >= ITERATION_IN_SECONDS
200
+ logger.error(
201
+ "The minutely probes took more than 60 seconds. " \
202
+ "The probes should not take this long as metrics will not " \
203
+ "be accurately reported."
204
+ )
205
+ end
194
206
  sleep wait_time
195
207
  end
196
208
  end
@@ -214,16 +226,16 @@ module Appsignal
214
226
 
215
227
  # @api private
216
228
  def wait_time
217
- 60 - Time.now.sec
229
+ ITERATION_IN_SECONDS - Time.now.sec
218
230
  end
219
231
 
220
232
  private
221
233
 
222
234
  def initial_wait_time
223
- remaining_seconds = 60 - Time.now.sec
235
+ remaining_seconds = ITERATION_IN_SECONDS - Time.now.sec
224
236
  return remaining_seconds if remaining_seconds > 30
225
237
 
226
- remaining_seconds + 60
238
+ remaining_seconds + ITERATION_IN_SECONDS
227
239
  end
228
240
 
229
241
  def initialize_probes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.7.4"
4
+ VERSION = "3.7.6"
5
5
  end
data/lib/appsignal.rb CHANGED
@@ -6,6 +6,7 @@ require "stringio"
6
6
 
7
7
  require "appsignal/logger"
8
8
  require "appsignal/utils/stdout_and_logger_message"
9
+ require "appsignal/helpers/heartbeats"
9
10
  require "appsignal/helpers/instrumentation"
10
11
  require "appsignal/helpers/metrics"
11
12
 
@@ -17,6 +18,7 @@ require "appsignal/helpers/metrics"
17
18
  # {Appsignal::Helpers::Metrics}) for ease of use.
18
19
  module Appsignal
19
20
  class << self
21
+ include Helpers::Heartbeats
20
22
  include Helpers::Instrumentation
21
23
  include Helpers::Metrics
22
24
 
@@ -95,11 +97,11 @@ module Appsignal
95
97
  # @since 0.7.0
96
98
  def start
97
99
  unless extension_loaded?
98
- internal_logger.info("Not starting appsignal, extension is not loaded")
100
+ internal_logger.info("Not starting AppSignal, extension is not loaded")
99
101
  return
100
102
  end
101
103
 
102
- internal_logger.debug("Starting appsignal")
104
+ internal_logger.debug("Loading AppSignal gem")
103
105
 
104
106
  @config ||= Config.new(
105
107
  Dir.pwd,
@@ -0,0 +1,43 @@
1
+ describe Appsignal::EventFormatter::ViewComponent::RenderFormatter do
2
+ let(:klass) { Appsignal::EventFormatter::ViewComponent::RenderFormatter }
3
+
4
+ if DependencyHelper.rails_present? && DependencyHelper.view_component_present?
5
+ require "view_component"
6
+
7
+ context "when in a Rails app" do
8
+ let(:formatter) { klass.new }
9
+ before { allow(Rails.root).to receive(:to_s).and_return("/var/www/app/20130101") }
10
+
11
+ it "registers render.view_component and (deprecated) !render.view_component" do
12
+ expect(Appsignal::EventFormatter.registered?("render.view_component",
13
+ klass)).to be_truthy
14
+ expect(Appsignal::EventFormatter.registered?("!render.view_component",
15
+ klass)).to be_truthy
16
+ end
17
+
18
+ describe "#format" do
19
+ subject { formatter.format(payload) }
20
+
21
+ context "with a name and identifier" do
22
+ let(:payload) do
23
+ {
24
+ :name => "WhateverComponent",
25
+ :identifier => "/var/www/app/20130101/app/components/whatever_component.rb"
26
+ }
27
+ end
28
+
29
+ it { is_expected.to eq ["WhateverComponent", "app/components/whatever_component.rb"] }
30
+ end
31
+ end
32
+ end
33
+ else
34
+ context "when not in a Rails app with the ViewComponent gem" do
35
+ it "does not register the event formatter" do
36
+ expect(Appsignal::EventFormatter.registered?("render.view_component",
37
+ klass)).to be_falsy
38
+ expect(Appsignal::EventFormatter.registered?("!render.view_component",
39
+ klass)).to be_falsy
40
+ end
41
+ end
42
+ end
43
+ end
@@ -24,7 +24,26 @@ describe Appsignal::Heartbeat do
24
24
  expect(transmitter).to receive(:transmit).with(hash_including(
25
25
  :name => "heartbeat-name",
26
26
  :kind => "start"
27
- )).and_return(nil)
27
+ )).and_return(Net::HTTPResponse.new(nil, "200", nil))
28
+
29
+ expect(Appsignal.internal_logger).to receive(:debug).with(
30
+ "Transmitted heartbeat `heartbeat-name` (#{heartbeat.id}) start event"
31
+ )
32
+ expect(Appsignal.internal_logger).not_to receive(:error)
33
+
34
+ heartbeat.start
35
+ end
36
+
37
+ it "should log an error if it fails" do
38
+ expect(transmitter).to receive(:transmit).with(hash_including(
39
+ :name => "heartbeat-name",
40
+ :kind => "start"
41
+ )).and_return(Net::HTTPResponse.new(nil, "499", nil))
42
+
43
+ expect(Appsignal.internal_logger).not_to receive(:debug)
44
+ expect(Appsignal.internal_logger).to receive(:error).with(
45
+ "Failed to transmit heartbeat event: status code was 499"
46
+ )
28
47
 
29
48
  heartbeat.start
30
49
  end
@@ -35,7 +54,26 @@ describe Appsignal::Heartbeat do
35
54
  expect(transmitter).to receive(:transmit).with(hash_including(
36
55
  :name => "heartbeat-name",
37
56
  :kind => "finish"
38
- )).and_return(nil)
57
+ )).and_return(Net::HTTPResponse.new(nil, "200", nil))
58
+
59
+ expect(Appsignal.internal_logger).to receive(:debug).with(
60
+ "Transmitted heartbeat `heartbeat-name` (#{heartbeat.id}) finish event"
61
+ )
62
+ expect(Appsignal.internal_logger).not_to receive(:error)
63
+
64
+ heartbeat.finish
65
+ end
66
+
67
+ it "should log an error if it fails" do
68
+ expect(transmitter).to receive(:transmit).with(hash_including(
69
+ :name => "heartbeat-name",
70
+ :kind => "finish"
71
+ )).and_return(Net::HTTPResponse.new(nil, "499", nil))
72
+
73
+ expect(Appsignal.internal_logger).not_to receive(:debug)
74
+ expect(Appsignal.internal_logger).to receive(:error).with(
75
+ "Failed to transmit heartbeat event: status code was 499"
76
+ )
39
77
 
40
78
  heartbeat.finish
41
79
  end
@@ -215,6 +215,29 @@ describe Appsignal::Probes do
215
215
  end
216
216
  end
217
217
 
218
+ context "with a probe that takes 60 seconds" do
219
+ it "logs an error and continues calling the probes every <wait_time>" do
220
+ stub_const("Appsignal::Probes::ITERATION_IN_SECONDS", 0.2)
221
+ calls = 0
222
+ probe = lambda do
223
+ calls += 1
224
+ sleep 0.2
225
+ end
226
+ Appsignal::Probes.register :my_probe, probe
227
+ Appsignal::Probes.register :other_probe, lambda {}
228
+ Appsignal::Probes.start
229
+
230
+ wait_for("enough probe calls") { calls >= 2 }
231
+
232
+ expect(log).to contains_log(
233
+ :error,
234
+ "The minutely probes took more than 60 seconds. " \
235
+ "The probes should not take this long as metrics will not " \
236
+ "be accurately reported."
237
+ )
238
+ end
239
+ end
240
+
218
241
  it "ensures only one minutely probes thread is active at a time" do
219
242
  alive_thread_counter = proc { Thread.list.reject { |t| t.status == "dead" }.length }
220
243
  probe = MockProbe.new
@@ -240,10 +263,6 @@ describe Appsignal::Probes do
240
263
  end
241
264
 
242
265
  context "with thread already started" do
243
- before do
244
- allow(Appsignal::Probes).to receive(:initial_wait_time).and_return(0.00001)
245
- end
246
-
247
266
  it "auto starts probes added after the thread is started" do
248
267
  Appsignal::Probes.start
249
268
  wait_for("Probes thread to start") { Appsignal::Probes.started? }
@@ -290,7 +309,7 @@ describe Appsignal::Probes do
290
309
 
291
310
  describe ".stop" do
292
311
  before do
293
- allow(Appsignal::Probes).to receive(:initial_wait_time).and_return(0.001)
312
+ speed_up_tests!
294
313
  end
295
314
 
296
315
  it "stops the minutely thread" do
@@ -719,7 +719,6 @@ describe Appsignal::Transaction do
719
719
 
720
720
  sample_data = transaction.to_h["sample_data"]
721
721
  expect(sample_data["environment"]).to include(
722
- "CONTENT_LENGTH" => "0",
723
722
  "REQUEST_METHOD" => "GET",
724
723
  "SERVER_NAME" => "example.org",
725
724
  "SERVER_PORT" => "80",
@@ -131,6 +131,10 @@ module DependencyHelper # rubocop:disable Metrics/ModuleLength
131
131
  hanami_present? && Gem.loaded_specs["hanami"].version >= Gem::Version.new("2.0")
132
132
  end
133
133
 
134
+ def view_component_present?
135
+ dependency_present? "view_component"
136
+ end
137
+
134
138
  def dependency_present?(dependency_file)
135
139
  Gem.loaded_specs.key? dependency_file
136
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.4
4
+ version: 3.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-05-09 00:00:00.000000000 Z
13
+ date: 2024-06-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -135,6 +135,7 @@ extra_rdoc_files: []
135
135
  files:
136
136
  - ".github/ISSUE_TEMPLATE/bug_report.md"
137
137
  - ".github/ISSUE_TEMPLATE/chore.md"
138
+ - ".github/workflows/create_release_from_tag.yml"
138
139
  - ".gitignore"
139
140
  - ".gitmodules"
140
141
  - ".rspec"
@@ -203,10 +204,12 @@ files:
203
204
  - lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb
204
205
  - lib/appsignal/event_formatter/rom/sql_formatter.rb
205
206
  - lib/appsignal/event_formatter/sequel/sql_formatter.rb
207
+ - lib/appsignal/event_formatter/view_component/render_formatter.rb
206
208
  - lib/appsignal/extension.rb
207
209
  - lib/appsignal/extension/jruby.rb
208
210
  - lib/appsignal/garbage_collection.rb
209
211
  - lib/appsignal/heartbeat.rb
212
+ - lib/appsignal/helpers/heartbeats.rb
210
213
  - lib/appsignal/helpers/instrumentation.rb
211
214
  - lib/appsignal/helpers/metrics.rb
212
215
  - lib/appsignal/hooks.rb
@@ -313,6 +316,7 @@ files:
313
316
  - spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb
314
317
  - spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb
315
318
  - spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb
319
+ - spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb
316
320
  - spec/lib/appsignal/event_formatter_spec.rb
317
321
  - spec/lib/appsignal/extension/jruby_spec.rb
318
322
  - spec/lib/appsignal/extension_install_failure_spec.rb
@@ -452,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
452
456
  - !ruby/object:Gem::Version
453
457
  version: '0'
454
458
  requirements: []
455
- rubygems_version: 3.3.7
459
+ rubygems_version: 3.5.11
456
460
  signing_key:
457
461
  specification_version: 4
458
462
  summary: Logs performance and exception data from your app to appsignal.com