errorgap 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/errorgap/notice.rb +38 -2
- data/lib/errorgap/rails/railtie.rb +5 -1
- data/lib/errorgap/span_collector.rb +19 -1
- data/lib/errorgap/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cabe7a082d767651c4e56f067d77fa21486056cde995842eb4ef7f8531adbf00
|
|
4
|
+
data.tar.gz: 10cc33121d252ce987eb92ccd2e57301ea4399bafa42c2b8cada4ab0dd4d1f63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 283fcdf5b95bcbf34a175b2e9249c5e2a5b4c16f46bedfe9852f088214ada0e6aa022d84f816a4c692b36291c9a3d8a0f099ee0f18beb15cf5c856d014ecdb14
|
|
7
|
+
data.tar.gz: a66f945ca3d16ee996aeec660dc24351baa3799e7b7404ce209202e98a3c10e6df7eac940c4bdea82e4b7ca86391c98ed3b718c174c0cfe5499485cfb14bd1b2
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.0] - 2026-07-16
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- APM span collection now works when `config.apm_enabled` is set in a Rails
|
|
13
|
+
app initializer (the common case). The `sql.active_record` subscriber was
|
|
14
|
+
previously installed only if APM was already enabled during railtie
|
|
15
|
+
initialization, which runs before `config/initializers` — so transactions
|
|
16
|
+
shipped without spans and the time breakdown showed everything as
|
|
17
|
+
"App / other".
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- In-app backtrace frames now include a source excerpt (`source: {start_line,
|
|
22
|
+
lines}`, ±6 lines around the failing line) so the errorgap UI can render
|
|
23
|
+
backtrace source without a repository integration.
|
|
24
|
+
|
|
25
|
+
- View-rendering time is now recorded as a `view` span (from Rails'
|
|
26
|
+
`process_action.action_controller` `view_runtime`), populating the
|
|
27
|
+
"View rendering" segment of the route time breakdown.
|
|
28
|
+
|
|
8
29
|
## [0.2.0] - 2026-07-10
|
|
9
30
|
|
|
10
31
|
### Added
|
|
@@ -27,5 +48,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
27
48
|
timing and DB query spans, sampled by `config.apm_sample_rate`.
|
|
28
49
|
- Authentication via the `X-Errorgap-Project-Key` header.
|
|
29
50
|
|
|
51
|
+
[0.3.0]: https://github.com/errorgaphq/errorgap-ruby/compare/v0.2.0...v0.3.0
|
|
30
52
|
[0.2.0]: https://github.com/errorgaphq/errorgap-ruby/compare/v0.1.0...v0.2.0
|
|
31
53
|
[0.1.0]: https://github.com/errorgaphq/errorgap-ruby/releases/tag/v0.1.0
|
data/lib/errorgap/notice.rb
CHANGED
|
@@ -4,6 +4,13 @@ require "time"
|
|
|
4
4
|
|
|
5
5
|
module Errorgap
|
|
6
6
|
class Notice
|
|
7
|
+
# Lines of context shipped either side of the failing line for in-app
|
|
8
|
+
# frames, and a cap on how many frames include an excerpt so deep
|
|
9
|
+
# backtraces don't inflate the payload.
|
|
10
|
+
SOURCE_RADIUS = 6
|
|
11
|
+
MAX_SOURCE_FRAMES = 25
|
|
12
|
+
MAX_SOURCE_LINE_LENGTH = 400
|
|
13
|
+
|
|
7
14
|
def self.from_exception(error, configuration:, context: {}, environment: {}, session: {}, params: {})
|
|
8
15
|
new(
|
|
9
16
|
error: error,
|
|
@@ -54,18 +61,47 @@ module Errorgap
|
|
|
54
61
|
end
|
|
55
62
|
|
|
56
63
|
def backtrace_frames
|
|
64
|
+
source_frames = 0
|
|
57
65
|
Array(@error.backtrace).map.with_index do |line, index|
|
|
58
66
|
file, line_number, function = parse_backtrace_line(line)
|
|
59
|
-
{
|
|
67
|
+
frame = {
|
|
60
68
|
file: relative_file(file),
|
|
61
69
|
line: line_number,
|
|
62
70
|
function: function,
|
|
63
71
|
in_app: in_app?(file),
|
|
64
72
|
index: index
|
|
65
|
-
}
|
|
73
|
+
}
|
|
74
|
+
if in_app?(file) && source_frames < MAX_SOURCE_FRAMES &&
|
|
75
|
+
(source = source_excerpt(file, line_number))
|
|
76
|
+
frame[:source] = source
|
|
77
|
+
source_frames += 1
|
|
78
|
+
end
|
|
79
|
+
frame.compact
|
|
66
80
|
end
|
|
67
81
|
end
|
|
68
82
|
|
|
83
|
+
# Reads the lines around the failing line so the server can show source
|
|
84
|
+
# without needing repository access. Returns nil when the file cannot be
|
|
85
|
+
# read (precompiled deploys, eval'd code, template paths).
|
|
86
|
+
def source_excerpt(file, line_number)
|
|
87
|
+
return nil unless line_number && line_number >= 1
|
|
88
|
+
return nil unless file && File.file?(file) && File.readable?(file)
|
|
89
|
+
|
|
90
|
+
lines = File.readlines(file)
|
|
91
|
+
return nil if lines.empty? || line_number > lines.length
|
|
92
|
+
|
|
93
|
+
start_line = [line_number - SOURCE_RADIUS, 1].max
|
|
94
|
+
end_line = [line_number + SOURCE_RADIUS, lines.length].min
|
|
95
|
+
{
|
|
96
|
+
start_line: start_line,
|
|
97
|
+
lines: lines[(start_line - 1)..(end_line - 1)].map do |text|
|
|
98
|
+
text.chomp[0, MAX_SOURCE_LINE_LENGTH]
|
|
99
|
+
end
|
|
100
|
+
}
|
|
101
|
+
rescue StandardError
|
|
102
|
+
nil
|
|
103
|
+
end
|
|
104
|
+
|
|
69
105
|
def parse_backtrace_line(line)
|
|
70
106
|
match = line.match(/\A(.+?):(\d+)(?::in `(.*)')?\z/)
|
|
71
107
|
return [line, nil, nil] unless match
|
|
@@ -18,7 +18,11 @@ module Errorgap
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
initializer "errorgap.install_span_collector" do
|
|
21
|
-
|
|
21
|
+
# Unconditional: apps enable APM in config/initializers, which runs
|
|
22
|
+
# after railtie initializers, so the flag cannot be checked here. The
|
|
23
|
+
# subscribers no-op unless the middleware starts a per-request
|
|
24
|
+
# collection, which does check the flag.
|
|
25
|
+
SpanCollector.install
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
generators do
|
|
@@ -14,9 +14,16 @@ module Errorgap
|
|
|
14
14
|
SKIP_NAMES = %w[SCHEMA EXPLAIN CACHE].freeze
|
|
15
15
|
|
|
16
16
|
class << self
|
|
17
|
-
# Call once at boot (from Railtie)
|
|
17
|
+
# Call once at boot (from Railtie). Subscribers only record while a
|
|
18
|
+
# transaction is being collected (the middleware starts one per request
|
|
19
|
+
# when APM is enabled), so installing unconditionally is safe — and
|
|
20
|
+
# required, since app initializers that enable APM run after railtie
|
|
21
|
+
# initializers.
|
|
18
22
|
def install
|
|
19
23
|
return unless defined?(ActiveSupport::Notifications)
|
|
24
|
+
return if @installed
|
|
25
|
+
|
|
26
|
+
@installed = true
|
|
20
27
|
|
|
21
28
|
ActiveSupport::Notifications.subscribe("sql.active_record") do |*, payload|
|
|
22
29
|
next unless Thread.current[THREAD_KEY]
|
|
@@ -28,6 +35,17 @@ module Errorgap
|
|
|
28
35
|
|
|
29
36
|
store << Span.new(kind: "db", sql: sql, duration_ms: duration_ms.round(3))
|
|
30
37
|
end
|
|
38
|
+
|
|
39
|
+
# Rails reports view_runtime with database time already subtracted, so
|
|
40
|
+
# this does not double count the db spans above.
|
|
41
|
+
ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*, payload|
|
|
42
|
+
next unless Thread.current[THREAD_KEY]
|
|
43
|
+
|
|
44
|
+
view_ms = payload[:view_runtime]
|
|
45
|
+
next unless view_ms&.positive?
|
|
46
|
+
|
|
47
|
+
store << Span.new(kind: "view", duration_ms: view_ms.round(3))
|
|
48
|
+
end
|
|
31
49
|
end
|
|
32
50
|
|
|
33
51
|
def start
|
data/lib/errorgap/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: errorgap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Errorgap
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '5.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: activesupport
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '6.1'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '6.1'
|
|
41
55
|
description: Captures Ruby exceptions and sends them to a Errorgap server.
|
|
42
56
|
email:
|
|
43
57
|
- support@errorgap.com
|