uptrace 0.2.5 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +47 -6
- data/lib/uptrace.rb +16 -9
- data/lib/uptrace/client.rb +4 -2
- data/lib/uptrace/dsn.rb +1 -1
- data/lib/uptrace/trace/exporter.rb +10 -0
- data/lib/uptrace/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b0f7710f0eae6b7bcd64b9ba4cb6f8e8ea0d038288dc01f173381a1937639c9
|
4
|
+
data.tar.gz: 160bd219eb212e7e97561b758b1d76cf3a38672aa02e292c218c9694b8f27544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e67923bceb81e39049b4dadf8d0a0740b114300d6c979fb9f720dd3a599adf83c0fb0adfe5b0fece036225863ab27ea05e738df2d547c82d2bff25b3e0c1a6fe
|
7
|
+
data.tar.gz: 39886118653a1e0f61d6d880c1adda437c337dcff2819f7ffd2d012561dccda10340565aece6b600f7bdcb741881413d925f65ed95cd9463d0502077cb11dfa2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v0.17.0 - 2021-04-24
|
4
|
+
|
5
|
+
- Updated OpenTelemetry to
|
6
|
+
[v0.17.0](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/CHANGELOG.md#v0170--2021-04-22).
|
7
|
+
|
8
|
+
## v0.16.2 - 2021-03-28
|
9
|
+
|
10
|
+
- Updated OpenTelemetry to
|
11
|
+
[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
7
|
<img src="https://docs.uptrace.dev/devicons/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,18 +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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
31
38
|
end
|
32
39
|
end
|
33
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
|
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: 0.17.0
|
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-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -16,42 +16,42 @@ 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: 0.17.0
|
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: 0.17.0
|
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
|
@@ -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
|