jaeger-client 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +32 -0
- data/Rakefile +4 -1
- data/bin/console +3 -3
- data/jaeger-client.gemspec +9 -5
- data/lib/jaeger/client.rb +1 -0
- data/lib/jaeger/client/carrier.rb +3 -6
- data/lib/jaeger/client/collector.rb +2 -2
- data/lib/jaeger/client/span.rb +2 -2
- data/lib/jaeger/client/span_context.rb +3 -3
- data/lib/jaeger/client/trace_id.rb +1 -1
- data/lib/jaeger/client/tracer.rb +14 -11
- data/lib/jaeger/client/udp_sender.rb +23 -1
- data/lib/jaeger/client/udp_sender/transport.rb +2 -1
- data/lib/jaeger/client/version.rb +5 -0
- data/script/create_trace +20 -14
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75c88fcea8c5fa02b502e8c2c6cb3838a246e714
|
4
|
+
data.tar.gz: 12d8f676f98d486d1b9db5e73c7dc757e46477a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eedd11ef42e96094a128fd32df3c3bf5a152d498dd09933a667930caa5af7f287c00bddf9524cc87429898ff78a7e3cc1d2da1b38f560be9f3731bfe0f42ac1
|
7
|
+
data.tar.gz: c478b9e68a708fd6a093d08b38c844136535a4b3723dd717392dd7ce5852ac01ba2a6b0948f954924cbe9a46daf6ea9e13f8d87242bb58a647fb44a0d0695d6f
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'thrift/**/*'
|
6
|
+
|
7
|
+
Style/Documentation:
|
8
|
+
Enabled: no
|
9
|
+
|
10
|
+
Style/IfUnlessModifier:
|
11
|
+
Enabled: no
|
12
|
+
|
13
|
+
RSpec/NestedGroups:
|
14
|
+
Max: 4
|
15
|
+
|
16
|
+
RSpec/ExampleLength:
|
17
|
+
Enabled: no
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Enabled: no
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
Enabled: no
|
24
|
+
|
25
|
+
Metrics/AbcSize:
|
26
|
+
Enabled: no
|
27
|
+
|
28
|
+
Lint/UnusedMethodArgument:
|
29
|
+
Enabled: no
|
30
|
+
|
31
|
+
Metrics/LineLength:
|
32
|
+
Max: 120
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'jaeger/client'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "jaeger/client"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/jaeger-client.gemspec
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
+
require 'jaeger/client/version'
|
6
|
+
|
5
7
|
Gem::Specification.new do |spec|
|
6
8
|
spec.name = 'jaeger-client'
|
7
|
-
spec.version =
|
9
|
+
spec.version = Jaeger::Client::VERSION
|
8
10
|
spec.authors = ['SaleMove TechMovers']
|
9
11
|
spec.email = ['techmovers@salemove.com']
|
10
12
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
+
spec.summary = 'OpenTracing Tracer implementation for Jaeger in Ruby'
|
14
|
+
spec.description = ''
|
13
15
|
spec.homepage = ''
|
14
16
|
spec.license = 'MIT'
|
15
17
|
|
@@ -22,6 +24,8 @@ Gem::Specification.new do |spec|
|
|
22
24
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
23
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
28
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.24.0'
|
25
29
|
|
26
30
|
spec.add_dependency 'opentracing', '~> 0.3'
|
27
31
|
spec.add_dependency 'thrift'
|
data/lib/jaeger/client.rb
CHANGED
@@ -7,21 +7,18 @@ module Jaeger
|
|
7
7
|
# [] retrieves a value by the given key
|
8
8
|
# @param key [String] key to retrieve the value
|
9
9
|
# @return [String] the desired value
|
10
|
-
def [](key)
|
11
|
-
end
|
10
|
+
def [](key); end
|
12
11
|
|
13
12
|
# []= sets the value for the given key
|
14
13
|
# @param key [String] key to set
|
15
14
|
# @param value [String] value to set
|
16
|
-
def []=(key, value)
|
17
|
-
end
|
15
|
+
def []=(key, value); end
|
18
16
|
|
19
17
|
# each iterates over every key-value pair in the carrier
|
20
18
|
# @yield [key, value]
|
21
19
|
# @yieldparam key [String] the key of the tuple
|
22
20
|
# @yieldparam value [String] the value of the tuple
|
23
|
-
def each(&block)
|
24
|
-
end
|
21
|
+
def each(&block); end
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -33,14 +33,14 @@ module Jaeger
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def build_tags(tags)
|
36
|
-
tags.map {|name, value| build_tag(name, value)}
|
36
|
+
tags.map { |name, value| build_tag(name, value) }
|
37
37
|
end
|
38
38
|
|
39
39
|
def build_logs(logs)
|
40
40
|
logs.map do |timestamp:, fields:|
|
41
41
|
Jaeger::Thrift::Log.new(
|
42
42
|
'timestamp' => (timestamp.to_f * 1_000_000).to_i,
|
43
|
-
'fields' => fields.map {|name, value| build_tag(name, value)}
|
43
|
+
'fields' => fields.map { |name, value| build_tag(name, value) }
|
44
44
|
)
|
45
45
|
end
|
46
46
|
end
|
data/lib/jaeger/client/span.rb
CHANGED
@@ -52,7 +52,7 @@ module Jaeger
|
|
52
52
|
# @param timestamp [Time] time of the log
|
53
53
|
# @param fields [Hash] Additional information to log
|
54
54
|
def log(timestamp: Time.now, **fields)
|
55
|
-
@logs << {timestamp: timestamp, fields: fields}
|
55
|
+
@logs << { timestamp: timestamp, fields: fields }
|
56
56
|
end
|
57
57
|
|
58
58
|
# Finish the {Span}
|
@@ -66,7 +66,7 @@ module Jaeger
|
|
66
66
|
|
67
67
|
def build_binary_annotations
|
68
68
|
@tags.map do |name, value|
|
69
|
-
{key: name, value: value.to_s}
|
69
|
+
{ key: name, value: value.to_s }
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -37,9 +37,9 @@ module Jaeger
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def to_s
|
40
|
-
"#<SpanContext @span_id=#{span_id.to_s(16)} "
|
41
|
-
"@parent_id=#{parent_id.to_s(16)} "
|
42
|
-
"@trace_id=#{trace_id.to_s(16)} "
|
40
|
+
"#<SpanContext @span_id=#{span_id.to_s(16)} " \
|
41
|
+
"@parent_id=#{parent_id.to_s(16)} " \
|
42
|
+
"@trace_id=#{trace_id.to_s(16)} " \
|
43
43
|
"@flags=#{flags}>"
|
44
44
|
end
|
45
45
|
end
|
data/lib/jaeger/client/tracer.rb
CHANGED
@@ -72,21 +72,24 @@ module Jaeger
|
|
72
72
|
def parse_context(trace)
|
73
73
|
return nil if !trace || trace == ''
|
74
74
|
|
75
|
-
trace_arguments = trace.split(':').map {|arg| arg.to_i(16)}
|
75
|
+
trace_arguments = trace.split(':').map { |arg| arg.to_i(16) }
|
76
76
|
return nil if trace_arguments.size != 4
|
77
77
|
|
78
78
|
trace_id, span_id, parent_id, flags = trace_arguments
|
79
|
+
return nil if trace_id.zero? || span_id.zero?
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
SpanContext.new(
|
82
|
+
trace_id: to_signed_int(trace_id, 64),
|
83
|
+
parent_id: to_signed_int(parent_id, 64),
|
84
|
+
span_id: to_signed_int(span_id, 64),
|
85
|
+
flags: flags
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_signed_int(num, bits)
|
90
|
+
# Using two's complement
|
91
|
+
mask = 2**(bits - 1)
|
92
|
+
(num & ~mask) - (num & mask)
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative './udp_sender/transport'
|
2
2
|
require 'jaeger/thrift/agent'
|
3
|
+
require 'socket'
|
3
4
|
require 'thread'
|
4
5
|
|
5
6
|
module Jaeger
|
@@ -10,6 +11,27 @@ module Jaeger
|
|
10
11
|
@collector = collector
|
11
12
|
@flush_interval = flush_interval
|
12
13
|
|
14
|
+
@tags = [
|
15
|
+
Jaeger::Thrift::Tag.new(
|
16
|
+
'key' => 'jaeger.version',
|
17
|
+
'vType' => Jaeger::Thrift::TagType::STRING,
|
18
|
+
'vStr' => 'Ruby-' + Jaeger::Client::VERSION
|
19
|
+
),
|
20
|
+
Jaeger::Thrift::Tag.new(
|
21
|
+
'key' => 'hostname',
|
22
|
+
'vType' => Jaeger::Thrift::TagType::STRING,
|
23
|
+
'vStr' => Socket.gethostname
|
24
|
+
)
|
25
|
+
]
|
26
|
+
ipv4 = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }
|
27
|
+
unless ipv4.nil?
|
28
|
+
@tags << Jaeger::Thrift::Tag.new(
|
29
|
+
'key' => 'ip',
|
30
|
+
'vType' => Jaeger::Thrift::TagType::STRING,
|
31
|
+
'vStr' => ipv4.ip_address
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
13
35
|
transport = Transport.new(host, port)
|
14
36
|
protocol = ::Thrift::CompactProtocol.new(transport)
|
15
37
|
@client = Jaeger::Thrift::Agent::Client.new(protocol)
|
@@ -38,7 +60,7 @@ module Jaeger
|
|
38
60
|
batch = Jaeger::Thrift::Batch.new(
|
39
61
|
'process' => Jaeger::Thrift::Process.new(
|
40
62
|
'serviceName' => @service_name,
|
41
|
-
'tags' =>
|
63
|
+
'tags' => @tags
|
42
64
|
),
|
43
65
|
'spans' => thrift_spans
|
44
66
|
)
|
@@ -20,6 +20,7 @@ module Jaeger
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def open; end
|
23
|
+
|
23
24
|
def close; end
|
24
25
|
|
25
26
|
private
|
@@ -29,7 +30,7 @@ module Jaeger
|
|
29
30
|
@socket.flush
|
30
31
|
rescue Errno::ECONNREFUSED
|
31
32
|
warn 'Unable to connect to Jaeger Agent'
|
32
|
-
rescue => e
|
33
|
+
rescue StandardError => e
|
33
34
|
warn "Unable to send spans: #{e.message}"
|
34
35
|
end
|
35
36
|
end
|
data/script/create_trace
CHANGED
@@ -11,24 +11,31 @@ port = ENV['JAEGER_HOST'] || 6831
|
|
11
11
|
tracer1 = Jaeger::Client.build(host: host, port: port.to_i, service_name: 'test-service', flush_interval: 1)
|
12
12
|
tracer2 = Jaeger::Client.build(host: host, port: port.to_i, service_name: 'downstream-service', flush_interval: 1)
|
13
13
|
|
14
|
-
outer_span = tracer1.start_span(
|
15
|
-
'
|
16
|
-
}
|
14
|
+
outer_span = tracer1.start_span(
|
15
|
+
'receive request',
|
16
|
+
tags: { 'span.kind' => 'server' }
|
17
|
+
)
|
17
18
|
sleep 0.1
|
18
19
|
outer_span.log(event: 'woop di doop', count: 5)
|
19
20
|
sleep 1
|
20
21
|
|
21
|
-
inner_span = tracer1.start_span(
|
22
|
-
'
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
inner_span = tracer1.start_span(
|
23
|
+
'fetch info from downstream',
|
24
|
+
child_of: outer_span,
|
25
|
+
tags: {
|
26
|
+
'span.kind' => 'client',
|
27
|
+
'peer.service' => 'downstream-service',
|
28
|
+
'peer.ipv4' => '6.6.6.6',
|
29
|
+
'peer.port' => 443
|
30
|
+
}
|
31
|
+
)
|
27
32
|
sleep 0.3 # emulate network delay
|
28
33
|
|
29
|
-
downstream_span = tracer2.start_span(
|
30
|
-
'
|
31
|
-
|
34
|
+
downstream_span = tracer2.start_span(
|
35
|
+
'downstream operation',
|
36
|
+
child_of: inner_span,
|
37
|
+
tags: { 'span.kind' => 'server' }
|
38
|
+
)
|
32
39
|
sleep 0.5
|
33
40
|
downstream_span.finish
|
34
41
|
|
@@ -42,5 +49,4 @@ outer_span.finish
|
|
42
49
|
tracer1.stop
|
43
50
|
tracer2.stop
|
44
51
|
|
45
|
-
puts
|
46
|
-
|
52
|
+
puts 'Finished'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jaeger-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.54.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.54.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.24.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.24.0
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: opentracing
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +117,7 @@ extra_rdoc_files: []
|
|
89
117
|
files:
|
90
118
|
- ".gitignore"
|
91
119
|
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
92
121
|
- ".travis.yml"
|
93
122
|
- Gemfile
|
94
123
|
- LICENSE.txt
|
@@ -106,6 +135,7 @@ files:
|
|
106
135
|
- lib/jaeger/client/tracer.rb
|
107
136
|
- lib/jaeger/client/udp_sender.rb
|
108
137
|
- lib/jaeger/client/udp_sender/transport.rb
|
138
|
+
- lib/jaeger/client/version.rb
|
109
139
|
- script/create_trace
|
110
140
|
- thrift/agent.thrift
|
111
141
|
- thrift/gen-rb/jaeger/thrift/agent.rb
|