uptrace 0.2.4 → 0.16.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: 525b8e2ad45dd955af7095839bfdf024e29b11309e8a0103b36bddb7980f3c41
4
- data.tar.gz: 0766a2822dad2acb536aeccba788ac898ce7474ae4d74de355577de544772a4b
3
+ metadata.gz: 6e560d02dc7fff00fe1417273235f621093fddf1dd2b89fec8eb26f25ec77137
4
+ data.tar.gz: f4425d572581c3b8863891e7f1df56c1acc2a8df19e96d56c5fadc138b147fd6
5
5
  SHA512:
6
- metadata.gz: 36c69755595e07ffee78a62f3f1633fdd62def2d910b50876e8ffc4e2791800869d98f61b338bb2e30a01280610cc5fbeabe58a0f17214b5f2377031c2801f07
7
- data.tar.gz: f33956036979a79d2f39e05f8a30f3008ffd967a828a048d88b187867e562bd013cecf9b0958584dc885142341633848739c3fc05dded624c8c16dc7ee8d7848
6
+ metadata.gz: f9d888b255f9b97deb19d115bfc0a16eca449a79df08c6262557be002f98460a3ba1db188caf5cf2266e7cbbe92aefd5fec1567a7c398ddcd04021f4315324e2
7
+ data.tar.gz: d831ec671858212f78caeadba72689d0735b0c85579af3bcec992e5df83c62d40af0a447dea647f0a28c993f277f8e3ecfbaa9aa9ef348734912523ecc947f26
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## v0.16.2 - 2021-03-28
4
+
5
+ - Updated OpenTelemetry to
6
+ [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
- [![Build Status](https://travis-ci.org/uptrace/uptrace-ruby.svg?branch=master)](https://travis-ci.org/uptrace/uptrace-ruby)
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
- ## Installation
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
- ## Introduction
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
- uptrace-ruby is the official Uptrace client for Ruby that sends your traces/spans and metrics to
19
- [Uptrace.dev](https://uptrace.dev).
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
- See [uptrace-ruby documentation](https://docs.uptrace.dev/ruby/) for details.
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
- def trace_url(span)
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
- def configure_tracing(c, dsn: '')
24
- upclient = if dsn.empty?
25
- client
26
- else
27
- Client.new(dsn: dsn)
28
- end
29
-
30
- c.add_span_processor(upclient.span_processor) unless upclient.disabled?
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
 
@@ -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
@@ -25,7 +25,7 @@ module Uptrace
25
25
 
26
26
  KEYS.each do |k|
27
27
  v = public_send(k)
28
- raise ArgumentError, %(DSN does not have #{k} (DSN=#{dsn.inspect})) if v.nil? || v.empty?
28
+ raise ArgumentError, %(DSN=#{dsn.inspect} does not have a #{k}) if v.nil? || v.empty?
29
29
  end
30
30
  end
31
31
 
data/lib/uptrace/trace.rb CHANGED
@@ -6,5 +6,4 @@ module Uptrace
6
6
  end
7
7
  end
8
8
 
9
- require 'uptrace/trace/config'
10
9
  require 'uptrace/trace/exporter'
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uptrace
4
- VERSION = '0.2.4'
4
+ VERSION = '0.16.2'
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: 0.2.4
4
+ version: 0.16.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-03-18 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.15.0
33
+ version: 0.16.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.15.0
40
+ version: 0.16.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zstd-ruby
43
43
  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