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 +4 -4
- data/README.md +47 -6
- data/lib/uptrace.rb +3 -1
- data/lib/uptrace/client.rb +4 -2
- data/lib/uptrace/dsn.rb +1 -1
- data/lib/uptrace/trace/exporter.rb +10 -0
- data/lib/uptrace/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d437c19b7fc3feb724d4fa895fb7ef5e9cfc8501931a16f53d598fb9ef5afddc
|
4
|
+
data.tar.gz: 6340b2ba9b3991f922777310e43d7e256384f621b18c6598e422332b1940efce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
##
|
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
|
-
|
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
|
-
|
19
|
-
|
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
|
-
|
62
|
+
Please see [uptrace-ruby documentation](https://docs.uptrace.dev/ruby/) for more details.
|
data/lib/uptrace.rb
CHANGED
data/lib/uptrace/client.rb
CHANGED
@@ -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
@@ -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
|
data/lib/uptrace/version.rb
CHANGED
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.
|
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-
|
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.
|
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.
|
40
|
+
version: 0.16.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: zstd-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|