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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17d36e478e92a07d18262c627d9c2986004a2fe81985fd80721da6adf4d2c282
4
- data.tar.gz: 44c0dd539bcda08a88d69478c56eeaa7eaa52f34b4bc2941510b7996d4b2bf28
3
+ metadata.gz: 389518e7025f63c5c99a5599000e12191ca8634b38f8d05ba727fe22b0fe3aa5
4
+ data.tar.gz: f8648d7990686c3abbd955f4b45869cf67c88e2b644da156e914bc2cac92087d
5
5
  SHA512:
6
- metadata.gz: 5684c47004efb75753fed8f3c7d980cd72d6646c8eaa2eafc2fc001d25a96c80c7c3ad590d01fb7859544e8567c4318a29892cba70ec2fcaeefd81219ce6f34d
7
- data.tar.gz: 8c8f7abd2de878319c61b8ffa491d8946f9fc8b782aad65911520948bc1efe4d545e10829fe0ee63b465443358ad858430429e485d3378238cd6e70e70464d06
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
- private
54
-
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)
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
- if block.arity.zero?
65
- yield
66
- else
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
- end
70
-
71
- # Assign a trace context to the current execution scope.
72
- def trace_context= context
73
- Fiber.current.traces_backend_context = context
74
- end
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
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
- # This is the default.
88
- self.include(Console)
88
+ Interface = Console::Interface
89
89
  end
90
90
  end
@@ -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
- private
56
-
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!"
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 = 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
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
- end
75
-
76
- # Assign a trace context to the current execution scope.
77
- def trace_context= context
78
- Fiber.current.traces_backend_context = context
79
- end
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
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
- self.include(Test)
93
+ Interface = Test::Interface
93
94
  end
94
- end
95
+ end
@@ -37,7 +37,7 @@ module Traces
37
37
  klass.extend(Provider)
38
38
 
39
39
  provider = klass.traces_provider
40
- provider.prepend(Backend)
40
+ provider.prepend(Backend::Interface)
41
41
 
42
42
  klass.prepend(provider)
43
43
 
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Traces
24
- VERSION = "0.3.2"
24
+ VERSION = "0.4.0"
25
25
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file