plain_apm 0.8.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/object_tracing/bug18464.rb +3 -0
- data/lib/plain_apm/agent.rb +0 -1
- data/lib/plain_apm/deploy_tracking.rb +32 -0
- data/lib/plain_apm/event_attributes.rb +8 -19
- data/lib/plain_apm/hooks/active_record.rb +1 -1
- data/lib/plain_apm/version.rb +1 -1
- data/lib/plain_apm.rb +1 -3
- metadata +3 -3
- data/lib/plain_apm/hooks/deploy.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86351e7cfbfef5b9e4916152f8f7638f3d25ec63eea2228552a7ed18a30af210
|
4
|
+
data.tar.gz: 3e2054248c4affa80a1a563fb340310fbeeac0d75caf9fc77dadcf1c14a9f975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 594f73225b32f2b172251c848b176c1c8fc1370a45d0804bd3741be82eff94cb26fc5526d290127591c274ee886723782890bc1be095b00b158f85331c366f2c
|
7
|
+
data.tar.gz: 6435cb48e14b99c36b1457e28eb343a65618cbda9a0a014e15031b3e08b17aa6da0e15dd3cffa5808df4b44d5db19b180c102103320c231b95d1da1a39bf14c2
|
data/lib/plain_apm/agent.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module PlainApm
|
2
|
+
class DeployTracking
|
3
|
+
class << self
|
4
|
+
def revision
|
5
|
+
git_revision || hg_revision || heroku_revision
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def git_revision
|
11
|
+
return unless File.exist?(".git")
|
12
|
+
rev = `git rev-parse --short=8 HEAD`.strip
|
13
|
+
rev if !rev.empty?
|
14
|
+
rescue Error::ENOENT # No git installed
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def heroku_revision
|
19
|
+
rev = ENV["HEROKU_SLUG_COMMIT"].to_s[0..8]
|
20
|
+
rev if !rev.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def hg_revision
|
24
|
+
return unless File.exist?(".hg")
|
25
|
+
rev = `hg log -l 1 -r . -T '{node}'`.strip
|
26
|
+
rev if !rev.empty?
|
27
|
+
rescue Error::ENOENT # No mercurial installed
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -7,7 +7,6 @@ module PlainApm
|
|
7
7
|
action_controller
|
8
8
|
action_mailer
|
9
9
|
active_job
|
10
|
-
deploy
|
11
10
|
exception
|
12
11
|
].freeze
|
13
12
|
|
@@ -17,20 +16,6 @@ module PlainApm
|
|
17
16
|
"ActionController::RoutingError" # Rails unmapped route, raised before the request hits the app.
|
18
17
|
].freeze
|
19
18
|
|
20
|
-
def attributes_from_deploy(tool, revision)
|
21
|
-
source = "deploy"
|
22
|
-
|
23
|
-
attrs = {
|
24
|
-
"source" => source,
|
25
|
-
"revision" => revision,
|
26
|
-
"name" => tool
|
27
|
-
}
|
28
|
-
|
29
|
-
attrs.merge!(trace_attributes(source))
|
30
|
-
|
31
|
-
[tool, attrs]
|
32
|
-
end
|
33
|
-
|
34
19
|
def attributes_from_exception(e, context, error_source)
|
35
20
|
source = "exception"
|
36
21
|
|
@@ -98,16 +83,20 @@ module PlainApm
|
|
98
83
|
{
|
99
84
|
"thread_id" => Thread.current.object_id,
|
100
85
|
"collected_at" => Time.now.iso8601(9),
|
86
|
+
# TODO: There is a perf cost in Rubies until 3.3, so it might be a good
|
87
|
+
# idea to cache this. See https://bugs.ruby-lang.org/issues/19443 for
|
88
|
+
# the feature.
|
89
|
+
"pid" => Process.pid,
|
101
90
|
"version" => PlainApm::VERSION
|
102
91
|
}.merge(
|
103
|
-
|
92
|
+
cached_attributes
|
104
93
|
)
|
105
94
|
end
|
106
95
|
|
107
|
-
def
|
108
|
-
@
|
96
|
+
def cached_attributes
|
97
|
+
@cached_attributes ||= {
|
109
98
|
"hostname" => Socket.gethostname,
|
110
|
-
"
|
99
|
+
"revision" => PlainApm::DeployTracking.revision
|
111
100
|
}
|
112
101
|
end
|
113
102
|
|
@@ -22,7 +22,7 @@ module PlainApm
|
|
22
22
|
|
23
23
|
case name
|
24
24
|
when "sql"
|
25
|
-
base.merge({"sql" => payload[:sql]})
|
25
|
+
base.merge({"sql" => payload[:sql], "sql_name" => payload[:name]})
|
26
26
|
when "instantiation"
|
27
27
|
base.merge({"class_name" => payload[:class_name], "record_count" => payload[:record_count]})
|
28
28
|
end
|
data/lib/plain_apm/version.rb
CHANGED
data/lib/plain_apm.rb
CHANGED
@@ -4,13 +4,11 @@ require_relative "plain_apm/version"
|
|
4
4
|
require_relative "plain_apm/transport"
|
5
5
|
require_relative "plain_apm/config"
|
6
6
|
require_relative "plain_apm/agent"
|
7
|
+
require_relative "plain_apm/deploy_tracking"
|
7
8
|
require_relative "plain_apm/event_attributes"
|
8
9
|
|
9
10
|
require "object_tracing"
|
10
11
|
|
11
|
-
# Deployment reporting.
|
12
|
-
require_relative "plain_apm/hooks/deploy"
|
13
|
-
|
14
12
|
# Rails instrumentation. The hooks won't install unless
|
15
13
|
# ActiveSupport::Notifications is loaded.
|
16
14
|
require_relative "plain_apm/hooks/active_support_subscriber"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plain_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PlainAPM Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/plain_apm.rb
|
100
100
|
- lib/plain_apm/agent.rb
|
101
101
|
- lib/plain_apm/config.rb
|
102
|
+
- lib/plain_apm/deploy_tracking.rb
|
102
103
|
- lib/plain_apm/event_attributes.rb
|
103
104
|
- lib/plain_apm/extensions/context.rb
|
104
105
|
- lib/plain_apm/extensions/context/LICENSE.txt
|
@@ -119,7 +120,6 @@ files:
|
|
119
120
|
- lib/plain_apm/hooks/active_record.rb
|
120
121
|
- lib/plain_apm/hooks/active_support.rb
|
121
122
|
- lib/plain_apm/hooks/active_support_subscriber.rb
|
122
|
-
- lib/plain_apm/hooks/deploy.rb
|
123
123
|
- lib/plain_apm/hooks/error_reporter.rb
|
124
124
|
- lib/plain_apm/hooks/manual.rb
|
125
125
|
- lib/plain_apm/transport.rb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module PlainApm
|
2
|
-
##
|
3
|
-
# Tracks current revision of the app.
|
4
|
-
#
|
5
|
-
# This enables per-deploy metrics segmentation and checking
|
6
|
-
# for performance regressions.
|
7
|
-
module Hooks
|
8
|
-
class Deploy
|
9
|
-
include EventAttributes
|
10
|
-
|
11
|
-
##
|
12
|
-
# Collect once, immediately on install.
|
13
|
-
def install
|
14
|
-
collect
|
15
|
-
end
|
16
|
-
|
17
|
-
def uninstall
|
18
|
-
# NOOP
|
19
|
-
end
|
20
|
-
|
21
|
-
def collect
|
22
|
-
result = git_revision || hg_revision || return
|
23
|
-
|
24
|
-
_, attrs = attributes_from_deploy(*result)
|
25
|
-
|
26
|
-
::PlainApm.agent.collect(attrs)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
# TODO: other deploy mechanisms
|
32
|
-
#
|
33
|
-
# Also, we might not be in the app root.
|
34
|
-
def git_revision
|
35
|
-
return unless File.exist?(".git")
|
36
|
-
|
37
|
-
rev = `git rev-parse --short=8 HEAD`.strip
|
38
|
-
|
39
|
-
return if rev.empty?
|
40
|
-
|
41
|
-
["git", rev]
|
42
|
-
rescue Error::ENOENT # No git installed
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
def hg_revision
|
47
|
-
return unless File.exist?(".hg")
|
48
|
-
|
49
|
-
rev = `hg log -l 1 -r . -T '{node}'`.strip
|
50
|
-
|
51
|
-
return if rev.empty?
|
52
|
-
|
53
|
-
["hg", rev]
|
54
|
-
rescue Error::ENOENT # No mercurial installed
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|