uptrace 0.2.6 → 0.16.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: 7eaccd23f9b8a866577eb6ef2c81589306a4930280bedbed67340b8d908339c4
4
- data.tar.gz: fe2bce7cfb97c14318f2cf63d65aa102d6e74ac6f01f12a600d2822856abf15c
3
+ metadata.gz: d437c19b7fc3feb724d4fa895fb7ef5e9cfc8501931a16f53d598fb9ef5afddc
4
+ data.tar.gz: 6340b2ba9b3991f922777310e43d7e256384f621b18c6598e422332b1940efce
5
5
  SHA512:
6
- metadata.gz: a6f15e1110e43582d2aba18a19ef16aa6844a85584d101c9c4c72de0f072941d31c9a42deae5b42802f03b7da3050b7279e3a5b07b9ba9a3d4e76251d9293d24
7
- data.tar.gz: 72fbe0da3afe6979150c16f5944fe140439ea552009aef1c84164d9cebed73d40a5639ed346e4e57029ba8c39087f78af7358f121d36084ed1715d7a96e3fb4d
6
+ metadata.gz: cdb698a1ee148f598fbf2ecf93ddc47867d797fd0f72a33bdc44547dfe5cec846984eaaba71e69c198ce3423c64bfe8ff830313b770980624a8cff164b0b431d
7
+ data.tar.gz: 95c417612dd655203b05d3323188536f453fa03ba4f412e84491dc23bdca90397f9ae3d99cdfd1899f06e23632282efa6f74251a9e93da8436d1255aa74431df
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,7 +16,9 @@ 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,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
 
@@ -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.6'
4
+ VERSION = '0.16.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: 0.2.6
4
+ version: 0.16.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: 2021-03-19 00:00:00.000000000 Z
11
+ date: 2021-03-23 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