Skip to content

Commit 9411593

Browse files
committed
fix variable names and comments.
1 parent 009d7a2 commit 9411593

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

propagation/http_textformat_propagator.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ func (t textFormatPropagator) Injector(req *http.Request) trace.Injector {
5050
// TextFormatPropagator creates a new propagator. The propagator is then used
5151
// to create Injector and Extrator associated with a specific request. Injectors
5252
// 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.
5456
func TextFormatPropagator() textFormatPropagator {
5557
return textFormatPropagator{}
5658
}
@@ -63,8 +65,8 @@ var _ trace.Extractor = textFormatExtractor{}
6365

6466
// Extract implements Extract method of trace.Extractor interface. It extracts
6567
// 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)
6870
if !ok {
6971
return core.INVALID_SPAN_CONTEXT, nil
7072
}
@@ -137,15 +139,15 @@ var _ trace.Injector = textFormatInjector{}
137139
// Inject implements Inject method of trace.Injector interface. It encodes
138140
// SpanContext into W3C TraceContext Header and injects the header into
139141
// 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) {
141143
if sc.IsValid() {
142144
h := fmt.Sprintf("%.2x-%.16x%.16x-%.16x-%.2x",
143145
supportedVersion,
144146
sc.TraceID.High,
145147
sc.TraceID.Low,
146148
sc.SpanID,
147149
sc.TraceOptions)
148-
f.req.Header.Set(traceparentHeader, h)
150+
tfi.req.Header.Set(traceparentHeader, h)
149151
}
150152
// TODO: [rghetia] add tag.Map (distributed context) injection
151153
}

propagation/http_textformat_propagator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ func TestExtractTraceContextFromHTTPReq(t *testing.T) {
7474
t.Run(tt.name, func(t *testing.T) {
7575
req, _ := http.NewRequest("GET", "http://example.com", nil)
7676
req.Header.Set("traceparent", tt.header)
77-
f := propagator.Extractor(req)
77+
e := propagator.Extractor(req)
7878

79-
gotSc, _ := f.Extract()
79+
gotSc, _ := e.Extract()
8080
if diff := cmp.Diff(gotSc, tt.wantSc); diff != "" {
8181
t.Errorf("Extract Tracecontext: %s: -got +want %s", tt.name, diff)
8282
}
@@ -117,8 +117,8 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) {
117117
for _, tt := range tests {
118118
t.Run(tt.name, func(t *testing.T) {
119119
req, _ := http.NewRequest("GET", "http://example.com", nil)
120-
f := propagator.Injector(req)
121-
f.Inject(tt.sc, nil)
120+
i := propagator.Injector(req)
121+
i.Inject(tt.sc, nil)
122122

123123
gotHeader := req.Header.Get("traceparent")
124124
if diff := cmp.Diff(gotHeader, tt.wantHeader); diff != "" {

0 commit comments

Comments
 (0)