stack_trace 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +19 -23
- data/LICENSE.txt +1 -1
- data/README.md +15 -191
- data/Rakefile +8 -1
- data/ext/stack_trace/configuration.c +23 -0
- data/ext/stack_trace/configuration.h +6 -0
- data/ext/stack_trace/current_trace.c +43 -0
- data/ext/stack_trace/current_trace.h +7 -0
- data/ext/stack_trace/debug.c +43 -0
- data/ext/stack_trace/debug.h +37 -0
- data/ext/stack_trace/event_producer.c +65 -0
- data/ext/stack_trace/event_producer.h +3 -0
- data/ext/stack_trace/event_store.c +109 -0
- data/ext/stack_trace/event_store.h +5 -0
- data/ext/stack_trace/extconf.rb +7 -0
- data/ext/stack_trace/sidecar.c +77 -0
- data/ext/stack_trace/sidecar.h +1 -0
- data/ext/stack_trace/span.c +106 -0
- data/ext/stack_trace/span.h +9 -0
- data/ext/stack_trace/stack_trace.c +54 -0
- data/ext/stack_trace/trace.c +132 -0
- data/ext/stack_trace/trace.h +8 -0
- data/ext/stack_trace/types/event.h +31 -0
- data/ext/stack_trace/types/span.h +22 -0
- data/ext/stack_trace/types/trace.h +15 -0
- data/ext/stack_trace/utils.c +8 -0
- data/ext/stack_trace/utils.h +1 -0
- data/lib/stack_trace/argument_extractor.rb +22 -0
- data/lib/stack_trace/configuration.rb +2 -57
- data/lib/stack_trace/patch/class.rb +7 -0
- data/lib/stack_trace/patch/false_class.rb +7 -0
- data/lib/stack_trace/patch/nil_class.rb +7 -0
- data/lib/stack_trace/patch/numeric.rb +7 -0
- data/lib/stack_trace/patch/object.rb +7 -0
- data/lib/stack_trace/patch/symbol.rb +7 -0
- data/lib/stack_trace/patch/true_class.rb +7 -0
- data/lib/stack_trace/version.rb +3 -1
- data/lib/stack_trace.rb +30 -34
- data/stack_trace.gemspec +22 -20
- metadata +45 -77
- data/.gitignore +0 -11
- data/.travis.yml +0 -7
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/stack_trace/integration/rspec.rb +0 -79
- data/lib/stack_trace/module_extensions.rb +0 -13
- data/lib/stack_trace/setup.rb +0 -62
- data/lib/stack_trace/span.rb +0 -94
- data/lib/stack_trace/trace.rb +0 -83
data/lib/stack_trace/trace.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
|
3
|
-
require "securerandom"
|
4
|
-
|
5
|
-
module StackTrace
|
6
|
-
class Trace
|
7
|
-
TRACE_START_EVENTS = %i(call c_call).freeze
|
8
|
-
TRACE_END_EVENTS = %i(return c_return).freeze
|
9
|
-
TRACE_RAISE_EVENT = :raise
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def track(trace_point)
|
13
|
-
current.add(trace_point) if trackable?(trace_point)
|
14
|
-
end
|
15
|
-
|
16
|
-
def start
|
17
|
-
@current = new
|
18
|
-
end
|
19
|
-
|
20
|
-
def current
|
21
|
-
@current ||= new
|
22
|
-
end
|
23
|
-
|
24
|
-
def as_json
|
25
|
-
current.as_json
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def trackable?(trace_point)
|
31
|
-
trace_point.defined_class&.trace_method?(trace_point.method_id)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
attr_reader :uuid, :spans
|
36
|
-
|
37
|
-
def initialize
|
38
|
-
@uuid = SecureRandom.uuid
|
39
|
-
@spans = []
|
40
|
-
end
|
41
|
-
|
42
|
-
def add(trace_point)
|
43
|
-
case trace_point.event
|
44
|
-
when *TRACE_START_EVENTS
|
45
|
-
create_new_span(trace_point)
|
46
|
-
when *TRACE_END_EVENTS
|
47
|
-
close_current_span(trace_point)
|
48
|
-
else
|
49
|
-
apply_exception_to_current_span(trace_point)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def as_json
|
54
|
-
{
|
55
|
-
uuid: uuid,
|
56
|
-
spans: spans.map(&:as_json)
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
def <<(span)
|
61
|
-
spans << span
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def create_new_span(trace_point)
|
67
|
-
span = Span.start_from(trace_point, container)
|
68
|
-
container << (@active_span = span)
|
69
|
-
end
|
70
|
-
|
71
|
-
def close_current_span(trace_point)
|
72
|
-
@active_span = @active_span&.close(trace_point)
|
73
|
-
end
|
74
|
-
|
75
|
-
def apply_exception_to_current_span(trace_point)
|
76
|
-
@active_span.exception = trace_point.raised_exception
|
77
|
-
end
|
78
|
-
|
79
|
-
def container
|
80
|
-
@active_span || self
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|