uptrace 1.0.1 → 1.0.2

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: c320ccec5439c9c74f4127443eb875ad2426bdb3efb3e83ef246ac8f1a69d4e3
4
- data.tar.gz: 88449bc895c39171505069b5d10574b807ebdcc3badc95a77792609ef7f63b90
3
+ metadata.gz: 6666340ea7b7556a09c06a41878efdd58bb10b4d05cdc711654189e01eec4011
4
+ data.tar.gz: 78c26e6a6f6e59e2ac01fd14a872a5c9c164e72431238d5c8d79322201fd1a20
5
5
  SHA512:
6
- metadata.gz: aed13462dbcefbceae6a239cc4cf206c46d69740f70a752c0317aac40c4b073d2ae965b413868af63f4520276bbdff39c46ee70cc9f22233d3699d9478c8435b
7
- data.tar.gz: e8f8e3fd095d9fee1bea930870ca5b330f848510005504c31a5f3c9f610c2eb2897d451ce40a81392b9e50c7c62d66fa767664c290c37caff3dd64d43e82b832
6
+ metadata.gz: b3780a0f3fa9841f4883618f0a7b28f1ec86e046e0f99c90ab6a5ffc0bd7a6c3e2ab3a004c2c3f7f848a62afbea5c9d699ecb07105f4f398c4594c6ce52099bf
7
+ data.tar.gz: '08270a500502c272d6eda9f96eab25909ea26a834e070ba8d6c4cb7ab7ccfee428d2094c63a353402c1a720b03d11fe7a3f95dad8e09171ad879df96eb2e3466'
@@ -24,5 +24,13 @@ module Uptrace
24
24
  def disabled?
25
25
  @disabled
26
26
  end
27
+
28
+ # @param [optional OpenTelemetry::Trace::Span] span
29
+ # @return [String]
30
+ def trace_url(span = nil)
31
+ span = OpenTelemetry::Trace.current_span if span.nil?
32
+ trace_id = span.context.hex_trace_id
33
+ "#{@dsn.app_addr}/traces/#{trace_id}"
34
+ end
27
35
  end
28
36
  end
data/lib/uptrace/dsn.rb CHANGED
@@ -3,9 +3,7 @@
3
3
  module Uptrace
4
4
  # Uptrace DSN
5
5
  class DSN
6
- KEYS = %w[scheme host project_id token].freeze
7
-
8
- attr_reader :dsn, :port, *KEYS
6
+ attr_reader :dsn, :scheme, :host, :port, :project_id, :token
9
7
 
10
8
  def initialize(dsn)
11
9
  raise ArgumentError, "DSN can't be empty" if dsn.empty?
@@ -17,13 +15,21 @@ module Uptrace
17
15
  end
18
16
 
19
17
  @dsn = dsn
20
- @project_id = uri.path.delete_prefix('/')
21
- @token = uri.user
18
+ @scheme = uri.scheme
22
19
  @host = uri.host
23
20
  @port = uri.port
24
- @scheme = uri.scheme
21
+ @project_id = uri.path.delete_prefix('/')
22
+ @token = uri.user
23
+
24
+ %w[scheme host].each do |k|
25
+ v = public_send(k)
26
+ raise ArgumentError, %(DSN=#{dsn.inspect} does not have a #{k}) if v.nil? || v.empty?
27
+ end
28
+
29
+ @host = 'uptrace.dev' if @host == 'api.uptrace.dev'
30
+ return if @host != 'uptrace.dev'
25
31
 
26
- KEYS.each do |k|
32
+ %w[project_id token].each do |k|
27
33
  v = public_send(k)
28
34
  raise ArgumentError, %(DSN=#{dsn.inspect} does not have a #{k}) if v.nil? || v.empty?
29
35
  end
@@ -32,5 +38,17 @@ module Uptrace
32
38
  def to_s
33
39
  @dsn
34
40
  end
41
+
42
+ def app_addr
43
+ return 'https://app.uptrace.dev' if @host == 'uptrace.dev'
44
+
45
+ "#{@scheme}://#{@host}:#{@port}"
46
+ end
47
+
48
+ def otlp_addr
49
+ return 'https://otlp.uptrace.dev' if @host == 'uptrace.dev'
50
+
51
+ "#{@scheme}://#{@host}:#{@port}"
52
+ end
35
53
  end
36
54
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uptrace
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
data/lib/uptrace.rb CHANGED
@@ -21,9 +21,7 @@ module Uptrace
21
21
  # @param [optional OpenTelemetry::Trace::Span] span
22
22
  # @return [String]
23
23
  def trace_url(span = nil)
24
- span = OpenTelemetry::Trace.current_span if span.nil?
25
- trace_id = span.context.hex_trace_id
26
- "https://app.uptrace.dev/traces/#{trace_id}"
24
+ @client.trace_url(span)
27
25
  end
28
26
 
29
27
  # ConfigureOpentelemetry configures OpenTelemetry to export data to Uptrace.
@@ -35,7 +33,7 @@ module Uptrace
35
33
  def configure_opentelemetry(dsn: '')
36
34
  OpenTelemetry::SDK.configure do |c|
37
35
  @client = Client.new(dsn: dsn) unless dsn.empty?
38
- c.add_span_processor(span_processor(@client.dsn.to_s)) unless client.disabled?
36
+ c.add_span_processor(span_processor(@client.dsn)) unless client.disabled?
39
37
 
40
38
  yield c if block_given?
41
39
  end
@@ -45,9 +43,9 @@ module Uptrace
45
43
 
46
44
  def span_processor(dsn)
47
45
  exporter = OpenTelemetry::Exporter::OTLP::Exporter.new(
48
- endpoint: 'https://otlp.uptrace.dev/v1/traces',
46
+ endpoint: "#{dsn.otlp_addr}/v1/traces",
49
47
  # Set the Uptrace DSN here or use UPTRACE_DSN env var.
50
- headers: { 'uptrace-dsn': dsn },
48
+ headers: { 'uptrace-dsn': dsn.to_s },
51
49
  compression: 'gzip'
52
50
  )
53
51
  OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uptrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.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: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-exporter-otlp
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.20.5
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.22.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.20.5
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.22.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: opentelemetry-sdk
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 1.0.0
39
+ version: 1.0.2
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 1.0.0
46
+ version: 1.0.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +92,28 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 1.22.3
95
+ version: 1.23.0
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: 1.22.3
102
+ version: 1.23.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rubocop-minitest
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: 0.15.2
109
+ version: 0.17.0
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
114
  - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: 0.15.2
116
+ version: 0.17.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rubocop-rake
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +175,8 @@ files:
169
175
  homepage: https://github.com/uptrace/uptrace-ruby
170
176
  licenses:
171
177
  - BSD-2-Clause
172
- metadata: {}
178
+ metadata:
179
+ rubygems_mfa_required: 'true'
173
180
  post_install_message:
174
181
  rdoc_options: []
175
182
  require_paths: