Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure outbound tracing headers take precedence #683

Merged
merged 3 commits into from
Feb 23, 2018
Merged

Ensure outbound tracing headers take precedence #683

merged 3 commits into from
Feb 23, 2018

Conversation

yurishkuro
Copy link
Contributor

@yurishkuro yurishkuro commented Feb 17, 2018

Resolves #682

Signed-off-by: Yuri Shkuro ys@uber.com

cc @Yu-Xie

@codecov
Copy link

codecov bot commented Feb 17, 2018

Codecov Report

Merging #683 into dev will increase coverage by 0.68%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #683      +/-   ##
==========================================
+ Coverage   86.55%   87.24%   +0.68%     
==========================================
  Files          39       39              
  Lines        3958     3959       +1     
==========================================
+ Hits         3426     3454      +28     
+ Misses        410      386      -24     
+ Partials      122      119       -3
Impacted Files Coverage Δ
tracing.go 88.42% <100%> (+1.76%) ⬆️
relay.go 83.88% <0%> (-1.32%) ⬇️
outbound.go 79.88% <0%> (-0.58%) ⬇️
connection.go 85.13% <0%> (+3.27%) ⬆️
tracing_keys.go 88.57% <0%> (+5.71%) ⬆️
mex.go 79.06% <0%> (+6.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0b1e58...8b7d117. Read the comment docs.

Signed-off-by: Yuri Shkuro <ys@uber.com>
@yurishkuro
Copy link
Contributor Author

keep forgetting that dev is the trunk branch

// Some applications propagate all inbound application headers to outbound calls (issue #682).
// If those headers include tracing headers we want to make sure to keep the new tracing headers.
if _, ok := newHeaders[k]; !ok {
newHeaders[k] = v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we didn't get coverage from the added test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know. When I run this locally it shows the line as covered:

$ go test -v -run TestTracingSpanAttributes -coverprofile cover.out
=== RUN   TestTracingSpanAttributes
--- PASS: TestTracingSpanAttributes (0.00s)
PASS
coverage: 48.8% of statements
ok  	github.com/uber/tchannel-go	0.042s

$ go tool cover -html=cover.out

image

I added another check to ensure that non-tracing headers are propagated.

tracing_test.go Outdated
customAppHeaderKey = "futurama"
customAppHeaderExpectedValue = "simpsons"
)
var customAppHeaderValue atomic.Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use uber-go/atomic in tchannel, which has a atomic.String that you could use here

tracing_test.go Outdated
// will override them (https://github.com/uber/tchannel-go/issues/682).
headers := make(map[string]string)
assert.NoError(t, tracer.Inject(span.Context(), opentracing.TextMap, opentracing.TextMapCarrier(headers)))
tracingHeaders := map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be named the opposite? this seems like headers, while the thing named headers seems more like tracingHeaders

tracing_test.go Outdated
customAppHeaderKey: customAppHeaderExpectedValue,
}
for k, v := range headers {
tracingHeaders["$tracing$"+k] = v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you set the value to something incorrect, like dummy so we know that it was replaced

@yurishkuro yurishkuro merged commit 75acd77 into dev Feb 23, 2018
@yurishkuro yurishkuro deleted the fix-682 branch February 23, 2018 03:14
@Yu-Xie
Copy link

Yu-Xie commented Mar 6, 2018

Thanks Yuri for fixing this! Do we have a plan to release?

@prashantv
Copy link
Contributor

@Yu-Xie This is now released in the latest release:
https://github.com/uber/tchannel-go/releases/tag/v1.10.0

@Yu-Xie
Copy link

Yu-Xie commented Apr 5, 2018

Thanks @prashantv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants