Missing PR fixes (#503)
* Drop bogus comment, fix typo A result of copy-pasting. * Unexport HTTP header constants * Rename instruments in tests "ajwaj" is my favourite placeholder text, but seems like I forgot to replace its occurences with proper names. Co-authored-by: Rahul Patel <rghetia@yahoo.com>
This commit is contained in:
		
							parent
							
								
									52fb033e13
								
							
						
					
					
						commit
						91ea965f8b
					
				| 
						 | 
				
			
			@ -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}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue