uptrace 0.2.6 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +48 -7
- data/lib/uptrace.rb +16 -5
- data/lib/uptrace/client.rb +4 -2
- data/lib/uptrace/dsn.rb +1 -1
- data/lib/uptrace/trace/exporter.rb +13 -11
- data/lib/uptrace/version.rb +1 -1
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f9a4d977dcec234cd8810306f108488708ca23a30ce0836d71d52e5f759033b
|
4
|
+
data.tar.gz: 305152b04753b7febe844a76ff675f192f5d0f939f179b77dfb73a4fd21d71fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0593e88e857717b329f4f4d21278efddd605412e3ab63d617eccb3547bbabacaf98ff3f7c68630b90215eff7712cc824c7579e2c5edb78617931b3004b1930b
|
7
|
+
data.tar.gz: d8c976e2e80dbaa0eb323c8c71ee919cac0b53331bec52483b34e0e393dece72914ef21810d4d5c677a1ee8bc8902a6f210d2c814366a9afe940f456ee9fa5c9
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.0.0.rc1 - 2021-05-22
|
4
|
+
|
5
|
+
- Updated OpenTelemetry to
|
6
|
+
[v1.0.0.rc1](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v100rc1--2021-05-21).
|
7
|
+
|
8
|
+
## v0.17.0 - 2021-04-24
|
9
|
+
|
10
|
+
- Updated OpenTelemetry to
|
11
|
+
[v0.17.0](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v0170--2021-04-22).
|
12
|
+
|
13
|
+
## v0.16.2 - 2021-03-28
|
14
|
+
|
15
|
+
- Updated OpenTelemetry to
|
16
|
+
[v0.16.0](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v0160--2021-03-17).
|
data/README.md
CHANGED
@@ -1,21 +1,62 @@
|
|
1
1
|
# Uptrace Ruby exporter for OpenTelemetry
|
2
2
|
|
3
|
-
|
3
|
+
![build workflow](https://github.com/uptrace/uptrace-ruby/actions/workflows/build.yml/badge.svg)
|
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
|
11
|
+
|
12
|
+
uptrace-ruby is an OpenTelemery distribution configured to export
|
13
|
+
[traces](https://docs.uptrace.dev/tracing/#spans) to Uptrace.
|
14
|
+
|
15
|
+
## Quickstart
|
16
|
+
|
17
|
+
Install uptrace-ruby:
|
11
18
|
|
12
19
|
```bash
|
13
20
|
gem install uptrace
|
14
21
|
```
|
15
22
|
|
16
|
-
|
23
|
+
Run the [basic example](example/basic) below using the DSN from the Uptrace project settings page.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
#!/usr/bin/env ruby
|
27
|
+
# frozen_string_literal: true
|
28
|
+
|
29
|
+
require 'rubygems'
|
30
|
+
require 'bundler/setup'
|
31
|
+
require 'uptrace'
|
17
32
|
|
18
|
-
|
19
|
-
|
33
|
+
OpenTelemetry::SDK.configure do |c|
|
34
|
+
c.service_name = 'myservice'
|
35
|
+
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
|
+
end
|
41
|
+
|
42
|
+
tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
|
43
|
+
|
44
|
+
tracer.in_span('main') do |span|
|
45
|
+
tracer.in_span('child1') do |child1|
|
46
|
+
child1.set_attribute('key1', 'value1')
|
47
|
+
child1.record_exception(ArgumentError.new('error1'))
|
48
|
+
end
|
49
|
+
|
50
|
+
tracer.in_span('child2') do |child2|
|
51
|
+
child2.set_attribute('key2', '24')
|
52
|
+
child2.set_attribute('key3', 123.456)
|
53
|
+
end
|
54
|
+
|
55
|
+
puts("trace URL: #{Uptrace.trace_url(span)}")
|
56
|
+
end
|
57
|
+
|
58
|
+
# Send buffered spans.
|
59
|
+
OpenTelemetry.tracer_provider.shutdown
|
60
|
+
```
|
20
61
|
|
21
|
-
|
62
|
+
Please see [uptrace-ruby documentation](https://docs.uptrace.dev/ruby/) for more details.
|
data/lib/uptrace.rb
CHANGED
@@ -16,14 +16,25 @@ module Uptrace
|
|
16
16
|
@client ||= Client.new
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
# @param [optional OpenTelemetry::Trace::Span] span
|
20
|
+
# @return [String]
|
21
|
+
def trace_url(span = nil)
|
20
22
|
client.trace_url(span)
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
# ConfigureOpentelemetry configures OpenTelemetry to export data to Uptrace.
|
26
|
+
# Specifically it configures and registers Uptrace span exporter.
|
27
|
+
#
|
28
|
+
# @param [optional String] dsn
|
29
|
+
# @yieldparam [OpenTelemetry::SDK::Configurator] c Yields a configurator to the
|
30
|
+
# provided block
|
31
|
+
def configure_opentelemetry(dsn: '')
|
32
|
+
OpenTelemetry::SDK.configure do |c|
|
33
|
+
@client = Client.new(dsn: dsn) unless dsn.empty?
|
34
|
+
c.add_span_processor(client.span_processor) unless client.disabled?
|
35
|
+
|
36
|
+
yield c if block_given?
|
37
|
+
end
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
data/lib/uptrace/client.rb
CHANGED
@@ -23,9 +23,11 @@ module Uptrace
|
|
23
23
|
@disabled
|
24
24
|
end
|
25
25
|
|
26
|
-
# @param [OpenTelemetry::Trace::Span] span
|
26
|
+
# @param [optional OpenTelemetry::Trace::Span] span
|
27
27
|
# @return [String]
|
28
|
-
def trace_url(span)
|
28
|
+
def trace_url(span = nil)
|
29
|
+
span = OpenTelemetry::Trace.current_span if span.nil?
|
30
|
+
|
29
31
|
host = @dsn.host.delete_prefix('api.')
|
30
32
|
trace_id = span.context.hex_trace_id
|
31
33
|
"#{@dsn.scheme}://#{host}/search/#{@dsn.project_id}?q=#{trace_id}"
|
data/lib/uptrace/dsn.rb
CHANGED
@@ -51,6 +51,15 @@ module Uptrace
|
|
51
51
|
send({ spans: out }, timeout: timeout)
|
52
52
|
end
|
53
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
|
+
|
54
63
|
# Called when {OpenTelemetry::SDK::Trace::Tracer#shutdown} is called, if
|
55
64
|
# this exporter is registered to a {OpenTelemetry::SDK::Trace::Tracer}
|
56
65
|
# object.
|
@@ -59,6 +68,7 @@ module Uptrace
|
|
59
68
|
def shutdown(timeout: nil) # rubocop:disable Lint/UnusedMethodArgument
|
60
69
|
@shutdown = true
|
61
70
|
@http.finish if @http.started?
|
71
|
+
SUCCESS
|
62
72
|
end
|
63
73
|
|
64
74
|
private
|
@@ -73,8 +83,8 @@ module Uptrace
|
|
73
83
|
|
74
84
|
name: span.name,
|
75
85
|
kind: kind_as_str(span.kind),
|
76
|
-
startTime:
|
77
|
-
endTime:
|
86
|
+
startTime: span.start_timestamp,
|
87
|
+
endTime: span.end_timestamp,
|
78
88
|
|
79
89
|
resource: uptrace_resource(span.resource),
|
80
90
|
attrs: span.attributes
|
@@ -157,14 +167,6 @@ module Uptrace
|
|
157
167
|
end
|
158
168
|
end
|
159
169
|
|
160
|
-
##
|
161
|
-
# @param [Integer] timestamp
|
162
|
-
# @return [Integer]
|
163
|
-
#
|
164
|
-
def as_unix_nano(timestamp)
|
165
|
-
(timestamp.to_r * 1_000_000_000).to_i
|
166
|
-
end
|
167
|
-
|
168
170
|
##
|
169
171
|
# @param [Integer] code
|
170
172
|
# @return [String]
|
@@ -197,7 +199,7 @@ module Uptrace
|
|
197
199
|
{
|
198
200
|
name: event.name,
|
199
201
|
attrs: event.attributes,
|
200
|
-
time:
|
202
|
+
time: event.timestamp
|
201
203
|
}
|
202
204
|
)
|
203
205
|
end
|
data/lib/uptrace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.rc1
|
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-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.4.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: 1.4.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.rc1
|
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.
|
40
|
+
version: 1.0.0.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: zstd-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.4.
|
47
|
+
version: 1.4.9.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.4.
|
54
|
+
version: 1.4.9.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.1.4
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.1.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +172,7 @@ extensions: []
|
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
174
|
- ".yardopts"
|
175
|
+
- CHANGELOG.md
|
175
176
|
- LICENSE
|
176
177
|
- README.md
|
177
178
|
- RELEASE.md
|
@@ -197,9 +198,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
198
|
version: 2.5.0
|
198
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
200
|
requirements:
|
200
|
-
- - "
|
201
|
+
- - ">"
|
201
202
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
203
|
+
version: 1.3.1
|
203
204
|
requirements: []
|
204
205
|
rubygems_version: 3.1.4
|
205
206
|
signing_key:
|