trace 0.4.1 → 0.4.2

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: 5db118b222eae45a6a0f70e000424e089fb3f0877cb5b882987553864fbde992
4
- data.tar.gz: 88ffc50c9238056489d7bb9b79630819b10a9cdafb94454e405f65b13d5f9dd3
3
+ metadata.gz: fb527822327842c5c6b73e6d3b7b1f0aa34eec02f0c2e359bd518ed0244b3661
4
+ data.tar.gz: 4b3b5b346e92d79f869b02ab044bdd40829d7c66e0f912ed6ec7ee86e655114a
5
5
  SHA512:
6
- metadata.gz: 07e8dfa47865b00957d3acb739e63f2a1448e1f238448453261dd4714172bb239be9d015000fa82125f2f364e33155eced99278acec0bca91fc67bc770550a18
7
- data.tar.gz: fd9042d17282c8c785f137b58b9a68028bdbc9925d7fc7ee991ad71a3f2d95d97b9178b8c66c846c584eb4771961ea7bc62ae83a89088f71126f59fd511439ae
6
+ metadata.gz: '086f6ae2a662b67e12081ca4e6c74ed885bafdd6c74be44ea70c21c7d75bae70a6879ece9a63395643644b54c7a54c61cf53a56b23a77dc574dfdf28b516db53'
7
+ data.tar.gz: 26aea73d38d0bed8bc0fb7e6775e22dbb23d0a2a087e7a9faa02e99a47ea36ea8c41bcca137385f3f209fadcfa6f0ea344ca479a1706b97d03f0af3b8572b026
@@ -20,7 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require 'console'
23
+ require 'ddtrace'
24
24
 
25
25
  module Trace
26
26
  module Backend
@@ -28,14 +28,14 @@ module Trace
28
28
 
29
29
  def trace(name, parent = nil, **attributes, &block)
30
30
  if parent
31
- parent = Datadog::Context.new(
31
+ parent = ::Datadog::Context.new(
32
32
  trace_id: parent.trace_id,
33
33
  span_id: parent.span_id,
34
34
  sampled: parent.sampled?,
35
35
  )
36
36
  end
37
37
 
38
- Datadog.tracer.trace(name, child_of: parent, tags: attributes) do |span|
38
+ ::Datadog.tracer.trace(name, child_of: parent, tags: attributes) do |span|
39
39
  begin
40
40
  if block.arity.zero?
41
41
  yield
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ module Trace
24
+ def self.require_backend(env = ENV)
25
+ if backend = env['TRACE_BACKEND']
26
+ begin
27
+ path = File.join('backend', backend)
28
+ require_relative(path)
29
+ rescue LoadError
30
+ require(backend)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ Trace.require_backend
@@ -20,6 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
+ require_relative 'backend'
24
+
23
25
  module Trace
24
26
  module Provider
25
27
  def trace_provider
@@ -42,7 +44,7 @@ module Trace
42
44
  end
43
45
  else
44
46
  def self.Provider(klass, &block)
45
- # No-op.
47
+ # Tracing disabled.
46
48
  end
47
49
  end
48
50
  end
data/lib/trace/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Trace
24
- VERSION = "0.4.1"
24
+ VERSION = "0.4.2"
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/trace.rb
34
+ - lib/trace/backend.rb
34
35
  - lib/trace/backend/console.rb
35
36
  - lib/trace/backend/datadog.rb
36
37
  - lib/trace/backend/open_telemetry.rb