plain_apm 0.7.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b4d2bddabd031b2b17d2edcf27e32f323c217b2331c469072e95d0afeb58ec7
4
- data.tar.gz: a892bbd62da4a10b074046c39326576355d591bf02982f9d336a97d887f99bc6
3
+ metadata.gz: 41e2fd7c72868351a09c83a13a22df9e9718e00cbb1950c27e7ce129cf24a826
4
+ data.tar.gz: 2f658463e3ee8f8195142a2b456b6f5c535efac868ada116f766ef92db5ab714
5
5
  SHA512:
6
- metadata.gz: b523dbaea426bbb9f2e4c2808efb4937ebf5c842361d07c9a0ae6a23bef03fe8bef0a71815710b4c55a7f8a1eeaea01e8b0fbe01bb3ed9af58743a31aa09c0aa
7
- data.tar.gz: 93c110b5e728cd6e934cbb25e56bd5345e3cc45dc1776922ca39a5de902e19a996fcc2aa7de0c749b231e8faf137b16be49f1d9389bec1735986223f18bc6798
6
+ metadata.gz: 139c55ba03f6982640310ba59122fab53c6fb9c871e409c304b5d5ebd50e44c34af8db691195acb4dd7b4b43087092e7b9f1fe052f8d7aa299b863d4b4301c8e
7
+ data.tar.gz: da0cd391b91b3660ef48fc8587e26562d1caf908526b2af86e9c42e2cff945940c779b6b115763bacf8f105e33e7422e4a27d403c788b8d44be9d33d909e1460
@@ -1,6 +1,6 @@
1
1
  module PlainApm
2
2
  module EventAttributes
3
- SOURCES_WITH_HOST_ATTRIBUTES = %w[
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!(agent_attributes)
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!(context_attributes, agent_attributes)
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
- "started_at" => event.time,
76
- "finished_at" => event.end
73
+ "event_time" => event.time,
74
+ "duration" => event.duration
77
75
  }
78
76
 
79
77
  attrs["source_location"] = loc if !loc.nil?
80
- attrs.merge!(context_attributes, agent_attributes)
81
- attrs.merge!(host_attributes) if add_host_attributes?(source)
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 context_attributes
89
- ##
90
- # Context contains the trace ID (which comes from either
91
- # HTTP_X_REQUEST_ID header, the deserialized job,
92
- # or is generated by the trace_id middleware).
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 host_attributes
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 add_host_attributes?(source)
117
- SOURCES_WITH_HOST_ATTRIBUTES.include?(source)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plain_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PlainAPM Team