Adds option to disable Stackdriver Export (#293)

This commit is contained in:
Megan O'Keefe 2020-02-20 15:26:44 -05:00 committed by GitHub
parent 595bd21d38
commit 90f9287f3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 267 additions and 75 deletions

View file

@ -69,8 +69,19 @@ type checkoutService struct {
}
func main() {
go initTracing()
go initProfiling("checkoutservice", "1.0.0")
if os.Getenv("DISABLE_TRACING") == "" {
log.Info("Tracing enabled.")
go initTracing()
} else {
log.Info("Tracing disabled.")
}
if os.Getenv("DISABLE_PROFILER") == "" {
log.Info("Profiling enabled.")
go initProfiling("checkoutservice", "1.0.0")
} else {
log.Info("Profiling disabled.")
}
port := listenPort
if os.Getenv("PORT") != "" {
@ -91,7 +102,15 @@ func main() {
if err != nil {
log.Fatal(err)
}
srv := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
var srv *grpc.Server
if os.Getenv("DISABLE_STATS") == "" {
log.Info("Stats enabled.")
srv = grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
} else {
log.Info("Stats disabled.")
srv = grpc.NewServer()
}
pb.RegisterCheckoutServiceServer(srv, svc)
healthpb.RegisterHealthServer(srv, svc)
log.Infof("starting to listen on tcp: %q", lis.Addr().String())