1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/env ruby
#require 'bundler'
#Bundler.setup
require 'jaeger/client'
host = ENV['JAEGER_HOST'] || '127.0.0.1'
port = ENV['JAEGER_HOST'] || 6831
tracer1 = Jaeger::Client.build(host: host, port: port.to_i, service_name: 'test-service', flush_interval: 1)
tracer2 = Jaeger::Client.build(host: host, port: port.to_i, service_name: 'downstream-service', flush_interval: 1)
outer_span = tracer1.start_span(
'receive request',
tags: { 'span.kind' => 'server' }
)
sleep 0.1
outer_span.log_kv(event: 'woop di doop', count: 5)
sleep 1
inner_span = tracer1.start_span(
'fetch info from downstream',
child_of: outer_span,
tags: {
'span.kind' => 'client',
'peer.service' => 'downstream-service',
'peer.ipv4' => '6.6.6.6',
'peer.port' => 443
}
)
inner_span.set_tag('error', false)
sleep 0.3 # emulate network delay
downstream_span = tracer2.start_span(
'downstream operation',
child_of: inner_span,
tags: { 'span.kind' => 'server' }
)
sleep 0.5
downstream_span.finish
sleep 0.2 # emulate network delay
inner_span.finish
sleep 0.1 # doing something with fetched info
outer_span.finish
sleep 2
puts 'Finished'
|