traces 0.11.0 → 0.11.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: 58e40069d868f9f358b8fe3771a6ae011049742381fe0b147aac4e9f93068009
4
- data.tar.gz: 0a66121b3073ca5484c7f5972fdf04a3c2a93cb2d189f1c185cc5c593285a0d3
3
+ metadata.gz: b14640339110cfee8aecc8766c250d7e3cc2a33be144080ed8b478287c0abc39
4
+ data.tar.gz: 34a6ec9d893ca1c278e4ec38127b15c2dc89b79ac11e1953bfb6cdfeeb8b6a27
5
5
  SHA512:
6
- metadata.gz: ade58743017f6df8ee53bca6975b8754b3d313645624bbd42786753e128c6cfdfe92dec02727f9aff51905c1c65ef98d815ef4b992f13cc151165f1bcae61c67
7
- data.tar.gz: 494b4d3bfb20749a163f0ee95732370a3fb00bda154dab0c54604f8ac0e66c085877c45efc697d4fab398ec1dba2b10d527d1ab0edb74f07fa51866744e3d821
6
+ metadata.gz: 923a1c1e3a387aa487437cafbc2514d9db78f0afaee36cd50d3c06a21daf3ed4395d325c4fdf52ebda422dac3b1fe5e06fbdc2c1b078b58a4246719843ec812c
7
+ data.tar.gz: '09fd133d87ef78a7ecbe91bc8deaf8be3d1b6d211bb3eafbb5b6b20fa19834ead759290b288368e481aa587301374ae822faa6e82f894403df80d469a69c14ee'
checksums.yaml.gz.sig CHANGED
Binary file
@@ -17,16 +17,14 @@ module Traces
17
17
  module Capture
18
18
  # A span which validates tag assignment.
19
19
  class Span
20
- def initialize(context, instance, name, resource, attributes)
20
+ def initialize(context, name, resource, attributes)
21
21
  @context = context
22
- @instance = instance
23
22
  @name = name
24
23
  @resource = resource
25
24
  @attributes = attributes
26
25
  end
27
26
 
28
27
  attr :context
29
- attr :instance
30
28
  attr :name
31
29
  attr :resource
32
30
  attr :attributes
@@ -60,11 +58,11 @@ module Traces
60
58
  # Trace the given block of code and log the execution.
61
59
  # @parameter name [String] A useful name/annotation for the recorded span.
62
60
  # @parameter attributes [Hash] Metadata for the recorded span.
63
- def trace(name, resource: self, attributes: {}, &block)
61
+ def trace(name, resource: nil, attributes: {}, &block)
64
62
  context = Context.nested(Fiber.current.traces_backend_context)
65
63
  Fiber.current.traces_backend_context = context
66
64
 
67
- span = Span.new(context, self, name, resource, attributes)
65
+ span = Span.new(context, name, resource, attributes)
68
66
  Capture.spans << span
69
67
 
70
68
  yield span
@@ -18,9 +18,8 @@ module Traces
18
18
  module Console
19
19
  # A span which validates tag assignment.
20
20
  class Span
21
- def initialize(context, instance, name)
21
+ def initialize(context, name)
22
22
  @context = context
23
- @instance = instance
24
23
  @name = name
25
24
  end
26
25
 
@@ -38,16 +37,16 @@ module Traces
38
37
  # Trace the given block of code and log the execution.
39
38
  # @parameter name [String] A useful name/annotation for the recorded span.
40
39
  # @parameter attributes [Hash] Metadata for the recorded span.
41
- def trace(name, resource: self, attributes: {}, &block)
40
+ def trace(name, resource: nil, attributes: {}, &block)
42
41
  context = Context.nested(Fiber.current.traces_backend_context)
43
42
  Fiber.current.traces_backend_context = context
44
43
 
45
- ::Console.logger.info(resource, name, attributes)
44
+ ::Console.logger.info(resource || self, name, attributes)
46
45
 
47
46
  if block.arity.zero?
48
47
  yield
49
48
  else
50
- yield Span.new(context, self, name)
49
+ yield Span.new(context, name)
51
50
  end
52
51
  end
53
52
 
@@ -41,8 +41,9 @@ module Traces
41
41
  module Interface
42
42
  # Trace the given block of code and validate the interface usage.
43
43
  # @parameter name [String] A useful name/annotation for the recorded span.
44
+ # @parameter resource [String] The context in which the trace operation is occuring.
44
45
  # @parameter attributes [Hash] Metadata for the recorded span.
45
- def trace(name, resource: self.class.name, attributes: nil, &block)
46
+ def trace(name, resource: nil, attributes: nil, &block)
46
47
  unless block_given?
47
48
  raise ArgumentError, "No block given!"
48
49
  end
@@ -51,10 +52,8 @@ module Traces
51
52
  raise ArgumentError, "Invalid name (must be String): #{name.inspect}!"
52
53
  end
53
54
 
54
- if resource
55
- # It should be convertable:
56
- resource = resource.to_s
57
- end
55
+ # It should be convertable:
56
+ resource &&= resource.to_s
58
57
 
59
58
  context = Context.nested(Fiber.current.traces_backend_context)
60
59
 
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Traces
7
- VERSION = "0.11.0"
7
+ VERSION = "0.11.1"
8
8
  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.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.4.7
135
+ rubygems_version: 3.1.6
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Application instrumentation and tracing.
metadata.gz.sig CHANGED
Binary file