shippingservice: move initTrace() to a func

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-07-12 14:56:51 -07:00
parent 062b325c1e
commit 5a32ddf0ff

View file

@ -69,15 +69,7 @@ func main() {
}
port = fmt.Sprintf(":%s", port)
exporter, err := stackdriver.NewExporter(stackdriver.Options{})
if err != nil {
log.Printf("failed to initialize stackdriver exporter: %+v", err)
log.Println("skipping uploading traces to stackdriver")
} else {
trace.RegisterExporter(exporter)
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
log.Println("registered stackdriver tracing")
}
initTrace()
lis, err := net.Listen("tcp", port)
if err != nil {
@ -93,3 +85,15 @@ func main() {
log.Fatalf("failed to serve: %v", err)
}
}
func initTrace() {
exporter, err := stackdriver.NewExporter(stackdriver.Options{})
if err != nil {
log.Printf("failed to initialize stackdriver exporter: %+v", err)
log.Println("skipping uploading traces to stackdriver")
} else {
trace.RegisterExporter(exporter)
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
log.Println("registered stackdriver tracing")
}
}