Skip to content

Commit

Permalink
Update OTLP auth example
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Feb 16, 2024
1 parent babed48 commit 0f22764
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
11 changes: 3 additions & 8 deletions example/trace/otlpgrpc/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
"go.opentelemetry.io/otel/trace"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/oauth"
"google.golang.org/grpc/credentials/google"
)

func initTracer() (func(), error) {
ctx := context.Background()

creds, err := oauth.NewApplicationDefault(ctx)
if err != nil {
panic(err)
}

exporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithDialOption(grpc.WithPerRPCCredentials(creds)))
creds := google.NewDefaultCredentials()
exporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithTLSCredentials(creds.TransportCredentials()))
if err != nil {
panic(err)
}
Expand Down
1 change: 1 addition & 0 deletions example/trace/otlpgrpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
2 changes: 2 additions & 0 deletions example/trace/otlpgrpc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ=
golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down

0 comments on commit 0f22764

Please sign in to comment.