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

Support -H, -B, --jaeger for headers and baggage #121

Merged
merged 17 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address nits
  • Loading branch information
kriskowal committed Nov 2, 2016
commit d2515f2f969b087d2bcb7f077e0e52e5deff312c
28 changes: 13 additions & 15 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,32 @@ func verifyBaggage(ctx context.Context) error {
val := span.BaggageItem("baggagekey")
if val == "" {
return errors.New("missing baggage")
} else if val != "baggagevalue" {
}
if val != "baggagevalue" {
return errors.New("unexpected baggage")
}
return nil
}

func verifyThriftHeaders(ctx thrift.Context) error {
headers := ctx.Headers()
if val, ok := headers["headerkey"]; ok {
if val != "headervalue" {
return errors.New("unexpected header")
}
} else {
return errors.New("missing header")
}

return nil
val, ok := headers["headerkey"]
return verifyHeader(val, ok)
}

func verifyYARPCHeaders(reqMeta yarpc.ReqMeta) error {
headers := reqMeta.Headers()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we instead have a single veriyHeaders(headers map[string]string) error method, and pass in the ctx.Headers() or reqMeta.Headers()? That way we can avoid the duplication 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.

YARPC does not expose Headers().Items().

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I forgot that yarpc headers are not an actual map, this is fine then.

if val, ok := headers.Get("headerkey"); ok {
if val != "headervalue" {
return errors.New("unexpected header")
}
} else {
val, ok := headers.Get("headerkey")
return verifyHeader(val, ok)
}

func verifyHeader(val string, ok bool) error {
if !ok {
return errors.New("missing header")
}
if val != "headervalue" {
return errors.New("unexpected header")
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion transport/tchannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewTChannel(opts TChannelOptions) (Transport, error) {
}

callerName := opts.SourceService
if cn, ok := opts.TransportOpts["cn"]; ok && cn != "" {
if cn, ok := opts.TransportOpts["cn"]; ok {
callerName = cn
}

Expand Down
5 changes: 5 additions & 0 deletions transport/tchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"testing"
"time"

"github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/tchannel-go"
Expand Down Expand Up @@ -174,6 +175,10 @@ func TestTChannelCallSuccessRaw(t *testing.T) {
for _, tt := range tests {
var lastSpan uint64
testutils.RegisterFunc(svr, "echo", func(ctx context.Context, args *raw.Args) (*raw.Res, error) {

span := opentracing.SpanFromContext(ctx)
assert.Nil(t, span, "the context should not have a span")

lastSpan = tchannel.CurrentSpan(ctx).TraceID()

assert.Equal(t, tt.arg2, args.Arg2, "Arg2 mismatch")
Expand Down