uptrace 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uptrace/id_generator.rb +40 -0
- data/lib/uptrace/version.rb +1 -1
- data/lib/uptrace.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b337f4c98d5b7ec15fd132be2ca475d847670849bc962ccf07c1b81231b70e5
|
4
|
+
data.tar.gz: 3132ef5b3ba04a8164b2f9f86e73d36ecb317309939fa877fe3363e2a98a75cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aab99b93dc7a4aa77851f90f1ff65b946a9698df3b88a701c5541163e294a67eabe00fd36ff24e31069a9d0443c286e8a2ac1d7113cda2eef8ee9bcf5bb7ea19
|
7
|
+
data.tar.gz: 55f723706b0dee67cd20b37bde410ea3da339eb5064bffa7586efbbe3057fc1305908af994f4e17f5f6f602a9a6401673dd72623f9c48adfbe5ad136cc93b235
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Uptrace
|
4
|
+
# Uptrace client that configures OpenTelemetry SDK to use Uptrace exporter.
|
5
|
+
module IdGenerator
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# Random number generator for generating IDs. This is an object that can
|
9
|
+
# respond to `#bytes` and uses the system PRNG. The current logic is
|
10
|
+
# compatible with Ruby 2.5 (which does not implement the `Random.bytes`
|
11
|
+
# class method) and with Ruby 3.0+ (which deprecates `Random::DEFAULT`).
|
12
|
+
# When we drop support for Ruby 2.5, this can simply be replaced with
|
13
|
+
# the class `Random`.
|
14
|
+
#
|
15
|
+
# @return [#bytes]
|
16
|
+
RANDOM = Random.respond_to?(:bytes) ? Random : Random::DEFAULT
|
17
|
+
|
18
|
+
# Generates a valid trace identifier, a 16-byte string with at least one
|
19
|
+
# non-zero byte.
|
20
|
+
#
|
21
|
+
# @return [String] a valid trace ID.
|
22
|
+
def generate_trace_id
|
23
|
+
time = (Time.now.to_f * 1_000_000).to_i
|
24
|
+
high = [time & 0xFFFFFFFF, time >> 32].pack('VV')
|
25
|
+
low = RANDOM.bytes(8)
|
26
|
+
high << low
|
27
|
+
end
|
28
|
+
|
29
|
+
# Generates a valid span identifier, an 8-byte string with at least one
|
30
|
+
# non-zero byte.
|
31
|
+
#
|
32
|
+
# @return [String] a valid span ID.
|
33
|
+
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
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/uptrace/version.rb
CHANGED
data/lib/uptrace.rb
CHANGED
@@ -34,6 +34,7 @@ module Uptrace
|
|
34
34
|
OpenTelemetry::SDK.configure do |c|
|
35
35
|
@client = Client.new(dsn: dsn) unless dsn.empty?
|
36
36
|
c.add_span_processor(span_processor(@client.dsn)) unless client.disabled?
|
37
|
+
c.id_generator = Uptrace::IdGenerator
|
37
38
|
|
38
39
|
yield c if block_given?
|
39
40
|
end
|
@@ -60,3 +61,4 @@ end
|
|
60
61
|
require 'uptrace/version'
|
61
62
|
require 'uptrace/dsn'
|
62
63
|
require 'uptrace/client'
|
64
|
+
require 'uptrace/id_generator'
|
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.
|
4
|
+
version: 1.2.2
|
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-
|
11
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-exporter-otlp
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/uptrace.rb
|
167
167
|
- lib/uptrace/client.rb
|
168
168
|
- lib/uptrace/dsn.rb
|
169
|
+
- lib/uptrace/id_generator.rb
|
169
170
|
- lib/uptrace/version.rb
|
170
171
|
homepage: https://github.com/uptrace/uptrace-ruby
|
171
172
|
licenses:
|