Repository: census-instrumentation/opencensus-service (go)

Issue:
Rename ocinterceptor.OCInterceptor to ocinterceptor.Interceptor
To minimize the stuttering of the names.

Pull request:
interceptor/opencensus: remove redundant OCInterceptor prefix
Given that the package name is already ocinterceptor, using
OCInterceptor as a prefix for the type name is now unnecessary.
That naming was because the package was one of the first ones
to be added. Now that the packaging is mature this has come up
as a better suggestion to remove that unnecessary prefix.

Fixes #88

Patch:
diff --git a/interceptor/opencensus/opencensus.go b/interceptor/opencensus/opencensus.go
index 2a4cb16..78abea2 100644
--- a/interceptor/opencensus/opencensus.go
+++ b/interceptor/opencensus/opencensus.go
@@ -30,28 +30,28 @@ import (
 	"github.com/census-instrumentation/opencensus-service/spanreceiver"
 )
 
-type OCInterceptor struct {
+type Interceptor struct {
 	spanSink         spanreceiver.SpanReceiver
 	spanBufferPeriod time.Duration
 	spanBufferCount  int
 }
 
-func New(sr spanreceiver.SpanReceiver, opts ...OCOption) (*OCInterceptor, error) {
+func New(sr spanreceiver.SpanReceiver, opts ...OCOption) (*Interceptor, error) {
 	if sr == nil {
 		return nil, errors.New("needs a non-nil spanReceiver")
 	}
-	oci := &OCInterceptor{spanSink: sr}
+	oci := &Interceptor{spanSink: sr}
 	for _, opt := range opts {
-		opt.WithOCInterceptor(oci)
+		opt.WithInterceptor(oci)
 	}
 	return oci, nil
 }
 
-var _ agenttracepb.TraceServiceServer = (*OCInterceptor)(nil)
+var _ agenttracepb.TraceServiceServer = (*Interceptor)(nil)
 
 var errUnimplemented = errors.New("unimplemented")
 
-func (oci *OCInterceptor) Config(tcs agenttracepb.TraceService_ConfigServer) error {
+func (oci *Interceptor) Config(tcs agenttracepb.TraceService_ConfigServer) error {
 	// TODO: Implement when we define the config receiver/sender.
 	return errUnimplemented
 }
@@ -67,7 +67,7 @@ const interceptorName = "opencensus"
 
 // Export is the gRPC method that receives streamed traces from
 // OpenCensus-traceproto compatible libraries/applications.
-func (oci *OCInterceptor) Export(tes agenttracepb.TraceService_ExportServer) error {
+func (oci *Interceptor) Export(tes agenttracepb.TraceService_ExportServer) error {
 	// The bundler will receive batches of spans i.e. []*tracepb.Span
 	// We need to ensure that it propagates the interceptor name as a tag
 	ctxWithInterceptorName := internal.ContextWithInterceptorName(tes.Context(), interceptorName)
@@ -129,7 +129,7 @@ func (oci *OCInterceptor) Export(tes agenttracepb.TraceService_ExportServer) err
 	}
 }
 
-func (oci *OCInterceptor) batchSpanExporting(longLivedRPCCtx context.Context, payload interface{}) {
+func (oci *Interceptor) batchSpanExporting(longLivedRPCCtx context.Context, payload interface{}) {
 	spnL := payload.([]*spansAndNode)
 	if len(spnL) == 0 {
 		return
diff --git a/interceptor/opencensus/options.go b/interceptor/opencensus/options.go
index f4ff736..f7ce54d 100644
--- a/interceptor/opencensus/options.go
+++ b/interceptor/opencensus/options.go
@@ -17,7 +17,7 @@ package ocinterceptor
 import "time"
 
 type OCOption interface {
-	WithOCInterceptor(*OCInterceptor)
+	WithInterceptor(*Interceptor)
 }
 
 type spanBufferPeriod struct {
@@ -26,12 +26,12 @@ type spanBufferPeriod struct {
 
 var _ OCOption = (*spanBufferPeriod)(nil)
 
-func (sfd *spanBufferPeriod) WithOCInterceptor(oci *OCInterceptor) {
+func (sfd *spanBufferPeriod) WithInterceptor(oci *Interceptor) {
 	oci.spanBufferPeriod = sfd.period
 }
 
 // WithSpanBufferPeriod is an option that allows one to configure
-// the period that spans are buffered for before the OCInterceptor
+// the period that spans are buffered for before the Interceptor
 // sends them to its SpanReceiver.
 func WithSpanBufferPeriod(period time.Duration) OCOption {
 	return &spanBufferPeriod{period: period}
@@ -41,12 +41,12 @@ type spanBufferCount int
 
 var _ OCOption = (*spanBufferCount)(nil)
 
-func (spc spanBufferCount) WithOCInterceptor(oci *OCInterceptor) {
+func (spc spanBufferCount) WithInterceptor(oci *Interceptor) {
 	oci.spanBufferCount = int(spc)
 }
 
 // WithSpanBufferCount is an option that allows one to configure
-// the number of spans that are buffered before the OCInterceptor
+// the number of spans that are buffered before the Interceptor
 // send them to its SpanReceiver.
 func WithSpanBufferCount(count int) OCOption {
 	return spanBufferCount(count)


Test patch:
diff --git a/interceptor/opencensus/opencensus_test.go b/interceptor/opencensus/opencensus_test.go
index f30d6fe..7b05555 100644
--- a/interceptor/opencensus/opencensus_test.go
+++ b/interceptor/opencensus/opencensus_test.go
@@ -43,7 +43,7 @@ import (
 	"go.opencensus.io/trace/tracestate"
 )
 
-func TestOCInterceptor_endToEnd(t *testing.T) {
+func TestInterceptor_endToEnd(t *testing.T) {
 	t.Skip("This test is flaky due to timing slowdown due to -race. Will reenable in the future")
 
 	sappender := newSpanAppender()
@@ -163,7 +163,7 @@ func TestOCInterceptor_endToEnd(t *testing.T) {
 }
 
 // Issue #43. Export should support node multiplexing.
-// The goal is to ensure that OCInterceptor can always support
+// The goal is to ensure that Interceptor can always support
 // a passthrough mode where it initiates Export normally by firstly
 // receiving the initiator node. However ti should still be able to
 // accept nodes from downstream sources, but if a node isn't specified in
@@ -456,7 +456,7 @@ func (sa *spanAppender) ReceiveSpans(ctx context.Context, node *commonpb.Node, s
 	return &spanreceiver.Acknowledgement{SavedSpans: uint64(len(spans))}, nil
 }
 
-func ocInterceptorOnGRPCServer(t *testing.T, sr spanreceiver.SpanReceiver, opts ...ocinterceptor.OCOption) (oci *ocinterceptor.OCInterceptor, port int, done func()) {
+func ocInterceptorOnGRPCServer(t *testing.T, sr spanreceiver.SpanReceiver, opts ...ocinterceptor.OCOption) (oci *ocinterceptor.Interceptor, port int, done func()) {
 	ln, err := net.Listen("tcp", ":0")
 	if err != nil {
 		t.Fatalf("Failed to find an available address to run the gRPC server: %v", err)
@@ -482,7 +482,7 @@ func ocInterceptorOnGRPCServer(t *testing.T, sr spanreceiver.SpanReceiver, opts
 
 	oci, err = ocinterceptor.New(sr, opts...)
 	if err != nil {
-		t.Fatalf("Failed to create the OCInterceptor: %v", err)
+		t.Fatalf("Failed to create the Interceptor: %v", err)
 	}
 
 	// Now run it as a gRPC server