channelz: turn on channelz when importing service package, delete RegisterChannelz from grpc package (#2277)

This commit is contained in:
lyuxuan
2018-08-29 11:01:36 -07:00
committed by GitHub
parent a91fb537b1
commit da7e20b83e
4 changed files with 8 additions and 8 deletions

View File

@ -66,6 +66,7 @@ import (
"google.golang.org/grpc/benchmark/latency" "google.golang.org/grpc/benchmark/latency"
"google.golang.org/grpc/benchmark/stats" "google.golang.org/grpc/benchmark/stats"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/test/bufconn" "google.golang.org/grpc/test/bufconn"
) )
@ -452,7 +453,7 @@ func main() {
grpc.EnableTracing = enableTrace[featuresPos[0]] grpc.EnableTracing = enableTrace[featuresPos[0]]
if enableChannelz[featuresPos[8]] { if enableChannelz[featuresPos[8]] {
grpc.RegisterChannelz() channelz.TurnOn()
} }
if runMode[0] { if runMode[0] {
unaryBenchmark(startTimer, stopTimer, benchFeature, benchtime, s) unaryBenchmark(startTimer, stopTimer, benchFeature, benchtime, s)

View File

@ -37,6 +37,10 @@ import (
"google.golang.org/grpc/internal/channelz" "google.golang.org/grpc/internal/channelz"
) )
func init() {
channelz.TurnOn()
}
func convertToPtypesDuration(sec int64, usec int64) *durpb.Duration { func convertToPtypesDuration(sec int64, usec int64) *durpb.Duration {
return ptypes.DurationProto(time.Duration(sec*1e9 + usec*1e3)) return ptypes.DurationProto(time.Duration(sec*1e9 + usec*1e3))
} }

View File

@ -101,12 +101,6 @@ const (
defaultReadBufSize = 32 * 1024 defaultReadBufSize = 32 * 1024
) )
// RegisterChannelz turns on channelz service.
// This is an EXPERIMENTAL API.
func RegisterChannelz() {
channelz.TurnOn()
}
// Dial creates a client connection to the given target. // Dial creates a client connection to the given target.
func Dial(target string, opts ...DialOption) (*ClientConn, error) { func Dial(target string, opts ...DialOption) (*ClientConn, error) {
return DialContext(context.Background(), target, opts...) return DialContext(context.Background(), target, opts...)

View File

@ -56,6 +56,7 @@ import (
"google.golang.org/grpc/health" "google.golang.org/grpc/health"
healthgrpc "google.golang.org/grpc/health/grpc_health_v1" healthgrpc "google.golang.org/grpc/health/grpc_health_v1"
healthpb "google.golang.org/grpc/health/grpc_health_v1" healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/internal/leakcheck" "google.golang.org/grpc/internal/leakcheck"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
@ -71,7 +72,7 @@ import (
) )
func init() { func init() {
grpc.RegisterChannelz() channelz.TurnOn()
} }
var ( var (