From 00cf7a13fda62d119920c6906c87469e42b5ee2d Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Thu, 3 Sep 2020 08:16:02 -0600 Subject: [PATCH] fix(pubsub): honor option.WithTelemetryDisabled (#2815) It seem that the telemetry options added here predate general telemetry handling. There is no need to explicitly enable such options here as it is taken care of grpc.DialPool: https://pkg.go.dev/google.golang.org/api/transport/grpc?#DialPool. The stats handler is only added if option.WithTelemetryDisabled is not passed in. Fixes: #2751 --- pubsub/pubsub.go | 2 +- pubsub/trace.go | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index d73adcf637c..bec2aff4a1f 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -61,6 +61,7 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio return nil, fmt.Errorf("grpc.Dial: %v", err) } o = []option.ClientOption{option.WithGRPCConn(conn)} + o = append(o, option.WithTelemetryDisabled()) } else { numConns := runtime.GOMAXPROCS(0) if numConns > 4 { @@ -73,7 +74,6 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio Time: 5 * time.Minute, })), } - o = append(o, openCensusOptions()...) } o = append(o, opts...) pubc, err := vkit.NewPublisherClient(ctx, o...) diff --git a/pubsub/trace.go b/pubsub/trace.go index 4036a350f98..cb331725ddb 100644 --- a/pubsub/trace.go +++ b/pubsub/trace.go @@ -19,20 +19,11 @@ import ( "log" "sync" - "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" - "google.golang.org/api/option" - "google.golang.org/grpc" ) -func openCensusOptions() []option.ClientOption { - return []option.ClientOption{ - option.WithGRPCDialOption(grpc.WithStatsHandler(&ocgrpc.ClientHandler{})), - } -} - // The following keys are used to tag requests with a specific topic/subscription ID. var ( keyTopic = tag.MustNewKey("topic")