@@ -50,7 +50,9 @@ func (t textFormatPropagator) Injector(req *http.Request) trace.Injector {
50
50
// TextFormatPropagator creates a new propagator. The propagator is then used
51
51
// to create Injector and Extrator associated with a specific request. Injectors
52
52
// and Extractors respectively provides method to inject and extract SpanContext
53
- // into/from the http request.
53
+ // into/from the http request. Inject method encodes SpanContext into W3C
54
+ // TraceContext Header and injects the header in the request. Extract extracts
55
+ // the header and decodes SpanContext.
54
56
func TextFormatPropagator () textFormatPropagator {
55
57
return textFormatPropagator {}
56
58
}
@@ -63,8 +65,8 @@ var _ trace.Extractor = textFormatExtractor{}
63
65
64
66
// Extract implements Extract method of trace.Extractor interface. It extracts
65
67
// W3C TraceContext Header and decodes SpanContext from the Header.
66
- func (f textFormatExtractor ) Extract () (sc core.SpanContext , tm tag.Map ) {
67
- h , ok := getRequestHeader (f .req , traceparentHeader , false )
68
+ func (tfe textFormatExtractor ) Extract () (sc core.SpanContext , tm tag.Map ) {
69
+ h , ok := getRequestHeader (tfe .req , traceparentHeader , false )
68
70
if ! ok {
69
71
return core .INVALID_SPAN_CONTEXT , nil
70
72
}
@@ -137,15 +139,15 @@ var _ trace.Injector = textFormatInjector{}
137
139
// Inject implements Inject method of trace.Injector interface. It encodes
138
140
// SpanContext into W3C TraceContext Header and injects the header into
139
141
// the associated request.
140
- func (f textFormatInjector ) Inject (sc core.SpanContext , tm tag.Map ) {
142
+ func (tfi textFormatInjector ) Inject (sc core.SpanContext , tm tag.Map ) {
141
143
if sc .IsValid () {
142
144
h := fmt .Sprintf ("%.2x-%.16x%.16x-%.16x-%.2x" ,
143
145
supportedVersion ,
144
146
sc .TraceID .High ,
145
147
sc .TraceID .Low ,
146
148
sc .SpanID ,
147
149
sc .TraceOptions )
148
- f .req .Header .Set (traceparentHeader , h )
150
+ tfi .req .Header .Set (traceparentHeader , h )
149
151
}
150
152
// TODO: [rghetia] add tag.Map (distributed context) injection
151
153
}
0 commit comments