plain_apm 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plain_apm/event_attributes.rb +32 -22
- data/lib/plain_apm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41e2fd7c72868351a09c83a13a22df9e9718e00cbb1950c27e7ce129cf24a826
|
4
|
+
data.tar.gz: 2f658463e3ee8f8195142a2b456b6f5c535efac868ada116f766ef92db5ab714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 139c55ba03f6982640310ba59122fab53c6fb9c871e409c304b5d5ebd50e44c34af8db691195acb4dd7b4b43087092e7b9f1fe052f8d7aa299b863d4b4301c8e
|
7
|
+
data.tar.gz: da0cd391b91b3660ef48fc8587e26562d1caf908526b2af86e9c42e2cff945940c779b6b115763bacf8f105e33e7422e4a27d403c788b8d44be9d33d909e1460
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module PlainApm
|
2
2
|
module EventAttributes
|
3
|
-
|
3
|
+
SOURCES_WITH_EXTRA_ATTRIBUTES = %w[
|
4
4
|
action_controller
|
5
5
|
action_mailer
|
6
6
|
active_job
|
@@ -23,8 +23,7 @@ module PlainApm
|
|
23
23
|
"name" => tool
|
24
24
|
}
|
25
25
|
|
26
|
-
attrs.merge!(
|
27
|
-
attrs.merge!(host_attributes) if add_host_attributes?(source)
|
26
|
+
attrs.merge!(trace_attributes(source))
|
28
27
|
|
29
28
|
[tool, attrs]
|
30
29
|
end
|
@@ -41,7 +40,7 @@ module PlainApm
|
|
41
40
|
}
|
42
41
|
|
43
42
|
if context[:env]
|
44
|
-
attrs["params"] = env["action_dispatch.request.parameters"]
|
43
|
+
attrs["params"] = context[:env]["action_dispatch.request.parameters"]
|
45
44
|
end
|
46
45
|
|
47
46
|
if context[:job]&.is_a?(ActiveJob::Base)
|
@@ -57,8 +56,7 @@ module PlainApm
|
|
57
56
|
})
|
58
57
|
end
|
59
58
|
|
60
|
-
attrs.merge!(
|
61
|
-
attrs.merge!(host_attributes) if add_host_attributes?(source)
|
59
|
+
attrs.merge!(trace_attributes(source))
|
62
60
|
|
63
61
|
[source, attrs]
|
64
62
|
end
|
@@ -72,30 +70,33 @@ module PlainApm
|
|
72
70
|
"name" => name,
|
73
71
|
"allocations" => event.allocations,
|
74
72
|
"thread_allocations" => event.thread_allocations,
|
75
|
-
"
|
76
|
-
"
|
73
|
+
"event_time" => event.time,
|
74
|
+
"duration" => event.duration
|
77
75
|
}
|
78
76
|
|
79
77
|
attrs["source_location"] = loc if !loc.nil?
|
80
|
-
|
81
|
-
attrs.merge!(
|
78
|
+
|
79
|
+
attrs.merge!(trace_attributes(source))
|
82
80
|
|
83
81
|
[name, attrs]
|
84
82
|
end
|
85
83
|
|
86
84
|
private
|
87
85
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# It can also carry user inserted app data.
|
94
|
-
if defined?(PlainApm::Extensions::Context)
|
95
|
-
PlainApm::Extensions::Context.current
|
86
|
+
def trace_attributes(source)
|
87
|
+
attrs = agent_attributes
|
88
|
+
|
89
|
+
if add_extra_attributes?(source)
|
90
|
+
attrs.merge!(process_attributes, context_attributes)
|
96
91
|
else
|
97
|
-
|
92
|
+
attrs.merge!(context_attributes.slice(:trace_id))
|
98
93
|
end
|
94
|
+
|
95
|
+
attrs
|
96
|
+
end
|
97
|
+
|
98
|
+
def add_extra_attributes?(source)
|
99
|
+
SOURCES_WITH_EXTRA_ATTRIBUTES.include?(source)
|
99
100
|
end
|
100
101
|
|
101
102
|
def agent_attributes
|
@@ -104,7 +105,7 @@ module PlainApm
|
|
104
105
|
}
|
105
106
|
end
|
106
107
|
|
107
|
-
def
|
108
|
+
def process_attributes
|
108
109
|
{
|
109
110
|
"collected_at" => Time.now.iso8601(9),
|
110
111
|
"hostname" => Socket.gethostname,
|
@@ -113,8 +114,17 @@ module PlainApm
|
|
113
114
|
}
|
114
115
|
end
|
115
116
|
|
116
|
-
def
|
117
|
-
|
117
|
+
def context_attributes
|
118
|
+
##
|
119
|
+
# Context contains the trace ID (which comes from either
|
120
|
+
# HTTP_X_REQUEST_ID header, the deserialized job,
|
121
|
+
# or is generated by the trace_id middleware).
|
122
|
+
# It can also carry user inserted app data.
|
123
|
+
if defined?(PlainApm::Extensions::Context)
|
124
|
+
PlainApm::Extensions::Context.current
|
125
|
+
else
|
126
|
+
{}
|
127
|
+
end
|
118
128
|
end
|
119
129
|
|
120
130
|
def source_location
|
data/lib/plain_apm/version.rb
CHANGED