refactor initTrace -> initTracing()

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-07-13 10:47:42 -07:00
parent 5a32ddf0ff
commit d01f525453
2 changed files with 15 additions and 11 deletions

View file

@ -88,15 +88,7 @@ var catalog = []*pb.Product{
func main() {
flag.Parse()
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")
}
initTracing()
log.Printf("starting grpc server at :%d", *port)
run(*port)
@ -114,6 +106,18 @@ func run(port int) string {
return l.Addr().String()
}
func initTracing() {
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")
}
}
type productCatalog struct{}
func (p *productCatalog) ListProducts(context.Context, *pb.Empty) (*pb.ListProductsResponse, error) {

View file

@ -69,7 +69,7 @@ func main() {
}
port = fmt.Sprintf(":%s", port)
initTrace()
initTracing()
lis, err := net.Listen("tcp", port)
if err != nil {
@ -86,7 +86,7 @@ func main() {
}
}
func initTrace() {
func initTracing() {
exporter, err := stackdriver.NewExporter(stackdriver.Options{})
if err != nil {
log.Printf("failed to initialize stackdriver exporter: %+v", err)