Skip to content

Commit

Permalink
Merge pull request openzipkin-attic#2 from Oscil8/finagle-thrift-v1.3
Browse files Browse the repository at this point in the history
Upgrade to finagle-thrift v1.3.x
  • Loading branch information
Oscil8 committed Nov 18, 2014
2 parents 94f588c + e7bfa27 commit 69da396
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

v0.3.0 - Upgrade to finagle-thrift v1.3.1

Supporting finagle-thrift v1.2.0
v0.1.0 initial implementation of client trace code
v0.2.3 minor gem cleanup, travis support; fix raise on DNS
v0.2.2 fix serialization of response code
v0.2.1 add annotation for http uri, method, response code
v0.2.0 added the optional service_name parameter, annotate correctly
v0.2.1 add annotation for http uri, method, response code
v0.2.2 fix serialization of response code
v0.2.3 minor gem cleanup, travis support; fix raise on DNS

TODO:
v0.3.0 - Upgrade to finagle-thrift v1.3.0
v0.1.0 initial implementation of client trace code
2 changes: 1 addition & 1 deletion faraday-zipkin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "faraday", ">= 0.8"
spec.add_dependency "thrift", "~> 0.9.0"
spec.add_dependency "finagle-thrift", "~> 1.2.0"
spec.add_dependency "finagle-thrift", "~> 1.3.1"

spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
8 changes: 5 additions & 3 deletions lib/faraday-zipkin/trace_headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class TraceHeaders < ::Faraday::Middleware
:trace_id => "X-B3-TraceId",
:parent_id => "X-B3-ParentSpanId",
:span_id => "X-B3-SpanId",
:sampled => "X-B3-Sampled"
:sampled => "X-B3-Sampled",
:flags => "X-B3-Flags"
}.freeze

def initialize(app, service_name=nil)
Expand All @@ -24,8 +25,9 @@ def call(env)
service_name = @service_name || url.host.split('.').first # default to url-derived service name
endpoint = ::Trace::Endpoint.new(host_ip_for(url.host), url.port, service_name)

trace_id = ::Trace.id
::Trace.push(trace_id.next_id) do
::Trace.unwind do
trace_id = ::Trace.id
::Trace.push(trace_id.next_id)
B3_HEADERS.each do |method, header|
env[:request_headers][header] = ::Trace.id.send(method).to_s
end
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday-zipkin/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Faraday
module Zipkin
VERSION = "0.2.3"
VERSION = "0.3.0"
end
end
4 changes: 3 additions & 1 deletion spec/zipkin_trace_headers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def expect_tracing
HEX_REGEX = RUBY_VERSION >= "1.9.2" ? '\h' : '[0-9a-fA-F]'

context 'with tracing id' do
let(:trace_id) { ::Trace::TraceId.new(1, 2, 3, true) }
let(:trace_id) { ::Trace::TraceId.new(1, 2, 3, true, ::Trace::Flags::DEBUG) }

it 'sets the X-B3 request headers' do
expect_tracing
Expand All @@ -75,6 +75,7 @@ def expect_tracing
expect(result[:request_headers]['X-B3-SpanId']).not_to eq('0000000000000003')
expect(result[:request_headers]['X-B3-SpanId']).to match(/^#{HEX_REGEX}{16}$/)
expect(result[:request_headers]['X-B3-Sampled']).to eq('true')
expect(result[:request_headers]['X-B3-Flags']).to eq('1')
end
end

Expand All @@ -88,6 +89,7 @@ def expect_tracing
expect(result[:request_headers]['X-B3-ParentSpanId']).to match(/^#{HEX_REGEX}{16}$/)
expect(result[:request_headers]['X-B3-SpanId']).to match(/^#{HEX_REGEX}{16}$/)
expect(result[:request_headers]['X-B3-Sampled']).to match(/(true|false)/)
expect(result[:request_headers]['X-B3-Flags']).to eq('0')
end
end

Expand Down

0 comments on commit 69da396

Please sign in to comment.