...

Source file src/github.com/go-kit/kit/tracing/zipkin/endpoint_test.go

Documentation: github.com/go-kit/kit/tracing/zipkin

     1  package zipkin_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/openzipkin/zipkin-go"
     8  	"github.com/openzipkin/zipkin-go/reporter/recorder"
     9  
    10  	"github.com/go-kit/kit/endpoint"
    11  	zipkinkit "github.com/go-kit/kit/tracing/zipkin"
    12  )
    13  
    14  const spanName = "test"
    15  
    16  func TestTraceEndpoint(t *testing.T) {
    17  	rec := recorder.NewReporter()
    18  	tr, _ := zipkin.NewTracer(rec)
    19  	mw := zipkinkit.TraceEndpoint(tr, spanName)
    20  	mw(endpoint.Nop)(context.Background(), nil)
    21  
    22  	spans := rec.Flush()
    23  
    24  	if want, have := 1, len(spans); want != have {
    25  		t.Fatalf("incorrect number of spans, wanted %d, got %d", want, have)
    26  	}
    27  
    28  	if want, have := spanName, spans[0].Name; want != have {
    29  		t.Fatalf("incorrect span name, wanted %s, got %s", want, have)
    30  	}
    31  }
    32  

View as plain text