shippingservice: move initTrace() to a func
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
062b325c1e
commit
5a32ddf0ff
1 changed files with 13 additions and 9 deletions
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue