traces 0.10.0 → 0.11.1

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: 47a1acf4edcb177776f172b8743e6beeae7161c6651819eab63a0206d15a7110
4
- data.tar.gz: 613f2bc265314167f2673a67a27cae51d5dd471479e9891da2de915611936846
3
+ metadata.gz: b14640339110cfee8aecc8766c250d7e3cc2a33be144080ed8b478287c0abc39
4
+ data.tar.gz: 34a6ec9d893ca1c278e4ec38127b15c2dc89b79ac11e1953bfb6cdfeeb8b6a27
5
5
  SHA512:
6
- metadata.gz: f74c9b5e55f2b231db24aaea42fb0fb1d5803b0e0da7f5332fc72158a5ddf5b59d1f2be8ad7fbb32f9c86890ffb517aa396eef32312b9758ef5bed35595a3cb4
7
- data.tar.gz: e54b6e4ab49a9a1c9fe9426e4d473eefe9ad43f6c53b8a562f0013c280df6ed27f675e2f77dc7693b77d63590809c627eb051f16a0ac8d941102e79c6045c480
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
 
@@ -21,23 +21,6 @@ module Traces
21
21
  end
22
22
  end
23
23
 
24
- module Deprecated
25
- def trace(...)
26
- warn "Traces::Provider.trace is deprecated. Please use Traces.trace instead."
27
- Traces.trace(...)
28
- end
29
-
30
- def trace_context
31
- warn "Traces::Provider.trace_context is deprecated. Please use Traces.trace_context instead."
32
- Traces.trace_context
33
- end
34
-
35
- def trace_context=(value)
36
- warn "Traces::Provider.trace_context= is deprecated. Please use Traces.trace_context= instead."
37
- Traces.trace_context = value
38
- end
39
- end
40
-
41
24
  private_constant :Singleton
42
25
 
43
26
  # Bail out if there is no backend configured.
@@ -45,10 +28,7 @@ module Traces
45
28
  # Extend the specified class in order to emit traces.
46
29
  def self.Provider(klass, &block)
47
30
  klass.extend(Singleton)
48
-
49
31
  provider = klass.traces_provider
50
- provider.prepend(Deprecated)
51
-
52
32
  klass.prepend(provider)
53
33
 
54
34
  provider.module_exec(&block) if block_given?
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Traces
7
- VERSION = "0.10.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.10.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -38,7 +38,7 @@ cert_chain:
38
38
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
39
39
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
40
40
  -----END CERTIFICATE-----
41
- date: 2023-06-19 00:00:00.000000000 Z
41
+ date: 2023-06-25 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: bake-test
@@ -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