traces 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/traces/backend/console.rb +30 -30
- data/lib/traces/backend/test.rb +33 -32
- data/lib/traces/provider.rb +1 -1
- data/lib/traces/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 389518e7025f63c5c99a5599000e12191ca8634b38f8d05ba727fe22b0fe3aa5
|
4
|
+
data.tar.gz: f8648d7990686c3abbd955f4b45869cf67c88e2b644da156e914bc2cac92087d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3d9834ff556a722bb7a82dae4c824c94888af648a70954ab2a7c720e26e622ce826262838016169388734b8f9beaa6c2b74cd0a4ea9a669295fce70ae41c61c
|
7
|
+
data.tar.gz: 4fd9a0b83fb293e04fec5ff91431ee55ac2a6fcb86609288795d4d22486cf51fdcb16ec21610487b6e99d9b5662ab30d0999360ce5aaf430408b75a56ae077b8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -31,6 +31,7 @@ end
|
|
31
31
|
|
32
32
|
module Traces
|
33
33
|
module Backend
|
34
|
+
# A backend which logs all spans to the console logger output.
|
34
35
|
module Console
|
35
36
|
# A span which validates tag assignment.
|
36
37
|
class Span
|
@@ -50,41 +51,40 @@ module Traces
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
module Interface
|
55
|
+
# Trace the given block of code and log the execution.
|
56
|
+
# @parameter name [String] A useful name/annotation for the recorded span.
|
57
|
+
# @parameter attributes [Hash] Metadata for the recorded span.
|
58
|
+
def trace(name, attributes: {}, &block)
|
59
|
+
context = Context.nested(Fiber.current.traces_backend_context)
|
60
|
+
Fiber.current.traces_backend_context = context
|
61
|
+
|
62
|
+
::Console.logger.info(self, name, attributes)
|
63
|
+
|
64
|
+
if block.arity.zero?
|
65
|
+
yield
|
66
|
+
else
|
67
|
+
yield Span.new(context, self, name)
|
68
|
+
end
|
69
|
+
end
|
63
70
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
yield Span.new(context, self, name)
|
71
|
+
# Assign a trace context to the current execution scope.
|
72
|
+
def trace_context= context
|
73
|
+
Fiber.current.traces_backend_context = context
|
68
74
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
def trace_context(span = nil)
|
79
|
-
if span
|
80
|
-
span.context
|
81
|
-
else
|
82
|
-
Fiber.current.traces_backend_context
|
75
|
+
|
76
|
+
# Get a trace context from the current execution scope.
|
77
|
+
# @parameter span [Span] An optional span from which to extract the context.
|
78
|
+
def trace_context(span = nil)
|
79
|
+
if span
|
80
|
+
span.context
|
81
|
+
else
|
82
|
+
Fiber.current.traces_backend_context
|
83
|
+
end
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
|
88
|
-
self.include(Console)
|
88
|
+
Interface = Console::Interface
|
89
89
|
end
|
90
90
|
end
|
data/lib/traces/backend/test.rb
CHANGED
@@ -29,6 +29,7 @@ end
|
|
29
29
|
|
30
30
|
module Traces
|
31
31
|
module Backend
|
32
|
+
# A backend which validates interface usage.
|
32
33
|
module Test
|
33
34
|
# A span which validates tag assignment.
|
34
35
|
class Span
|
@@ -52,43 +53,43 @@ module Traces
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
module Interface
|
57
|
+
# Trace the given block of code and validate the interface usage.
|
58
|
+
# @parameter name [String] A useful name/annotation for the recorded span.
|
59
|
+
# @parameter attributes [Hash] Metadata for the recorded span.
|
60
|
+
def trace(name, attributes: nil, &block)
|
61
|
+
unless name.is_a?(String)
|
62
|
+
raise ArgumentError, "Invalid name!"
|
63
|
+
end
|
64
|
+
|
65
|
+
context = Context.nested(Fiber.current.traces_backend_context)
|
66
|
+
Fiber.current.traces_backend_context = context
|
67
|
+
|
68
|
+
if block.arity.zero?
|
69
|
+
yield
|
70
|
+
else
|
71
|
+
span = Span.new(context)
|
72
|
+
yield span
|
73
|
+
end
|
63
74
|
end
|
64
75
|
|
65
|
-
context
|
66
|
-
|
67
|
-
|
68
|
-
if block.arity.zero?
|
69
|
-
yield
|
70
|
-
else
|
71
|
-
span = Span.new(context)
|
72
|
-
yield span
|
76
|
+
# Assign a trace context to the current execution scope.
|
77
|
+
def trace_context= context
|
78
|
+
Fiber.current.traces_backend_context = context
|
73
79
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def trace_context(span = nil)
|
84
|
-
if span
|
85
|
-
span.context
|
86
|
-
else
|
87
|
-
Fiber.current.traces_backend_context
|
80
|
+
|
81
|
+
# Get a trace context from the current execution scope.
|
82
|
+
# @parameter span [Span] An optional span from which to extract the context.
|
83
|
+
def trace_context(span = nil)
|
84
|
+
if span
|
85
|
+
span.context
|
86
|
+
else
|
87
|
+
Fiber.current.traces_backend_context
|
88
|
+
end
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
|
-
|
93
|
+
Interface = Test::Interface
|
93
94
|
end
|
94
|
-
end
|
95
|
+
end
|
data/lib/traces/provider.rb
CHANGED
data/lib/traces/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|