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 +4 -4
- data/.github/workflows/create_release_from_tag.yml +59 -0
- data/CHANGELOG.md +36 -0
- data/Rakefile +1 -1
- data/ext/agent.rb +27 -27
- data/gemfiles/grape.gemfile +3 -4
- data/gemfiles/rails-7.1.gemfile +1 -0
- data/lib/appsignal/event_formatter/view_component/render_formatter.rb +33 -0
- data/lib/appsignal/heartbeat.rb +2 -14
- data/lib/appsignal/helpers/heartbeats.rb +44 -0
- data/lib/appsignal/probes.rb +16 -4
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +4 -2
- data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +43 -0
- data/spec/lib/appsignal/heartbeat_spec.rb +40 -2
- data/spec/lib/appsignal/probes_spec.rb +24 -5
- data/spec/lib/appsignal/transaction_spec.rb +0 -1
- data/spec/support/helpers/dependency_helper.rb +4 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2efeb1057d0b9afac2d97367e7cc531c5ae0b5781da74d612ac8f1d27b3c1441
|
4
|
+
data.tar.gz: e55719783fdaad7abd0cf6fcdee6a27206e9b1f08ed0ef5ac577422e9258d5d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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" => "
|
17
|
+
"checksum" => "61210c40be70e0616a356d06040961b096e2d47332021a52f3779912a9fe0e4c",
|
18
18
|
"filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
|
19
19
|
},
|
20
20
|
"dynamic" => {
|
21
|
-
"checksum" => "
|
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" => "
|
27
|
+
"checksum" => "61210c40be70e0616a356d06040961b096e2d47332021a52f3779912a9fe0e4c",
|
28
28
|
"filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
|
29
29
|
},
|
30
30
|
"dynamic" => {
|
31
|
-
"checksum" => "
|
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" => "
|
37
|
+
"checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
|
38
38
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
39
39
|
},
|
40
40
|
"dynamic" => {
|
41
|
-
"checksum" => "
|
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" => "
|
47
|
+
"checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
|
48
48
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
49
49
|
},
|
50
50
|
"dynamic" => {
|
51
|
-
"checksum" => "
|
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" => "
|
57
|
+
"checksum" => "9b97c42561450f9af9ae63816d32b8db69be6f2745226f63d6eada4369c68a20",
|
58
58
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
59
59
|
},
|
60
60
|
"dynamic" => {
|
61
|
-
"checksum" => "
|
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" => "
|
67
|
+
"checksum" => "358db07cfa85d6bd048bd2bb05fc9607d4fe0d4396fd023d658e945e4a675fba",
|
68
68
|
"filename" => "appsignal-aarch64-linux-all-static.tar.gz"
|
69
69
|
},
|
70
70
|
"dynamic" => {
|
71
|
-
"checksum" => "
|
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" => "
|
77
|
+
"checksum" => "315bf1fc5d9c97b6f26e61f5e39919e0ba425b1d96ea6243cdb2f650487c407e",
|
78
78
|
"filename" => "appsignal-i686-linux-all-static.tar.gz"
|
79
79
|
},
|
80
80
|
"dynamic" => {
|
81
|
-
"checksum" => "
|
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" => "
|
87
|
+
"checksum" => "315bf1fc5d9c97b6f26e61f5e39919e0ba425b1d96ea6243cdb2f650487c407e",
|
88
88
|
"filename" => "appsignal-i686-linux-all-static.tar.gz"
|
89
89
|
},
|
90
90
|
"dynamic" => {
|
91
|
-
"checksum" => "
|
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" => "
|
97
|
+
"checksum" => "3fe42df2a52706c23f967b8421ac816fa37a38998bd24b1d6aafd59a324b23ff",
|
98
98
|
"filename" => "appsignal-x86_64-linux-all-static.tar.gz"
|
99
99
|
},
|
100
100
|
"dynamic" => {
|
101
|
-
"checksum" => "
|
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" => "
|
107
|
+
"checksum" => "1fe0ed0c0ca51eccd4c2ec3bb94bb1834bae19bc2c185b67c3f940f704abe9fc",
|
108
108
|
"filename" => "appsignal-x86_64-linux-musl-all-static.tar.gz"
|
109
109
|
},
|
110
110
|
"dynamic" => {
|
111
|
-
"checksum" => "
|
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" => "
|
117
|
+
"checksum" => "5027782008872f8091608cc5531a6dd90f0652e9ebb0404f7e86eb73f0807ba0",
|
118
118
|
"filename" => "appsignal-aarch64-linux-musl-all-static.tar.gz"
|
119
119
|
},
|
120
120
|
"dynamic" => {
|
121
|
-
"checksum" => "
|
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" => "
|
127
|
+
"checksum" => "1337268caaddd66bb170298968d50d76cc66f17e808c46a677ba00d1b78eb317",
|
128
128
|
"filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
|
129
129
|
},
|
130
130
|
"dynamic" => {
|
131
|
-
"checksum" => "
|
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" => "
|
137
|
+
"checksum" => "1337268caaddd66bb170298968d50d76cc66f17e808c46a677ba00d1b78eb317",
|
138
138
|
"filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
|
139
139
|
},
|
140
140
|
"dynamic" => {
|
141
|
-
"checksum" => "
|
141
|
+
"checksum" => "2b93af244d1d214b59c2657677bf96445f67cade2fa1bfd6cda78c8bec75cbca",
|
142
142
|
"filename" => "appsignal-x86_64-freebsd-all-dynamic.tar.gz"
|
143
143
|
}
|
144
144
|
}
|
data/gemfiles/grape.gemfile
CHANGED
data/gemfiles/rails-7.1.gemfile
CHANGED
@@ -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
|
data/lib/appsignal/heartbeat.rb
CHANGED
@@ -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.
|
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
|
data/lib/appsignal/probes.rb
CHANGED
@@ -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
|
-
|
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 =
|
235
|
+
remaining_seconds = ITERATION_IN_SECONDS - Time.now.sec
|
224
236
|
return remaining_seconds if remaining_seconds > 30
|
225
237
|
|
226
|
-
remaining_seconds +
|
238
|
+
remaining_seconds + ITERATION_IN_SECONDS
|
227
239
|
end
|
228
240
|
|
229
241
|
def initialize_probes
|
data/lib/appsignal/version.rb
CHANGED
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
|
100
|
+
internal_logger.info("Not starting AppSignal, extension is not loaded")
|
99
101
|
return
|
100
102
|
end
|
101
103
|
|
102
|
-
internal_logger.debug("
|
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
|
-
|
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
|
+
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-
|
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.
|
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
|