traces 0.4.1 → 0.5.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: '08840f587a19c2f5f8300c832a29409c5fa2e59c9607cc2c38586baa7db4b573'
4
- data.tar.gz: 42c1503ae596a3d8bdc8ece4bd839c09cdfa638236e4c64b1d4c42fcfcbe503e
3
+ metadata.gz: 284452f4bfc37587b942b74918b2807ad6c51ee09d5a93bd39d5eefa6ba66aa1
4
+ data.tar.gz: 7f2d42000701312aeeb5015b19f888d5ed5acb4d4c79322e894b584292c0aed1
5
5
  SHA512:
6
- metadata.gz: cf699c4c10ddca5ffc2a40b70498dee12df99cd801c5820a20eab9ef0aa1772871e09fb4d4019415b3be66f02396260613950c124229374401356bc9536e90a6
7
- data.tar.gz: 192db05a4272dd9420aa3341928289da2afd31a0c0181ec621f6bce0ba87ede6ac6575d3c17c6f2513cae94ce48c9216c5da1ddfe45ea6fdaa5f5a067aca985d
6
+ metadata.gz: b32ad9f2018cce91b418907c052b6f9c8b63b2fad08ccdc4e1abcf3dd623e0209ad3bed87b5dfdf4138c20110e0e1806caec1a1b62bbd064b2699498822e7e24
7
+ data.tar.gz: 41e7cd96fb1dcb21f727d2753854ba77c08378fee1ad459b9f696d2bdecc857841c7fda0f3cf2d3e3b03647bfbe6cd137a846cb1c6230a5cbcc1d149899ea031
checksums.yaml.gz.sig CHANGED
Binary file
@@ -55,11 +55,11 @@ module Traces
55
55
  # Trace the given block of code and log the execution.
56
56
  # @parameter name [String] A useful name/annotation for the recorded span.
57
57
  # @parameter attributes [Hash] Metadata for the recorded span.
58
- def trace(name, attributes: {}, &block)
58
+ def trace(name, resource: self, attributes: {}, &block)
59
59
  context = Context.nested(Fiber.current.traces_backend_context)
60
60
  Fiber.current.traces_backend_context = context
61
61
 
62
- ::Console.logger.info(self, name, attributes)
62
+ ::Console.logger.info(resource, name, attributes)
63
63
 
64
64
  if block.arity.zero?
65
65
  yield
@@ -44,11 +44,11 @@ module Traces
44
44
  # @parameter value [Object] The metadata value. Should be coercable to a string.
45
45
  def []= key, value
46
46
  unless key.is_a?(String)
47
- raise ArgumentError, "Invalid name!"
47
+ raise ArgumentError, "Invalid name (must be String): #{key.inspect}!"
48
48
  end
49
49
 
50
50
  unless String(value)
51
- raise ArgumentError, "Invalid value!"
51
+ raise ArgumentError, "Invalid value (must be String): #{value.inspect}!"
52
52
  end
53
53
  end
54
54
  end
@@ -57,9 +57,14 @@ module Traces
57
57
  # Trace the given block of code and validate the interface usage.
58
58
  # @parameter name [String] A useful name/annotation for the recorded span.
59
59
  # @parameter attributes [Hash] Metadata for the recorded span.
60
- def trace(name, attributes: nil, &block)
60
+ def trace(name, resource: self.class.name, attributes: nil, &block)
61
61
  unless name.is_a?(String)
62
- raise ArgumentError, "Invalid name!"
62
+ raise ArgumentError, "Invalid name (must be String): #{name.inspect}!"
63
+ end
64
+
65
+ if resource
66
+ # It should be convertable:
67
+ resource = resource.to_s
63
68
  end
64
69
 
65
70
  context = Context.nested(Fiber.current.traces_backend_context)
@@ -23,6 +23,11 @@
23
23
  require_relative 'backend'
24
24
 
25
25
  module Traces
26
+ # @returns [Boolean] Whether there is an active backend.
27
+ def self.enabled?
28
+ self.const_defined?(:Backend)
29
+ end
30
+
26
31
  # A module which contains tracing specific wrappers.
27
32
  module Provider
28
33
  def traces_provider
@@ -31,7 +36,7 @@ module Traces
31
36
  end
32
37
 
33
38
  # Bail out if there is no backend configured.
34
- if self.const_defined?(:Backend)
39
+ if self.enabled?
35
40
  # Extend the specified class in order to emit traces.
36
41
  def self.Provider(klass, &block)
37
42
  klass.extend(Provider)
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Traces
24
- VERSION = "0.4.1"
24
+ VERSION = "0.5.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.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -36,7 +36,7 @@ cert_chain:
36
36
  RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
37
37
  HiLJ8VOFx6w=
38
38
  -----END CERTIFICATE-----
39
- date: 2021-10-18 00:00:00.000000000 Z
39
+ date: 2022-01-27 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
metadata.gz.sig CHANGED
Binary file