lightstep 0.12.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +32 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +48 -0
- data/CHANGELOG.md +45 -0
- data/CONTRIBUTING.md +58 -0
- data/Gemfile.lock +52 -0
- data/Makefile +3 -3
- data/README.md +4 -1
- data/example.rb +2 -2
- data/examples/rack/inject_extract.rb +1 -1
- data/lib/lightstep.rb +4 -0
- data/lib/lightstep/propagation.rb +25 -0
- data/lib/lightstep/propagation/b3_propagator.rb +29 -0
- data/lib/lightstep/propagation/lightstep_propagator.rb +127 -0
- data/lib/lightstep/reporter.rb +14 -9
- data/lib/lightstep/scope.rb +23 -0
- data/lib/lightstep/scope_manager.rb +54 -0
- data/lib/lightstep/span.rb +44 -19
- data/lib/lightstep/span_context.rb +36 -3
- data/lib/lightstep/tracer.rb +131 -100
- data/lib/lightstep/transport/base.rb +0 -3
- data/lib/lightstep/transport/http_json.rb +74 -23
- data/lib/lightstep/version.rb +1 -1
- data/lightstep.gemspec +8 -4
- metadata +26 -17
- data/circle.yml +0 -3
@@ -4,53 +4,104 @@ require 'lightstep/transport/base'
|
|
4
4
|
module LightStep
|
5
5
|
module Transport
|
6
6
|
# HTTPJSON is a transport that sends reports via HTTP in JSON format.
|
7
|
-
# It is thread-safe
|
8
|
-
# in the queue will be copied and sent in duplicate.
|
9
|
-
#
|
10
|
-
# When forking, you should first `disable` the tracer, then `enable` it from
|
11
|
-
# within the fork (and in the parent post-fork). See
|
12
|
-
# `examples/fork_children/main.rb` for an example.
|
7
|
+
# It is thread-safe.
|
13
8
|
class HTTPJSON < Base
|
14
|
-
LIGHTSTEP_HOST =
|
9
|
+
LIGHTSTEP_HOST = 'collector.lightstep.com'.freeze
|
15
10
|
LIGHTSTEP_PORT = 443
|
16
11
|
|
17
|
-
ENCRYPTION_TLS = 'tls'
|
18
|
-
ENCRYPTION_NONE = 'none'
|
12
|
+
ENCRYPTION_TLS = 'tls'.freeze
|
13
|
+
ENCRYPTION_NONE = 'none'.freeze
|
19
14
|
|
15
|
+
REPORTS_API_ENDPOINT = '/api/v0/reports'.freeze
|
16
|
+
HEADER_ACCESS_TOKEN = 'LightStep-Access-Token'.freeze
|
17
|
+
|
18
|
+
##
|
20
19
|
# Initialize the transport
|
21
|
-
#
|
20
|
+
#
|
21
|
+
# @param host [String] host of the domain to the endpoint to push data
|
22
22
|
# @param port [Numeric] port on which to connect
|
23
23
|
# @param verbose [Numeric] verbosity level. Right now 0-3 are supported
|
24
24
|
# @param encryption [ENCRYPTION_TLS, ENCRYPTION_NONE] kind of encryption to use
|
25
25
|
# @param access_token [String] access token for LightStep server
|
26
|
-
# @
|
27
|
-
|
26
|
+
# @param ssl_verify_peer [Boolean]
|
27
|
+
# @param open_timeout [Integer]
|
28
|
+
# @param read_timeout [Integer]
|
29
|
+
# @param continue_timeout [Integer]
|
30
|
+
# @param keep_alive_timeout [Integer]
|
31
|
+
# @param logger [Logger]
|
32
|
+
#
|
33
|
+
def initialize(
|
34
|
+
host: LIGHTSTEP_HOST,
|
35
|
+
port: LIGHTSTEP_PORT,
|
36
|
+
verbose: 0,
|
37
|
+
encryption: ENCRYPTION_TLS,
|
38
|
+
access_token:,
|
39
|
+
ssl_verify_peer: true,
|
40
|
+
open_timeout: 20,
|
41
|
+
read_timeout: 20,
|
42
|
+
continue_timeout: nil,
|
43
|
+
keep_alive_timeout: 2,
|
44
|
+
logger: nil
|
45
|
+
)
|
28
46
|
@host = host
|
29
47
|
@port = port
|
30
48
|
@verbose = verbose
|
31
49
|
@encryption = encryption
|
50
|
+
@ssl_verify_peer = ssl_verify_peer
|
51
|
+
@open_timeout = open_timeout.to_i
|
52
|
+
@read_timeout = read_timeout.to_i
|
53
|
+
@continue_timeout = continue_timeout
|
54
|
+
@keep_alive_timeout = keep_alive_timeout.to_i
|
32
55
|
|
33
|
-
raise Tracer::ConfigurationError,
|
34
|
-
raise Tracer::ConfigurationError,
|
56
|
+
raise Tracer::ConfigurationError, 'access_token must be a string' unless access_token.is_a?(String)
|
57
|
+
raise Tracer::ConfigurationError, 'access_token cannot be blank' if access_token.empty?
|
35
58
|
@access_token = access_token
|
59
|
+
@logger = logger || LightStep.logger
|
36
60
|
end
|
37
61
|
|
62
|
+
##
|
38
63
|
# Queue a report for sending
|
64
|
+
#
|
39
65
|
def report(report)
|
40
|
-
|
66
|
+
@logger.info report if @verbose >= 3
|
67
|
+
|
68
|
+
req = build_request(report)
|
69
|
+
res = connection.request(req)
|
70
|
+
|
71
|
+
@logger.info res.to_s if @verbose >= 3
|
72
|
+
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
41
77
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
78
|
+
##
|
79
|
+
# @param [Hash] report
|
80
|
+
# @return [Net::HTTP::Post]
|
81
|
+
#
|
82
|
+
def build_request(report)
|
83
|
+
req = Net::HTTP::Post.new(REPORTS_API_ENDPOINT)
|
84
|
+
req[HEADER_ACCESS_TOKEN] = @access_token
|
46
85
|
req['Content-Type'] = 'application/json'
|
47
86
|
req['Connection'] = 'keep-alive'
|
48
87
|
req.body = report.to_json
|
49
|
-
|
50
|
-
|
51
|
-
puts res.to_s if @verbose >= 3
|
88
|
+
req
|
89
|
+
end
|
52
90
|
|
53
|
-
|
91
|
+
##
|
92
|
+
# @return [Net::HTTP]
|
93
|
+
#
|
94
|
+
def connection
|
95
|
+
unless @connection
|
96
|
+
@connection = ::Net::HTTP.new(@host, @port)
|
97
|
+
@connection.use_ssl = @encryption == ENCRYPTION_TLS
|
98
|
+
@connection.verify_mode = ::OpenSSL::SSL::VERIFY_NONE unless @ssl_verify_peer
|
99
|
+
@connection.open_timeout = @open_timeout
|
100
|
+
@connection.read_timeout = @read_timeout
|
101
|
+
@connection.continue_timeout = @continue_timeout
|
102
|
+
@connection.keep_alive_timeout = @keep_alive_timeout
|
103
|
+
end
|
104
|
+
@connection
|
54
105
|
end
|
55
106
|
end
|
56
107
|
end
|
data/lib/lightstep/version.rb
CHANGED
data/lightstep.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'lightstep/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'lightstep'
|
8
8
|
spec.version = LightStep::VERSION
|
9
|
-
spec.authors = ['
|
9
|
+
spec.authors = ['lightstep']
|
10
10
|
spec.email = ['support@lightstep.com']
|
11
11
|
|
12
12
|
spec.summary = 'LightStep OpenTracing Ruby bindings'
|
@@ -16,12 +16,16 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
+
spec.metadata = {
|
20
|
+
"changelog_uri" => "https://github.com/lightstep/lightstep-tracer-ruby/blob/master/CHANGELOG.md",
|
21
|
+
}
|
22
|
+
|
19
23
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
20
|
-
spec.add_dependency 'opentracing', '~> 0.
|
21
|
-
spec.add_development_dependency 'rake', '~>
|
24
|
+
spec.add_dependency 'opentracing', '~> 0.5.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
22
26
|
spec.add_development_dependency 'rack', '~> 2.0'
|
23
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
28
|
spec.add_development_dependency 'bump', '~> 0.5'
|
25
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
29
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
26
30
|
spec.add_development_dependency 'timecop', '~> 0.8.0'
|
27
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- lightstep
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.5.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:
|
40
|
+
version: 0.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: '0.16'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: '0.16'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: timecop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,16 +122,21 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.8.0
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- support@lightstep.com
|
128
128
|
executables: []
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".circleci/config.yml"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- CONTRIBUTING.md
|
134
138
|
- Gemfile
|
139
|
+
- Gemfile.lock
|
135
140
|
- LICENSE.txt
|
136
141
|
- Makefile
|
137
142
|
- README.md
|
@@ -141,14 +146,18 @@ files:
|
|
141
146
|
- benchmark/threading/thread_test.rb
|
142
147
|
- bin/console
|
143
148
|
- bin/setup
|
144
|
-
- circle.yml
|
145
149
|
- example.rb
|
146
150
|
- examples/fork_children/main.rb
|
147
151
|
- examples/rack/hello.rb
|
148
152
|
- examples/rack/inject_extract.rb
|
149
153
|
- lib/lightstep.rb
|
150
154
|
- lib/lightstep/global_tracer.rb
|
155
|
+
- lib/lightstep/propagation.rb
|
156
|
+
- lib/lightstep/propagation/b3_propagator.rb
|
157
|
+
- lib/lightstep/propagation/lightstep_propagator.rb
|
151
158
|
- lib/lightstep/reporter.rb
|
159
|
+
- lib/lightstep/scope.rb
|
160
|
+
- lib/lightstep/scope_manager.rb
|
152
161
|
- lib/lightstep/span.rb
|
153
162
|
- lib/lightstep/span_context.rb
|
154
163
|
- lib/lightstep/tracer.rb
|
@@ -162,8 +171,9 @@ files:
|
|
162
171
|
homepage: https://github.com/lightstep/lightstep-tracer-ruby
|
163
172
|
licenses:
|
164
173
|
- MIT
|
165
|
-
metadata:
|
166
|
-
|
174
|
+
metadata:
|
175
|
+
changelog_uri: https://github.com/lightstep/lightstep-tracer-ruby/blob/master/CHANGELOG.md
|
176
|
+
post_install_message:
|
167
177
|
rdoc_options: []
|
168
178
|
require_paths:
|
169
179
|
- lib
|
@@ -178,9 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
188
|
- !ruby/object:Gem::Version
|
179
189
|
version: '0'
|
180
190
|
requirements: []
|
181
|
-
|
182
|
-
|
183
|
-
signing_key:
|
191
|
+
rubygems_version: 3.0.3
|
192
|
+
signing_key:
|
184
193
|
specification_version: 4
|
185
194
|
summary: LightStep OpenTracing Ruby bindings
|
186
195
|
test_files: []
|
data/circle.yml
DELETED