uptrace 1.2.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -10
- data/lib/uptrace/client.rb +3 -2
- data/lib/uptrace/dsn.rb +8 -13
- data/lib/uptrace/id_generator.rb +8 -5
- data/lib/uptrace/version.rb +1 -1
- data/lib/uptrace.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38dd8206d1bf9212b72a56b017870d9be53ff8136e4ca3079778977025e2147c
|
4
|
+
data.tar.gz: ae1f04fbebf274f7e04aff463fb830a3e2e51428cce42de51b774b1992db1301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9266099177298e3228ad5ad57fbd466e4f201b2fe8903be555e67819c26564d7e9a5cd2704b68b05230d612135086ff33156ab30e3d1262acadb359ec8d8705e
|
7
|
+
data.tar.gz: 881cb73ac6ff636cc2d6dc6d879d3a36f39683eb9aa65215a3f8da250eaaebf60e60cee2dc43f78c26a94dd01404e200867b933fe479163b1a043557516eccee
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
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
|
-
[![Documentation](https://img.shields.io/badge/uptrace-documentation-informational)](https://uptrace.dev/get/
|
4
|
+
[![Documentation](https://img.shields.io/badge/uptrace-documentation-informational)](https://uptrace.dev/get/opentelemetry-ruby.html)
|
5
5
|
[![Chat](https://img.shields.io/badge/-telegram-red?color=white&logo=telegram&logoColor=black)](https://t.me/uptrace)
|
6
6
|
|
7
|
-
<a href="https://uptrace.dev/get/
|
7
|
+
<a href="https://uptrace.dev/get/opentelemetry-ruby.html">
|
8
8
|
<img src="https://uptrace.dev/get/devicon/ruby-original.svg" height="200px" />
|
9
9
|
</a>
|
10
10
|
|
@@ -37,21 +37,28 @@ Uptrace.configure_opentelemetry(dsn: '') do |c|
|
|
37
37
|
# c is OpenTelemetry::SDK::Configurator
|
38
38
|
c.service_name = 'myservice'
|
39
39
|
c.service_version = '1.0.0'
|
40
|
+
|
41
|
+
c.resource = OpenTelemetry::SDK::Resources::Resource.create(
|
42
|
+
'deployment.environment' => 'production'
|
43
|
+
)
|
40
44
|
end
|
41
45
|
|
42
46
|
# Create a tracer. Usually, tracer is a global variable.
|
43
47
|
tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
|
44
48
|
|
45
49
|
# Create a root span (a trace) to measure some operation.
|
46
|
-
tracer.in_span('main-operation') do |main|
|
47
|
-
tracer.in_span('
|
48
|
-
child1.set_attribute('
|
50
|
+
tracer.in_span('main-operation', kind: :client) do |main|
|
51
|
+
tracer.in_span('GET /posts/:id') do |child1|
|
52
|
+
child1.set_attribute('http.method', 'GET')
|
53
|
+
child1.set_attribute('http.route', '/posts/:id')
|
54
|
+
child1.set_attribute('http.url', 'http://localhost:8080/posts/123')
|
55
|
+
child1.set_attribute('http.status_code', 200)
|
49
56
|
child1.record_exception(ArgumentError.new('error1'))
|
50
57
|
end
|
51
58
|
|
52
|
-
tracer.in_span('
|
53
|
-
child2.set_attribute('
|
54
|
-
child2.set_attribute('
|
59
|
+
tracer.in_span('SELECT') do |child2|
|
60
|
+
child2.set_attribute('db.system', 'mysql')
|
61
|
+
child2.set_attribute('db.statement', 'SELECT * FROM posts LIMIT 100')
|
55
62
|
end
|
56
63
|
|
57
64
|
puts("trace URL: #{Uptrace.trace_url(main)}")
|
@@ -64,5 +71,7 @@ OpenTelemetry.tracer_provider.shutdown
|
|
64
71
|
## Links
|
65
72
|
|
66
73
|
- [Examples](example)
|
67
|
-
- [Documentation](https://uptrace.dev/get/
|
68
|
-
- [Instrumentations](https://uptrace.dev/opentelemetry/instrumentations/?lang=ruby)
|
74
|
+
- [Documentation](https://uptrace.dev/get/opentelemetry-ruby.html)
|
75
|
+
- [OpenTelemetry Instrumentations](https://uptrace.dev/opentelemetry/instrumentations/?lang=ruby)
|
76
|
+
- [OpenTelemetry Rails](https://uptrace.dev/opentelemetry/instrumentations/ruby-rails.html)
|
77
|
+
- [OpenTelemetry Sinatra](https://uptrace.dev/opentelemetry/instrumentations/ruby-sinatra.html)
|
data/lib/uptrace/client.rb
CHANGED
@@ -17,7 +17,7 @@ module Uptrace
|
|
17
17
|
Uptrace.logger.error("Uptrace is disabled: #{e.message}")
|
18
18
|
@disabled = true
|
19
19
|
|
20
|
-
@dsn = DSN.new('https://TOKEN@uptrace.dev
|
20
|
+
@dsn = DSN.new('https://TOKEN@uptrace.dev')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -30,7 +30,8 @@ module Uptrace
|
|
30
30
|
def trace_url(span = nil)
|
31
31
|
span = OpenTelemetry::Trace.current_span if span.nil?
|
32
32
|
trace_id = span.context.hex_trace_id
|
33
|
-
|
33
|
+
span_id = span.context.hex_span_id
|
34
|
+
"#{@dsn.site_url}/traces/#{trace_id}?span_id=#{span_id}"
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/uptrace/dsn.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Uptrace
|
4
4
|
# Uptrace DSN
|
5
5
|
class DSN
|
6
|
-
attr_reader :dsn, :scheme, :host, :
|
6
|
+
attr_reader :dsn, :scheme, :host, :http_port, :token
|
7
7
|
|
8
8
|
def initialize(dsn)
|
9
9
|
raise ArgumentError, "DSN can't be empty" if dsn.empty?
|
@@ -17,8 +17,7 @@ module Uptrace
|
|
17
17
|
@dsn = dsn
|
18
18
|
@scheme = uri.scheme
|
19
19
|
@host = uri.host
|
20
|
-
@
|
21
|
-
@project_id = uri.path.delete_prefix('/')
|
20
|
+
@http_port = uri.port
|
22
21
|
@token = uri.user
|
23
22
|
|
24
23
|
%w[scheme host].each do |k|
|
@@ -27,28 +26,24 @@ module Uptrace
|
|
27
26
|
end
|
28
27
|
|
29
28
|
@host = 'uptrace.dev' if @host == 'api.uptrace.dev'
|
30
|
-
return if @host != 'uptrace.dev'
|
31
|
-
|
32
|
-
%w[project_id token].each do |k|
|
33
|
-
v = public_send(k)
|
34
|
-
raise ArgumentError, %(DSN=#{dsn.inspect} does not have a #{k}) if v.nil? || v.empty?
|
35
|
-
end
|
36
29
|
end
|
37
30
|
|
38
31
|
def to_s
|
39
32
|
@dsn
|
40
33
|
end
|
41
34
|
|
42
|
-
def
|
35
|
+
def site_url
|
43
36
|
return 'https://app.uptrace.dev' if @host == 'uptrace.dev'
|
37
|
+
return "#{@scheme}://#{@host}:#{@http_port}" if @http_port != 443
|
44
38
|
|
45
|
-
"#{@scheme}://#{@host}
|
39
|
+
"#{@scheme}://#{@host}"
|
46
40
|
end
|
47
41
|
|
48
|
-
def
|
42
|
+
def otlp_http_endpoint
|
49
43
|
return 'https://otlp.uptrace.dev' if @host == 'uptrace.dev'
|
44
|
+
return "#{@scheme}://#{@host}:#{@http_port}" if @http_port != 443
|
50
45
|
|
51
|
-
"#{@scheme}://#{@host}
|
46
|
+
"#{@scheme}://#{@host}"
|
52
47
|
end
|
53
48
|
end
|
54
49
|
end
|
data/lib/uptrace/id_generator.rb
CHANGED
@@ -5,6 +5,9 @@ module Uptrace
|
|
5
5
|
module IdGenerator
|
6
6
|
extend self
|
7
7
|
|
8
|
+
# An invalid span identifier, an 8-byte string with all zero bytes.
|
9
|
+
INVALID_SPAN_ID = ("\0" * 8).b
|
10
|
+
|
8
11
|
# Random number generator for generating IDs. This is an object that can
|
9
12
|
# respond to `#bytes` and uses the system PRNG. The current logic is
|
10
13
|
# compatible with Ruby 2.5 (which does not implement the `Random.bytes`
|
@@ -13,7 +16,7 @@ module Uptrace
|
|
13
16
|
# the class `Random`.
|
14
17
|
#
|
15
18
|
# @return [#bytes]
|
16
|
-
RANDOM = Random.respond_to?(:bytes) ? Random : Random
|
19
|
+
RANDOM = Random.respond_to?(:bytes) ? Random : Random.new
|
17
20
|
|
18
21
|
# Generates a valid trace identifier, a 16-byte string with at least one
|
19
22
|
# non-zero byte.
|
@@ -31,10 +34,10 @@ module Uptrace
|
|
31
34
|
#
|
32
35
|
# @return [String] a valid span ID.
|
33
36
|
def generate_span_id
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
loop do
|
38
|
+
id = Random.bytes(8)
|
39
|
+
return id unless id == INVALID_SPAN_ID
|
40
|
+
end
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
data/lib/uptrace/version.rb
CHANGED
data/lib/uptrace.rb
CHANGED
@@ -44,7 +44,7 @@ module Uptrace
|
|
44
44
|
|
45
45
|
def span_processor(dsn)
|
46
46
|
exporter = OpenTelemetry::Exporter::OTLP::Exporter.new(
|
47
|
-
endpoint: "#{dsn.
|
47
|
+
endpoint: "#{dsn.otlp_http_endpoint}/v1/traces",
|
48
48
|
# Set the Uptrace DSN here or use UPTRACE_DSN env var.
|
49
49
|
headers: { 'uptrace-dsn': dsn.to_s },
|
50
50
|
compression: 'gzip'
|
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: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uptrace Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-exporter-otlp
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.26.1
|
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: 0.
|
26
|
+
version: 0.26.1
|
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: 1.
|
33
|
+
version: 1.3.1
|
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: 1.
|
40
|
+
version: 1.3.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
89
|
+
version: 1.57.2
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
96
|
+
version: 1.57.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop-minitest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.33.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.33.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop-rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
181
|
requirements:
|
182
182
|
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
184
|
+
version: '3.0'
|
185
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - ">="
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.4.10
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: Uptrace Ruby exporter for OpenTelemetry
|