traces 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -0
- data/lib/traces/backend/console.rb +3 -3
- data/lib/traces/backend/test.rb +4 -0
- data/lib/traces/backend.rb +1 -2
- data/lib/traces/context.rb +1 -1
- data/lib/traces/provider.rb +3 -4
- data/lib/traces/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +33 -7
- metadata.gz.sig +2 -0
- data/lib/traces/backend/datadog.rb +0 -70
- data/lib/traces/backend/open_telemetry.rb +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8d74b7b8712105a772f7d9cde7108dc2218137570ba71f11632cd539808a740
|
4
|
+
data.tar.gz: 4a63fcc5efe56b48a074a6e66587bab35395daf9a0b20864e59b4987db9530e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2291cae8c41890078266aaedbd14f760e94b18d76e55b2b32c792e6188770cee4565e96972711bf0cc83f6ddaacd1700d767eca56584423e7c55ee322ce295c
|
7
|
+
data.tar.gz: 33b0e8f87d219f8c4122d356b2ee1188d6df6f89aea9f8583757bf1cf288c4ed393cd2bda96804c84fb7812014d545d872923cb7bfff22a8e7152f87aeb2b8aa
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
^�d>-�E�7��|h#�ʸUn��Iھ�*@�tǵ@���X#ͣ�AX�!d�O��=���9�U1�� �'jĹ��/
|
2
|
+
Lk6+��%��YX@�����ݙ�M�:����&��0��S�[���3"������R�Sj�����%���.#��NQ�]P<&��Uv���_�rc}h���O��;5���j�4�m>t���zr�_���>�)x���̇�
|
3
|
+
((��_)��2�d����F~q#ZS��_\˪��<(��+�H��0s�����)o܅�I:�8��6�H���@JgA����=�Y۬ފ(
|
4
|
+
�cx�l�T��t��I�(R"27��H�Aˡ�V��ah���~wC�F (v
|
data/lib/traces/backend/test.rb
CHANGED
data/lib/traces/backend.rb
CHANGED
data/lib/traces/context.rb
CHANGED
data/lib/traces/provider.rb
CHANGED
@@ -24,8 +24,8 @@ require_relative 'backend'
|
|
24
24
|
|
25
25
|
module Traces
|
26
26
|
module Provider
|
27
|
-
def
|
28
|
-
@
|
27
|
+
def traces_provider
|
28
|
+
@traces_provider ||= Module.new
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,9 +33,8 @@ module Traces
|
|
33
33
|
if Traces.const_defined?(:Backend)
|
34
34
|
def self.Provider(klass, &block)
|
35
35
|
klass.extend(Provider)
|
36
|
-
klass.prepend(Backend)
|
37
36
|
|
38
|
-
provider = klass.
|
37
|
+
provider = klass.traces_provider
|
39
38
|
provider.prepend(Backend)
|
40
39
|
|
41
40
|
klass.prepend(provider)
|
data/lib/traces/version.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,42 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traces
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
14
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
15
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
16
|
+
aWFtcy9EQz1vcmlvbnR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
|
+
vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
|
32
|
+
x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
|
33
|
+
bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
|
34
|
+
Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
|
35
|
+
y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
|
36
|
+
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
37
|
+
HiLJ8VOFx6w=
|
38
|
+
-----END CERTIFICATE-----
|
39
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
40
|
dependencies:
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rspec
|
@@ -33,13 +61,11 @@ files:
|
|
33
61
|
- lib/traces.rb
|
34
62
|
- lib/traces/backend.rb
|
35
63
|
- lib/traces/backend/console.rb
|
36
|
-
- lib/traces/backend/datadog.rb
|
37
|
-
- lib/traces/backend/open_telemetry.rb
|
38
64
|
- lib/traces/backend/test.rb
|
39
65
|
- lib/traces/context.rb
|
40
66
|
- lib/traces/provider.rb
|
41
67
|
- lib/traces/version.rb
|
42
|
-
homepage: https://github.com/socketry/
|
68
|
+
homepage: https://github.com/socketry/traces
|
43
69
|
licenses:
|
44
70
|
- MIT
|
45
71
|
metadata: {}
|
@@ -58,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
84
|
- !ruby/object:Gem::Version
|
59
85
|
version: '0'
|
60
86
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.1.6
|
62
88
|
signing_key:
|
63
89
|
specification_version: 4
|
64
90
|
summary: Application instrumentation and tracing.
|
metadata.gz.sig
ADDED
@@ -1,70 +0,0 @@
|
|
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
|
-
require_relative '../context'
|
24
|
-
|
25
|
-
require 'ddtrace'
|
26
|
-
|
27
|
-
module Traces
|
28
|
-
module Backend
|
29
|
-
private
|
30
|
-
|
31
|
-
def trace(name, parent = nil, attributes: nil, &block)
|
32
|
-
if parent
|
33
|
-
parent = ::Datadog::Context.new(
|
34
|
-
trace_id: parent.trace_id,
|
35
|
-
span_id: parent.span_id,
|
36
|
-
sampled: parent.sampled?,
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
::Datadog.tracer.trace(name, child_of: parent, tags: attributes) do |span|
|
41
|
-
begin
|
42
|
-
if block.arity.zero?
|
43
|
-
yield
|
44
|
-
else
|
45
|
-
yield trace_span_context(span)
|
46
|
-
end
|
47
|
-
rescue Exception => error
|
48
|
-
Console.logger.error(self, error)
|
49
|
-
raise
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def trace_span_context(span)
|
55
|
-
flags = 0
|
56
|
-
|
57
|
-
if span.sampled
|
58
|
-
flags |= Context::SAMPLED
|
59
|
-
end
|
60
|
-
|
61
|
-
return Context.new(
|
62
|
-
span.trace_id,
|
63
|
-
span.span_id,
|
64
|
-
flags,
|
65
|
-
nil,
|
66
|
-
remote: false
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,76 +0,0 @@
|
|
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
|
-
require_relative '../context'
|
24
|
-
|
25
|
-
require 'opentelemetry/sdk'
|
26
|
-
|
27
|
-
module Traces
|
28
|
-
module Backend
|
29
|
-
private
|
30
|
-
|
31
|
-
# Provides a backend that writes data to OpenTelemetry.
|
32
|
-
# See <https://github.com/open-telemetry/opentelemetry-ruby> for more details.
|
33
|
-
TRACER = ::OpenTelemetry.tracer_provider.tracer(Traces, Traces::VERSION)
|
34
|
-
|
35
|
-
def trace(name, parent = nil, attributes: nil, &block)
|
36
|
-
if parent
|
37
|
-
# Convert it to the required object:
|
38
|
-
parent = ::OpenTelemetry::Traces::SpanContext.new(
|
39
|
-
trace_id: parent.trace_id,
|
40
|
-
span_id: parent.span_id,
|
41
|
-
trace_flags: ::OpenTelemetry::Traces::TracesFlags.from_byte(parent.flags),
|
42
|
-
tracestate: parent.state,
|
43
|
-
remote: parent.remote?
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
span = TRACER.start_span(name, with_parent: parent, attributes: attributes)
|
48
|
-
|
49
|
-
begin
|
50
|
-
if block.arity.zero?
|
51
|
-
yield
|
52
|
-
else
|
53
|
-
yield trace_span_context(span)
|
54
|
-
end
|
55
|
-
rescue Exception => error
|
56
|
-
span&.record_exception(error)
|
57
|
-
span&.status = ::OpenTelemetry::Traces::Status.error("Unhandled exception of type: #{error.class}")
|
58
|
-
raise
|
59
|
-
ensure
|
60
|
-
span&.finish
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def trace_span_context(span)
|
65
|
-
context = span.context
|
66
|
-
|
67
|
-
return Context.new(
|
68
|
-
context.trace_id,
|
69
|
-
context.span_id,
|
70
|
-
context.trace_flags,
|
71
|
-
context.tracestate,
|
72
|
-
remote: context.remote?
|
73
|
-
)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|