-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use simplified zipkin v2 span format
Libraries are slowly migrating over to a next version span format. The new format is a lot easier to implement and understand. More info: openzipkin/zipkin#1499
- Loading branch information
Showing
8 changed files
with
146 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Zipkin::Endpoint do | ||
let(:span) { Zipkin::Span.new(nil, 'operation_name', nil) } | ||
|
||
shared_examples 'a rpc endpoint' do | ||
it 'returns nil if no peer info' do | ||
expect(remote_endpoint(span)).to eq(nil) | ||
end | ||
|
||
it 'includes service name' do | ||
service_name = 'service-name' | ||
span.set_tag('peer.service', service_name) | ||
expect(remote_endpoint(span)).to include(serviceName: service_name) | ||
end | ||
|
||
it 'includes ipv4 address' do | ||
ipv4 = '8.7.6.5' | ||
span.set_tag('peer.ipv4', ipv4) | ||
expect(remote_endpoint(span)).to include(ipv4: ipv4) | ||
end | ||
|
||
it 'includes ipv6 address' do | ||
ipv6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334' | ||
span.set_tag('peer.ipv6', ipv6) | ||
expect(remote_endpoint(span)).to include(ipv6: ipv6) | ||
end | ||
|
||
it 'includes port' do | ||
port = 3000 | ||
span.set_tag('peer.port', port) | ||
expect(remote_endpoint(span)).to include(port: port) | ||
end | ||
end | ||
|
||
describe '.remote_endpoint' do | ||
context 'when span kind is undefined' do | ||
it_behaves_like 'a rpc endpoint' | ||
end | ||
|
||
context 'when span kind is server' do | ||
before { span.set_tag('span.kind', 'server') } | ||
|
||
it_behaves_like 'a rpc endpoint' | ||
end | ||
|
||
context 'when span kind is client' do | ||
before { span.set_tag('span.kind', 'client') } | ||
|
||
it_behaves_like 'a rpc endpoint' | ||
end | ||
|
||
context 'when span kind is producer' do | ||
before { span.set_tag('span.kind', 'producer') } | ||
|
||
it 'returns broker as service name' do | ||
expect(remote_endpoint(span)).to eq(serviceName: 'broker') | ||
end | ||
end | ||
|
||
context 'when span kind is consumer' do | ||
before { span.set_tag('span.kind', 'consumer') } | ||
|
||
it 'returns broker as service name' do | ||
expect(remote_endpoint(span)).to eq(serviceName: 'broker') | ||
end | ||
end | ||
|
||
context 'when unknown span kind' do | ||
before { span.set_tag('span.kind', 'something-else') } | ||
|
||
it 'returns nil' do | ||
expect(remote_endpoint(span)).to eq(nil) | ||
end | ||
end | ||
end | ||
|
||
def remote_endpoint(span) | ||
described_class.remote_endpoint(span) | ||
end | ||
end |