Skip to content

Commit

Permalink
Use the grpc.ClientConn to handle connections for the otlptracegrpc c…
Browse files Browse the repository at this point in the history
…lient (#2329)

* POC using the grpc.ClientConn to handle connections

* Update invalid client security test

* Update client start test for a bad endpoint

* Use any ClientConn a user provides

* Connect ReconnectionPeriod to gRPC conn retries

* Replace connection retry handling direct in otlptracegrpc

* Fix client comments

* Fix comment for NewGRPCConfig

* Replace reconnection test

* Fix grammar

* Remove unrelated changes

* Remove connection pkg

* Rename evaluate to retryable

* POC using the grpc.ClientConn to handle connections

* Replace connection retry handling direct in otlptracegrpc

* Add ClientConn use changes to changelog

* Update otlptracegrpc options

* Only close ClientConn that the Client create

* Remove listener wrapper from mock_collector_test

This is not needed now that no tests relies on the listener to wait for
a connection to be established before continuing.

* Fix spelling error

* Do not use deprecated options in the otel-collector example

* Add unit tests for retryable and throttleDelay funcs

* Add unit tests for context heredity

* Add test that exporter stop is linked to context cancel

* go mod tidy

* Update exporters/otlp/otlptrace/otlptracegrpc/client.go

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

* Fix go.mod from rebase

* Remove wrong comment about client stop closing gRPC conn

* Fix shutdown test cleanup

Do not check the second call to the client Stop. There is no guarantee
it will not error in normal operation.

* Make lint fixes

* Fix flaky unit test

Use the internals of the client to explicit cancel the context returned
from exportContext. This gets around the bug where the select in Stop
may randomly choose the non-context Done case and avoid returning an
error (also failing to cancel the context).

* Remove deprecation

To configure the client/exporter with environment variables these
options are used. There is no way to fully remove these options without
removing support for configuration with environment variables. Leave
that decision and strategy determination to a separate PR.

* Fix grammatical error in comment

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
  • Loading branch information
MrAlias and Aneurysm9 committed Nov 25, 2021
1 parent 1ea6ee3 commit f1971b3
Show file tree
Hide file tree
Showing 13 changed files with 434 additions and 698 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- The `"go.opentelemetry.io/otel/exporter/otel/otlptrace/otlptracegrpc".Client` now uses the underlying gRPC `ClientConn` to handle name resolution, TCP connection establishment (with retries and backoff) and TLS handshakes, and handling errors on established connections by re-resolving the name and reconnecting. (#2329)
- Changed the project minimum supported Go version from 1.15 to 1.16. (#2412)

### Removed
Expand Down
8 changes: 3 additions & 5 deletions example/otel-collector/main.go
Expand Up @@ -53,13 +53,11 @@ func initProvider() func() {
// `localhost:30080` endpoint. Otherwise, replace `localhost` with the
// endpoint of your cluster. If you run the app inside k8s, then you can
// probably connect directly to the service through dns
conn, err := grpc.DialContext(ctx, "localhost:30080", grpc.WithInsecure(), grpc.WithBlock())
handleErr(err, "failed to create gRPC connection to collector")

// Set up a trace exporter
traceExporter, err := otlptracegrpc.New(ctx,
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint("localhost:30080"),
otlptracegrpc.WithDialOption(grpc.WithBlock()),
)
traceExporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithGRPCConn(conn))
handleErr(err, "failed to create trace exporter")

// Register the trace exporter with a TracerProvider, using a batch
Expand Down
1 change: 0 additions & 1 deletion exporters/otlp/otlptrace/go.mod
Expand Up @@ -10,7 +10,6 @@ require (
go.opentelemetry.io/otel/sdk v1.2.0
go.opentelemetry.io/otel/trace v1.2.0
go.opentelemetry.io/proto/otlp v0.11.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.27.1
)
Expand Down
38 changes: 0 additions & 38 deletions exporters/otlp/otlptrace/internal/connection/alignment_test.go

This file was deleted.

0 comments on commit f1971b3

Please sign in to comment.