Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Add baggage to B3 codec #319

Merged
merged 9 commits into from
Mar 23, 2019
Merged

Conversation

pavolloffay
Copy link
Member

Signed-off-by: Pavol Loffay <[email protected]>
@ghost ghost assigned pavolloffay Jun 5, 2018
@ghost ghost added the review label Jun 5, 2018
return Propagator{enableBaggage: true, baggagePrefix: "baggage-"}
}

// NewZipkinB3HTTPHeaderPropagator creates a Propagator for extracting and injecting
Copy link

Choose a reason for hiding this comment

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

comment on exported function NewZipkinB3HTTPHeaderPropagatorWithBaggage should be of the form "NewZipkinB3HTTPHeaderPropagatorWithBaggage ..."

@@ -66,6 +81,7 @@ func (p Propagator) Extract(abstractCarrier interface{}) (jaeger.SpanContext, er
var spanID uint64
var parentID uint64
sampled := false
var baggage map[string]string = nil
Copy link

Choose a reason for hiding this comment

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

should drop = nil from declaration of var baggage; it is the zero value

@@ -24,12 +24,21 @@ import (
)

// Propagator is an Injector and Extractor
type Propagator struct{}
type Propagator struct{
Copy link

Choose a reason for hiding this comment

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

File is not goimports-ed

)

var (
rootSampledHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "1",
"x-b3-spanid": "2",
"x-b3-sampled": "1",
"baggage-foo": "bar",
Copy link

Choose a reason for hiding this comment

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

File is not goimports-ed

Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

The same question like in java imp jaegertracing/jaeger-client-java#438 (comment). Should it be enabled by default? should it contain enable flag?

@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #319 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #319      +/-   ##
==========================================
+ Coverage   87.31%   87.39%   +0.07%     
==========================================
  Files          54       54              
  Lines        3011     3030      +19     
==========================================
+ Hits         2629     2648      +19     
  Misses        271      271              
  Partials      111      111
Impacted Files Coverage Δ
zipkin/propagation.go 93.22% <100%> (+2.31%) ⬆️
config/options.go 100% <0%> (ø) ⬆️
config/config.go 93.24% <0%> (+0.04%) ⬆️

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 6e798e7...d447887. Read the comment docs.

Signed-off-by: Pavol Loffay <[email protected]>

// NewZipkinB3HTTPHeaderPropagator creates a Propagator for extracting and injecting
// Zipkin HTTP B3 headers into SpanContexts.
// Zipkin HTTP B3 headers into SpanContexts. Baggage is by default enabled and uses prefix
// 'baggage-'.
func NewZipkinB3HTTPHeaderPropagator() Propagator {
Copy link
Contributor

@black-adder black-adder Jun 6, 2018

Choose a reason for hiding this comment

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

Can we use functional options here instead? We reduce the API surface area and it's backward and forward compatible.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 it's nice design

Copy link
Member Author

Choose a reason for hiding this comment

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

There are various styles how this can be done. I have changed it slightly in the last commit.

Copy link
Member

Choose a reason for hiding this comment

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

Go experts advise against using functional options and use option structs, because structs compose better (as evidenced by our duplication of tracer and config options).

The reason we traditionally used options is in cases where the existing API did not have configurability, in which case adding a vararg option list is backwards compatible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a resource on this? I remember someone talking about this but never read anything about it

Copy link
Member Author

Choose a reason for hiding this comment

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

@yurishkuro do you it's better to pass option struct to the "constructor" function (or whatever it's called).

Copy link
Member

Choose a reason for hiding this comment

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

I think for new code it might make sense to pass a struct with options.

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
@yurishkuro yurishkuro merged commit 6f6eb37 into jaegertracing:master Mar 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants