uptrace 0.16.1 → 1.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +14 -12
- data/lib/uptrace.rb +29 -21
- data/lib/uptrace/client.rb +2 -11
- data/lib/uptrace/version.rb +1 -1
- metadata +14 -30
- data/lib/uptrace/metric.rb +0 -7
- data/lib/uptrace/trace.rb +0 -9
- data/lib/uptrace/trace/exporter.rb +0 -232
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56199216a5c7984c7896ed2d2480ec7d3ba062dbddc78feb1a640a8ea16d59a5
|
4
|
+
data.tar.gz: f63c2f468a5df9982a7fae3beb3911fe84b8743329f7c73fed8a26aa47851440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6ac6820d74a2df77286ae3d82cc94c91660cb31d04dfbbe5d2128ff0de645338d71e64658a32efb1e396b23ab8cb65ac86b3e1a3e2644ee00b767496627ab38
|
7
|
+
data.tar.gz: 1361f3804cfa101e125910035234dcc7dafd1c208babcaaca9d675ebb90e25da8c315f8631f7c9c11b832f6c49afd56a8552ba390b9a8d1a0cc939598a591431
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.0.0.rc3 - 2021-08-17
|
4
|
+
|
5
|
+
- Updated OpenTelemetry to
|
6
|
+
[v1.0.0.rc3](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v100rc3--2021-08-12).
|
7
|
+
- Switched to using OTLP protocol.
|
8
|
+
|
9
|
+
## v1.0.0.rc1 - 2021-05-22
|
10
|
+
|
11
|
+
- Updated OpenTelemetry to
|
12
|
+
[v1.0.0.rc1](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v100rc1--2021-05-21).
|
13
|
+
|
14
|
+
## v0.17.0 - 2021-04-24
|
15
|
+
|
16
|
+
- Updated OpenTelemetry to
|
17
|
+
[v0.17.0](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v0170--2021-04-22).
|
18
|
+
|
19
|
+
## v0.16.2 - 2021-03-28
|
20
|
+
|
21
|
+
- Updated OpenTelemetry to
|
22
|
+
[v0.16.0](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v0160--2021-03-17).
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Documentation](https://img.shields.io/badge/uptrace-documentation-informational)](https://docs.uptrace.dev/ruby/)
|
5
5
|
|
6
6
|
<a href="https://docs.uptrace.dev/ruby/">
|
7
|
-
<img src="https://docs.uptrace.dev/
|
7
|
+
<img src="https://docs.uptrace.dev/devicon/ruby-original.svg" height="200px" />
|
8
8
|
</a>
|
9
9
|
|
10
10
|
## Introduction
|
@@ -30,33 +30,35 @@ require 'rubygems'
|
|
30
30
|
require 'bundler/setup'
|
31
31
|
require 'uptrace'
|
32
32
|
|
33
|
-
OpenTelemetry
|
33
|
+
# Configure OpenTelemetry with sensible defaults.
|
34
|
+
# Copy your project DSN here or use UPTRACE_DSN env var.
|
35
|
+
Uptrace.configure_opentelemetry(dsn: '') do |c|
|
36
|
+
# c is OpenTelemetry::SDK::Configurator
|
34
37
|
c.service_name = 'myservice'
|
35
38
|
c.service_version = '1.0.0'
|
36
|
-
|
37
|
-
# Configure OpenTelemetry to export data to Uptrace.
|
38
|
-
# Copy your project DSN here or use UPTRACE_DSN env var.
|
39
|
-
Uptrace.configure_opentelemetry(c, dsn: '')
|
40
39
|
end
|
41
40
|
|
41
|
+
# Create a tracer. Usually, tracer is a global variable.
|
42
42
|
tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
# Create a root span (a trace) to measure some operation.
|
45
|
+
tracer.in_span('main-operation') do |main|
|
46
|
+
tracer.in_span('child1-of-main') do |child1|
|
46
47
|
child1.set_attribute('key1', 'value1')
|
47
48
|
child1.record_exception(ArgumentError.new('error1'))
|
48
49
|
end
|
49
50
|
|
50
|
-
tracer.in_span('child2') do |child2|
|
51
|
+
tracer.in_span('child2-of-main') do |child2|
|
51
52
|
child2.set_attribute('key2', '24')
|
52
53
|
child2.set_attribute('key3', 123.456)
|
53
54
|
end
|
54
55
|
|
55
|
-
puts("trace URL: #{Uptrace.trace_url(
|
56
|
+
puts("trace URL: #{Uptrace.trace_url(main)}")
|
56
57
|
end
|
57
58
|
|
58
|
-
# Send buffered spans.
|
59
|
+
# Send buffered spans and free resources.
|
59
60
|
OpenTelemetry.tracer_provider.shutdown
|
60
61
|
```
|
61
62
|
|
62
|
-
|
63
|
+
For more details, please see [documentation](https://docs.uptrace.dev/ruby/) and
|
64
|
+
[examples](example).
|
data/lib/uptrace.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'logger'
|
4
|
-
|
4
|
+
|
5
|
+
require 'opentelemetry/exporter/otlp'
|
5
6
|
|
6
7
|
# Uptrace provides Uptrace exporters for OpenTelemetry.
|
7
8
|
module Uptrace
|
@@ -24,31 +25,38 @@ module Uptrace
|
|
24
25
|
end
|
25
26
|
|
26
27
|
# ConfigureOpentelemetry configures OpenTelemetry to export data to Uptrace.
|
27
|
-
#
|
28
|
-
# - creates tracer provider;
|
29
|
-
# - registers Uptrace span exporter;
|
30
|
-
# - sets tracecontext + baggage composite context propagator.
|
28
|
+
# Specifically it configures and registers Uptrace span exporter.
|
31
29
|
#
|
32
|
-
# @param [
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
OpenTelemetry::Baggage::Propagation.text_map_injector
|
42
|
-
]
|
43
|
-
c.extractors = [
|
44
|
-
OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor,
|
45
|
-
OpenTelemetry::Baggage::Propagation.text_map_extractor
|
46
|
-
]
|
30
|
+
# @param [optional String] dsn
|
31
|
+
# @yieldparam [OpenTelemetry::SDK::Configurator] c Yields a configurator to the
|
32
|
+
# provided block
|
33
|
+
def configure_opentelemetry(dsn: '')
|
34
|
+
OpenTelemetry::SDK.configure do |c|
|
35
|
+
@client = Client.new(dsn: dsn) unless dsn.empty?
|
36
|
+
c.add_span_processor(span_processor(@client.dsn.to_s)) unless client.disabled?
|
37
|
+
|
38
|
+
yield c if block_given?
|
47
39
|
end
|
48
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def span_processor(dsn)
|
45
|
+
exporter = OpenTelemetry::Exporter::OTLP::Exporter.new(
|
46
|
+
endpoint: 'https://otlp.uptrace.dev/v1/traces',
|
47
|
+
# Set the Uptrace DSN here or use UPTRACE_DSN env var.
|
48
|
+
headers: { 'uptrace-dsn': dsn },
|
49
|
+
compression: 'gzip'
|
50
|
+
)
|
51
|
+
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
52
|
+
exporter,
|
53
|
+
max_queue_size: 1000,
|
54
|
+
max_export_batch_size: 1000,
|
55
|
+
schedule_delay: 5_000
|
56
|
+
)
|
57
|
+
end
|
49
58
|
end
|
50
59
|
|
51
60
|
require 'uptrace/version'
|
52
61
|
require 'uptrace/dsn'
|
53
62
|
require 'uptrace/client'
|
54
|
-
require 'uptrace/trace'
|
data/lib/uptrace/client.rb
CHANGED
@@ -5,6 +5,8 @@ require 'opentelemetry/sdk'
|
|
5
5
|
module Uptrace
|
6
6
|
# Uptrace client that configures OpenTelemetry SDK to use Uptrace exporter.
|
7
7
|
class Client
|
8
|
+
attr_reader :dsn
|
9
|
+
|
8
10
|
# @param [string] dsn
|
9
11
|
def initialize(dsn: '')
|
10
12
|
dsn = ENV.fetch('UPTRACE_DSN', '') if dsn.empty?
|
@@ -32,16 +34,5 @@ module Uptrace
|
|
32
34
|
trace_id = span.context.hex_trace_id
|
33
35
|
"#{@dsn.scheme}://#{host}/search/#{@dsn.project_id}?q=#{trace_id}"
|
34
36
|
end
|
35
|
-
|
36
|
-
# @return [OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor]
|
37
|
-
def span_processor
|
38
|
-
exp = Uptrace::Trace::Exporter.new(@dsn)
|
39
|
-
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
40
|
-
exp,
|
41
|
-
max_queue_size: 1000,
|
42
|
-
max_export_batch_size: 1000,
|
43
|
-
schedule_delay: 5_000
|
44
|
-
)
|
45
|
-
end
|
46
37
|
end
|
47
38
|
end
|
data/lib/uptrace/version.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uptrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uptrace Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: opentelemetry-exporter-otlp
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.20.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.20.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: opentelemetry-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 1.0.0.rc3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: zstd-ruby
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.4.5.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.4.5.0
|
40
|
+
version: 1.0.0.rc3
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: 2.1.4
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: 2.1.4
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: minitest
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,15 +158,13 @@ extensions: []
|
|
172
158
|
extra_rdoc_files: []
|
173
159
|
files:
|
174
160
|
- ".yardopts"
|
161
|
+
- CHANGELOG.md
|
175
162
|
- LICENSE
|
176
163
|
- README.md
|
177
164
|
- RELEASE.md
|
178
165
|
- lib/uptrace.rb
|
179
166
|
- lib/uptrace/client.rb
|
180
167
|
- lib/uptrace/dsn.rb
|
181
|
-
- lib/uptrace/metric.rb
|
182
|
-
- lib/uptrace/trace.rb
|
183
|
-
- lib/uptrace/trace/exporter.rb
|
184
168
|
- lib/uptrace/version.rb
|
185
169
|
homepage: https://github.com/uptrace/uptrace-ruby
|
186
170
|
licenses:
|
@@ -197,9 +181,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
181
|
version: 2.5.0
|
198
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
183
|
requirements:
|
200
|
-
- - "
|
184
|
+
- - ">"
|
201
185
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
186
|
+
version: 1.3.1
|
203
187
|
requirements: []
|
204
188
|
rubygems_version: 3.1.4
|
205
189
|
signing_key:
|
data/lib/uptrace/metric.rb
DELETED
data/lib/uptrace/trace.rb
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
require 'net/http'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
require 'opentelemetry/sdk'
|
8
|
-
require 'msgpack'
|
9
|
-
require 'zstd-ruby'
|
10
|
-
|
11
|
-
module Uptrace
|
12
|
-
module Trace
|
13
|
-
# Exporter is a span exporter for OpenTelemetry.
|
14
|
-
class Exporter
|
15
|
-
SUCCESS = OpenTelemetry::SDK::Trace::Export::SUCCESS
|
16
|
-
FAILURE = OpenTelemetry::SDK::Trace::Export::FAILURE
|
17
|
-
TIMEOUT = OpenTelemetry::SDK::Trace::Export::TIMEOUT
|
18
|
-
private_constant(:SUCCESS, :FAILURE, :TIMEOUT)
|
19
|
-
|
20
|
-
##
|
21
|
-
# @param [Config] cfg
|
22
|
-
#
|
23
|
-
def initialize(dsn)
|
24
|
-
@dsn = dsn
|
25
|
-
@endpoint = "/api/v1/tracing/#{@dsn.project_id}/spans"
|
26
|
-
|
27
|
-
@http = Net::HTTP.new(@dsn.host, 443)
|
28
|
-
@http.use_ssl = true
|
29
|
-
@http.open_timeout = 5
|
30
|
-
@http.read_timeout = 5
|
31
|
-
@http.keep_alive_timeout = 30
|
32
|
-
end
|
33
|
-
|
34
|
-
# Called to export sampled {OpenTelemetry::SDK::Trace::SpanData} structs.
|
35
|
-
#
|
36
|
-
# @param [Enumerable<OpenTelemetry::SDK::Trace::SpanData>] spans the
|
37
|
-
# list of recorded {OpenTelemetry::SDK::Trace::SpanData} structs to be
|
38
|
-
# exported.
|
39
|
-
# @param [optional Numeric] timeout An optional timeout in seconds.
|
40
|
-
# @return [Integer] the result of the export.
|
41
|
-
def export(spans, timeout: nil)
|
42
|
-
return SUCCESS if @disabled
|
43
|
-
return FAILURE if @shutdown
|
44
|
-
|
45
|
-
out = []
|
46
|
-
|
47
|
-
spans.each do |span|
|
48
|
-
out.push(uptrace_span(span))
|
49
|
-
end
|
50
|
-
|
51
|
-
send({ spans: out }, timeout: timeout)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Called when {OpenTelemetry::SDK::Trace::TracerProvider#force_flush} is called, if
|
55
|
-
# this exporter is registered to a {OpenTelemetry::SDK::Trace::TracerProvider}
|
56
|
-
# object.
|
57
|
-
#
|
58
|
-
# @param [optional Numeric] timeout An optional timeout in seconds.
|
59
|
-
def force_flush(timeout: nil) # rubocop:disable Lint/UnusedMethodArgument
|
60
|
-
SUCCESS
|
61
|
-
end
|
62
|
-
|
63
|
-
# Called when {OpenTelemetry::SDK::Trace::Tracer#shutdown} is called, if
|
64
|
-
# this exporter is registered to a {OpenTelemetry::SDK::Trace::Tracer}
|
65
|
-
# object.
|
66
|
-
#
|
67
|
-
# @param [optional Numeric] timeout An optional timeout in seconds.
|
68
|
-
def shutdown(timeout: nil) # rubocop:disable Lint/UnusedMethodArgument
|
69
|
-
@shutdown = true
|
70
|
-
@http.finish if @http.started?
|
71
|
-
SUCCESS
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
##
|
77
|
-
# @return [hash]
|
78
|
-
#
|
79
|
-
def uptrace_span(span)
|
80
|
-
out = {
|
81
|
-
id: span.span_id.unpack1('Q'),
|
82
|
-
traceId: span.trace_id,
|
83
|
-
|
84
|
-
name: span.name,
|
85
|
-
kind: kind_as_str(span.kind),
|
86
|
-
startTime: as_unix_nano(span.start_timestamp),
|
87
|
-
endTime: as_unix_nano(span.end_timestamp),
|
88
|
-
|
89
|
-
resource: uptrace_resource(span.resource),
|
90
|
-
attrs: span.attributes
|
91
|
-
}
|
92
|
-
|
93
|
-
out[:parentId] = span.parent_span_id.unpack1('Q') if span.parent_span_id
|
94
|
-
|
95
|
-
out[:events] = uptrace_events(span.events) unless span.events.nil?
|
96
|
-
out[:links] = uptrace_links(span.links) unless span.links.nil?
|
97
|
-
|
98
|
-
status = span.status
|
99
|
-
out[:statusCode] = status_code_as_str(status.code)
|
100
|
-
out[:statusMessage] = status.description unless status.description.empty?
|
101
|
-
|
102
|
-
il = span.instrumentation_library
|
103
|
-
out[:tracerName] = il.name
|
104
|
-
out[:tracerVersion] = il.name unless il.version.empty?
|
105
|
-
|
106
|
-
out
|
107
|
-
end
|
108
|
-
|
109
|
-
def send(data, timeout: nil) # rubocop:disable Lint/UnusedMethodArgument
|
110
|
-
req = build_request(data)
|
111
|
-
|
112
|
-
begin
|
113
|
-
resp = @http.request(req)
|
114
|
-
rescue Net::OpenTimeout, Net::ReadTimeout
|
115
|
-
return FAILURE
|
116
|
-
end
|
117
|
-
|
118
|
-
case resp
|
119
|
-
when Net::HTTPOK
|
120
|
-
resp.body # Read and discard body
|
121
|
-
SUCCESS
|
122
|
-
when Net::HTTPBadRequest
|
123
|
-
data = JSON.parse(resp.body)
|
124
|
-
Uptrace.logger.error("status=#{data['status']}: #{data['message']}")
|
125
|
-
FAILURE
|
126
|
-
when Net::HTTPInternalServerError
|
127
|
-
resp.body
|
128
|
-
FAILURE
|
129
|
-
else
|
130
|
-
@http.finish
|
131
|
-
FAILURE
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
##
|
136
|
-
# @param [Hash] data
|
137
|
-
# @return [Net::HTTP::Post]
|
138
|
-
#
|
139
|
-
def build_request(data)
|
140
|
-
data = MessagePack.pack(data)
|
141
|
-
data = Zstd.compress(data, 3)
|
142
|
-
|
143
|
-
req = Net::HTTP::Post.new(@endpoint)
|
144
|
-
req.add_field('Authorization', "Bearer #{@dsn.token}")
|
145
|
-
req.add_field('Content-Type', 'application/msgpack')
|
146
|
-
req.add_field('Content-Encoding', 'zstd')
|
147
|
-
req.add_field('Connection', 'keep-alive')
|
148
|
-
req.body = data
|
149
|
-
|
150
|
-
req
|
151
|
-
end
|
152
|
-
|
153
|
-
# @param [SpanKind] kind
|
154
|
-
# @return [String]
|
155
|
-
def kind_as_str(kind)
|
156
|
-
case kind
|
157
|
-
when OpenTelemetry::Trace::SpanKind::SERVER
|
158
|
-
'server'
|
159
|
-
when OpenTelemetry::Trace::SpanKind::CLIENT
|
160
|
-
'client'
|
161
|
-
when OpenTelemetry::Trace::SpanKind::PRODUCER
|
162
|
-
'producer'
|
163
|
-
when OpenTelemetry::Trace::SpanKind::CONSUMER
|
164
|
-
'consumer'
|
165
|
-
else
|
166
|
-
'internal'
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
##
|
171
|
-
# @param [Integer] timestamp
|
172
|
-
# @return [Integer]
|
173
|
-
#
|
174
|
-
def as_unix_nano(timestamp)
|
175
|
-
(timestamp.to_r * 1_000_000_000).to_i
|
176
|
-
end
|
177
|
-
|
178
|
-
##
|
179
|
-
# @param [Integer] code
|
180
|
-
# @return [String]
|
181
|
-
#
|
182
|
-
def status_code_as_str(code)
|
183
|
-
case code
|
184
|
-
when OpenTelemetry::Trace::Status::OK
|
185
|
-
'ok'
|
186
|
-
when OpenTelemetry::Trace::Status::ERROR
|
187
|
-
'error'
|
188
|
-
else
|
189
|
-
'unset'
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
##
|
194
|
-
# @param [OpenTelemetry::SDK::Resources::Resource] resource
|
195
|
-
# @return [Hash]
|
196
|
-
#
|
197
|
-
def uptrace_resource(resource)
|
198
|
-
out = {}
|
199
|
-
resource.attribute_enumerator.map { |key, value| out[key] = value }
|
200
|
-
out
|
201
|
-
end
|
202
|
-
|
203
|
-
def uptrace_events(events)
|
204
|
-
out = []
|
205
|
-
events.each do |event|
|
206
|
-
out.push(
|
207
|
-
{
|
208
|
-
name: event.name,
|
209
|
-
attrs: event.attributes,
|
210
|
-
time: as_unix_nano(event.timestamp)
|
211
|
-
}
|
212
|
-
)
|
213
|
-
end
|
214
|
-
out
|
215
|
-
end
|
216
|
-
|
217
|
-
def uptrace_links(links)
|
218
|
-
out = []
|
219
|
-
links.each do |link|
|
220
|
-
out.push(
|
221
|
-
{
|
222
|
-
trace_id => link.span_context.trace_id,
|
223
|
-
span_id => link.span_context.span_id.unpack1('Q'),
|
224
|
-
attrs => link.attributes
|
225
|
-
}
|
226
|
-
)
|
227
|
-
end
|
228
|
-
out
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|