From c5bb0ea168e6ea7f68f44195731bdb459e7af9d0 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 20 Feb 2020 23:13:49 +0100 Subject: [PATCH 1/3] Drop bogus comment, fix typo A result of copy-pasting. --- api/global/internal/meter_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/global/internal/meter_test.go b/api/global/internal/meter_test.go index 0156d40a104..950c55fd2cf 100644 --- a/api/global/internal/meter_test.go +++ b/api/global/internal/meter_test.go @@ -100,7 +100,7 @@ func TestDirect(t *testing.T) { func TestBound(t *testing.T) { internal.ResetForTest() - // Note: this test uses oppsite Float64/Int64 number kinds + // Note: this test uses opposite Float64/Int64 number kinds // vs. the above, to cover all the instruments. ctx := context.Background() glob := global.MeterProvider().Meter("test") @@ -229,8 +229,6 @@ func TestDefaultSDK(t *testing.T) { func TestUnbindThenRecordOne(t *testing.T) { internal.ResetForTest() - // Note: this test uses oppsite Float64/Int64 number kinds - // vs. the above, to cover all the instruments. ctx := context.Background() sdk := metrictest.NewProvider() meter := global.MeterProvider().Meter("test") From 24081dccc168e756a1fe0c84414139d6ec96c529 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 20 Feb 2020 23:17:23 +0100 Subject: [PATCH 2/3] Unexport HTTP header constants --- api/correlation/correlation_context_propagator.go | 10 ++++------ api/trace/trace_context_propagator.go | 8 ++++---- plugin/othttp/handler_test.go | 4 +--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/api/correlation/correlation_context_propagator.go b/api/correlation/correlation_context_propagator.go index 846f7d81fb1..a32f1b55003 100644 --- a/api/correlation/correlation_context_propagator.go +++ b/api/correlation/correlation_context_propagator.go @@ -10,9 +10,7 @@ import ( "go.opentelemetry.io/otel/api/propagation" ) -// CorrelationContextHeader is specified by W3C. -//nolint:golint -var CorrelationContextHeader = "Correlation-Context" +const correlationContextHeader = "Correlation-Context" // CorrelationContext propagates Key:Values in W3C CorrelationContext // format. @@ -44,13 +42,13 @@ func (CorrelationContext) Inject(ctx context.Context, supplier propagation.HTTPS }) if headerValueBuilder.Len() > 0 { headerString := headerValueBuilder.String() - supplier.Set(CorrelationContextHeader, headerString) + supplier.Set(correlationContextHeader, headerString) } } // Extract implements HTTPExtractor. func (CorrelationContext) Extract(ctx context.Context, supplier propagation.HTTPSupplier) context.Context { - correlationContext := supplier.Get(CorrelationContextHeader) + correlationContext := supplier.Get(correlationContextHeader) if correlationContext == "" { return ContextWithMap(ctx, NewEmptyMap()) } @@ -95,5 +93,5 @@ func (CorrelationContext) Extract(ctx context.Context, supplier propagation.HTTP // GetAllKeys implements HTTPPropagator. func (CorrelationContext) GetAllKeys() []string { - return []string{CorrelationContextHeader} + return []string{correlationContextHeader} } diff --git a/api/trace/trace_context_propagator.go b/api/trace/trace_context_propagator.go index 99ca303baac..dfc6e25895a 100644 --- a/api/trace/trace_context_propagator.go +++ b/api/trace/trace_context_propagator.go @@ -28,7 +28,7 @@ import ( const ( supportedVersion = 0 maxVersion = 254 - TraceparentHeader = "Traceparent" + traceparentHeader = "Traceparent" ) // TraceContext propagates SpanContext in W3C TraceContext format. @@ -51,7 +51,7 @@ func (TraceContext) Inject(ctx context.Context, supplier propagation.HTTPSupplie sc.TraceIDString(), sc.SpanID, sc.TraceFlags&core.TraceFlagsSampled) - supplier.Set(TraceparentHeader, h) + supplier.Set(traceparentHeader, h) } } @@ -60,7 +60,7 @@ func (tc TraceContext) Extract(ctx context.Context, supplier propagation.HTTPSup } func (TraceContext) extract(supplier propagation.HTTPSupplier) core.SpanContext { - h := supplier.Get(TraceparentHeader) + h := supplier.Get(traceparentHeader) if h == "" { return core.EmptySpanContext() } @@ -127,5 +127,5 @@ func (TraceContext) extract(supplier propagation.HTTPSupplier) core.SpanContext } func (TraceContext) GetAllKeys() []string { - return []string{TraceparentHeader} + return []string{traceparentHeader} } diff --git a/plugin/othttp/handler_test.go b/plugin/othttp/handler_test.go index aa73be7c4b6..59e0858b46b 100644 --- a/plugin/othttp/handler_test.go +++ b/plugin/othttp/handler_test.go @@ -20,8 +20,6 @@ import ( "net/http/httptest" "testing" - "go.opentelemetry.io/otel/api/trace" - mocktrace "go.opentelemetry.io/otel/internal/trace" ) @@ -47,7 +45,7 @@ func TestBasics(t *testing.T) { if got, expected := rr.Result().StatusCode, http.StatusOK; got != expected { t.Fatalf("got %d, expected %d", got, expected) } - if got := rr.Header().Get(trace.TraceparentHeader); got == "" { + if got := rr.Header().Get("Traceparent"); got == "" { t.Fatal("expected non empty trace header") } if got, expected := id, uint64(1); got != expected { From 1e7515ce9d479e58a117e19395ebfb23c726075a Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 21 Feb 2020 21:53:32 +0100 Subject: [PATCH 3/3] Rename instruments in tests "ajwaj" is my favourite placeholder text, but seems like I forgot to replace its occurences with proper names. --- api/metric/api_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/metric/api_test.go b/api/metric/api_test.go index 2925a0a96cf..a45c96c6118 100644 --- a/api/metric/api_test.go +++ b/api/metric/api_test.go @@ -370,7 +370,7 @@ func checkOptions(t *testing.T, got *metric.Options, expected *metric.Options) { func TestCounter(t *testing.T) { { meter := mock.NewMeter() - c := meter.NewFloat64Counter("ajwaj") + c := meter.NewFloat64Counter("test.counter.float") ctx := context.Background() labels := meter.Labels() c.Add(ctx, 42, labels) @@ -382,7 +382,7 @@ func TestCounter(t *testing.T) { } { meter := mock.NewMeter() - c := meter.NewInt64Counter("ajwaj") + c := meter.NewInt64Counter("test.counter.int") ctx := context.Background() labels := meter.Labels() c.Add(ctx, 42, labels) @@ -397,7 +397,7 @@ func TestCounter(t *testing.T) { func TestGauge(t *testing.T) { { meter := mock.NewMeter() - g := meter.NewFloat64Gauge("ajwaj") + g := meter.NewFloat64Gauge("test.gauge.float") ctx := context.Background() labels := meter.Labels() g.Set(ctx, 42, labels) @@ -409,7 +409,7 @@ func TestGauge(t *testing.T) { } { meter := mock.NewMeter() - g := meter.NewInt64Gauge("ajwaj") + g := meter.NewInt64Gauge("test.gauge.int") ctx := context.Background() labels := meter.Labels() g.Set(ctx, 42, labels) @@ -424,7 +424,7 @@ func TestGauge(t *testing.T) { func TestMeasure(t *testing.T) { { meter := mock.NewMeter() - m := meter.NewFloat64Measure("ajwaj") + m := meter.NewFloat64Measure("test.measure.float") ctx := context.Background() labels := meter.Labels() m.Record(ctx, 42, labels) @@ -436,7 +436,7 @@ func TestMeasure(t *testing.T) { } { meter := mock.NewMeter() - m := meter.NewInt64Measure("ajwaj") + m := meter.NewInt64Measure("test.measure.int") ctx := context.Background() labels := meter.Labels() m.Record(ctx, 42, labels)