uptrace 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b337f4c98d5b7ec15fd132be2ca475d847670849bc962ccf07c1b81231b70e5
4
- data.tar.gz: 3132ef5b3ba04a8164b2f9f86e73d36ecb317309939fa877fe3363e2a98a75cd
3
+ metadata.gz: 5f18ccfecc949d79b9c0e06850f440ce7f137dcb4111e2646bd730e9c51107cb
4
+ data.tar.gz: e1456ae29aa3fc8581e142ef858562033a6fc27e154718af9aeb49c2045385df
5
5
  SHA512:
6
- metadata.gz: aab99b93dc7a4aa77851f90f1ff65b946a9698df3b88a701c5541163e294a67eabe00fd36ff24e31069a9d0443c286e8a2ac1d7113cda2eef8ee9bcf5bb7ea19
7
- data.tar.gz: 55f723706b0dee67cd20b37bde410ea3da339eb5064bffa7586efbbe3057fc1305908af994f4e17f5f6f602a9a6401673dd72623f9c48adfbe5ad136cc93b235
6
+ metadata.gz: 90942bebaa75ea64f57609c70f4be2c50a4dd8e0809f9b059e7c9d8d25ba0aeb6c31c29ad731e878fbe9df208dcce2998d2fe2e6ad6abfb1731dedcbca2cfb69
7
+ data.tar.gz: fd117c9046126740d7181b378752e2f1cfc169599a4df073c5c0c6f0e9ff842fb32b70ed89fa1c1a7dc726ed7cd6a7d863e6894d2075d108bfaa66aae4af16fc
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/uptrace-ruby.html)
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/uptrace-ruby.html">
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('child1-of-main') do |child1|
48
- child1.set_attribute('key1', 'value1')
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('child2-of-main') do |child2|
53
- child2.set_attribute('key2', '24')
54
- child2.set_attribute('key3', 123.456)
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/uptrace-ruby.html)
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/dsn.rb CHANGED
@@ -28,11 +28,6 @@ module Uptrace
28
28
 
29
29
  @host = 'uptrace.dev' if @host == 'api.uptrace.dev'
30
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
31
  end
37
32
 
38
33
  def to_s
@@ -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`
@@ -20,8 +23,8 @@ module Uptrace
20
23
  #
21
24
  # @return [String] a valid trace ID.
22
25
  def generate_trace_id
23
- time = (Time.now.to_f * 1_000_000).to_i
24
- high = [time & 0xFFFFFFFF, time >> 32].pack('VV')
26
+ time = (Time.now.to_f * 1_000_000_000).to_i
27
+ high = [time >> 32, time & 0xFFFFFFFF].pack('NN')
25
28
  low = RANDOM.bytes(8)
26
29
  high << low
27
30
  end
@@ -31,10 +34,10 @@ module Uptrace
31
34
  #
32
35
  # @return [String] a valid span ID.
33
36
  def generate_span_id
34
- time = (Time.now.to_f * 1000).to_i
35
- high = RANDOM.bytes(4)
36
- low = [time].pack('V')
37
- high << low
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uptrace
4
- VERSION = '1.2.2'
4
+ VERSION = '1.3.0'
5
5
  end
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.2.2
4
+ version: 1.3.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: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2023-06-22 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.24.0
19
+ version: 0.26.0
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.24.0
26
+ version: 0.26.0
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.2.0
33
+ version: 1.3.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: 1.2.0
40
+ version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  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: 2.5.0
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.1.4
191
+ rubygems_version: 3.4.10
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Uptrace Ruby exporter for OpenTelemetry