Skip to content

Commit

Permalink
Replace deprecated grpc.DialContext with NewClient (#168)
Browse files Browse the repository at this point in the history
* Replace depr DialContext with NewClient

* Update README.md
  • Loading branch information
MrAlias authored Apr 14, 2024
1 parent e817c56 commit 607e038
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This repository provides a [`logr.Logger`] that exports recorded messages as [Op
A working gRPC connection to an OTLP receiving endpoint is needed to setup the logger.

```go
conn, _ := grpc.DialContext(ctx, otlpTarget)
conn, _ := grpc.NewClient(otlpTarget)
```

Create a [`logr.Logger`] with this connection.
Expand Down
6 changes: 5 additions & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down Expand Up @@ -98,7 +99,10 @@ func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

conn, err := grpc.DialContext(ctx, *targetPtr, grpc.WithBlock(), grpc.WithInsecure())
conn, err := grpc.NewClient(
*targetPtr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 607e038

Please sign in to comment.