productcatalog: export traces to stackdriver
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
88b29516fb
commit
6065e871a9
3 changed files with 18 additions and 1 deletions
2
src/.gitignore
vendored
2
src/.gitignore
vendored
|
@ -4,3 +4,5 @@ v/
|
||||||
github.com
|
github.com
|
||||||
golang.org
|
golang.org
|
||||||
google.golang.org
|
google.golang.org
|
||||||
|
cloud.google.com
|
||||||
|
go.opencensus.io
|
||||||
|
|
|
@ -7,7 +7,9 @@ WORKDIR /src/microservices-demo/productcatalogservice
|
||||||
RUN go get -d google.golang.org/grpc \
|
RUN go get -d google.golang.org/grpc \
|
||||||
google.golang.org/grpc/codes \
|
google.golang.org/grpc/codes \
|
||||||
google.golang.org/grpc/status \
|
google.golang.org/grpc/status \
|
||||||
go.opencensus.io/plugin/ocgrpc
|
go.opencensus.io/plugin/ocgrpc \
|
||||||
|
go.opencensus.io/trace \
|
||||||
|
go.opencensus.io/exporter/stackdriver
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
# get remaining dependencies
|
# get remaining dependencies
|
||||||
|
|
|
@ -9,7 +9,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pb "./genproto"
|
pb "./genproto"
|
||||||
|
"go.opencensus.io/exporter/stackdriver"
|
||||||
"go.opencensus.io/plugin/ocgrpc"
|
"go.opencensus.io/plugin/ocgrpc"
|
||||||
|
"go.opencensus.io/trace"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
@ -85,6 +87,17 @@ var catalog = []*pb.Product{
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
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)
|
||||||
|
log.Println("registered stackdriver")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("starting grpc server at :%d", *port)
|
||||||
run(*port)
|
run(*port)
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue