appmap 0.34.5 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +0,0 @@
1
- 2.6.2
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'appmap/event'
4
-
5
- module AppMap
6
- module Rails
7
- module ActionHandler
8
- Context = Struct.new(:id, :start_time)
9
-
10
- module ContextKey
11
- def context_key
12
- "#{HTTPServerRequest.name}#call"
13
- end
14
- end
15
-
16
- class HTTPServerRequest
17
- include ContextKey
18
-
19
- class Call < AppMap::Event::MethodCall
20
- attr_accessor :payload
21
-
22
- def initialize(payload)
23
- super AppMap::Event.next_id_counter, :call, Thread.current.object_id
24
-
25
- self.payload = payload
26
- end
27
-
28
- def to_h
29
- super.tap do |h|
30
- h[:http_server_request] = {
31
- request_method: payload[:method],
32
- path_info: payload[:path]
33
- }
34
-
35
- params = payload[:params]
36
- h[:message] = params.keys.map do |key|
37
- val = params[key]
38
- {
39
- name: key,
40
- class: val.class.name,
41
- value: self.class.display_string(val),
42
- object_id: val.__id__
43
- }
44
- end
45
- end
46
- end
47
- end
48
-
49
- def call(_, started, finished, _, payload) # (name, started, finished, unique_id, payload)
50
- event = Call.new(payload)
51
- Thread.current[context_key] = Context.new(event.id, Time.now)
52
- AppMap.tracing.record_event(event)
53
- end
54
- end
55
-
56
- class HTTPServerResponse
57
- include ContextKey
58
-
59
- class Call < AppMap::Event::MethodReturnIgnoreValue
60
- attr_accessor :payload
61
-
62
- def initialize(payload, parent_id, elapsed)
63
- super AppMap::Event.next_id_counter, :return, Thread.current.object_id
64
-
65
- self.payload = payload
66
- self.parent_id = parent_id
67
- self.elapsed = elapsed
68
- end
69
-
70
- def to_h
71
- super.tap do |h|
72
- h[:http_server_response] = {
73
- status: payload[:status]
74
- }
75
- end
76
- end
77
- end
78
-
79
- def call(_, started, finished, _, payload) # (name, started, finished, unique_id, payload)
80
- return unless Thread.current[context_key]
81
-
82
- context = Thread.current[context_key]
83
- Thread.current[context_key] = nil
84
-
85
- event = Call.new(payload, context.id, Time.now - context.start_time)
86
- AppMap.tracing.record_event(event)
87
- end
88
- end
89
- end
90
- end
91
- end