Skip to content

Commit

Permalink
fix(pubsub): honor option.WithTelemetryDisabled (#2815)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
codyoss committed Sep 3, 2020
1 parent 4de8351 commit 00cf7a1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion pubsub/pubsub.go
Expand Up @@ -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 {
Expand All @@ -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...)
Expand Down
9 changes: 0 additions & 9 deletions pubsub/trace.go
Expand Up @@ -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")
Expand Down

0 comments on commit 00cf7a1

Please sign in to comment.