-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split connection management away from exporter #1369
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1369 +/- ##
========================================
+ Coverage 78.1% 78.3% +0.2%
========================================
Files 123 125 +2
Lines 6252 6259 +7
========================================
+ Hits 4885 4904 +19
+ Misses 1119 1111 -8
+ Partials 248 244 -4
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall design of adding the ConnectionManager interface. I'm interested to know what you think about leaving the transform functionality in the exporter though and keeping the new ConnectionManager interface focused on transport.
@dashpole: Thanks for the review. I'll reply to both your issues here.
The follow-up PR would introduce the type MultiConnectionConfig struct {
Traces GRPCConnectionConfig
Metrics GRPCConnectionConfig
}
func NewGRPCMultiConnectionManager(cfg MultiConnectionConfig) ConnectionManager { … } So for |
Got it. Thanks for linking the issue.
That makes sense. This is part of #1121, right? If there are eventually going to be multiple types of exporters (not just grpc), it might make sense to make a more generic single vs multi connection manager that isn't grpc-specific. For example (with the current naming): type MultiConnectionConfig struct {
Traces ConnectionManager
Metrics ConnectionManager
}
func NewMultiConnectionManager(cfg MultiConnectionConfig) ConnectionManager { … } |
Yes.
I got something like that already: krnowak@f8c2ec8, but maybe your variant with the config is actually better, because you spell you explicitly which manager goes for tracing and which for metrics. So thanks for the idea and we'll see how it fares during the review when it appears in another PR. |
ba50f19
to
f23ea9f
Compare
Updated. |
f23ea9f
to
3f6da5f
Compare
3f6da5f
to
2f9aaa0
Compare
Updated. Added some tests to increase the coverage a bit (increasing coverage for error conditions is rather annoying). And fixed one or two races. |
03c6837
to
6e272f9
Compare
Before merging it, I'd like to discuss one thing at the Golang SIG meeting first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added a recommendation for a NewGRPCConnectionConfig
function.
From the SIG meeting, we are going to not add a single/multiple gRPC connection driver. Instead going to progress to just using the driver interface to support multiple protocols for now. |
This looks good to me, independent of the single- vs multi-driver question, simply for taking us one step closer to an OTLP/HTTP exporter. 😀 |
e7ca1fc
to
b58c925
Compare
Rebased and updated. Simplified the gRPC driver a bit. |
e273c75
to
081eca3
Compare
081eca3
to
07adb0e
Compare
ce9d867
to
671792a
Compare
Updated to fix a conflict in changelog. Updated some tests to be a bit less flaky. |
ed98136
to
3af8ec7
Compare
This commits adds a ProtocolDriver interface, which the exporter will use to connect to the collector and send both metrics and traces to it. That way, the Exporter type is free from dealing with any connection/protocol details, as this business is taken over by the implementations of the ProtocolDriver interface. The gRPC code from the exporter is moved into the implementation of ProtocolDriver. Currently it only maintains a single connection, just as the Exporter used to do. With the split, most of the Exporter options became actually gRPC connection manager's options. Currently the only option that remained to be Exporter's is about setting the export kind selector.
The disconnected channel can be used for sending by multiple goroutines (for example, by metric controller and span processor), so this channel should not be closed at all. Dropping this line closes a race between closing a channel and sending to it.
The callbacks never return an error, so drop the return type from it.
The client may change as a result on reconnection in background, so guard against a racy access.
The config type was exported earlier to have a consistent way of configuring the driver, when also the multiple connection driver would appear. Since we are not going to add a multiple connection driver, pass the options directly to the driver constructor. Also shorten the name of the constructor to `NewGRPCDriver`.
The common code was supposed to be shared between single connection driver and multiple connection driver, but since the latter won't be happening, it makes no sense to keep the not-so-common code in a separate file. Also drop some abstraction too.
Sometimes CI has it's better moments, so it's blazing fast and manages to finish shutting the exporter down within the 1 microsecond timeout.
One millisecond is quite short, and I was getting failures locally or in CI: go test ./... + race in ./exporters/otlp 2020/12/14 18:27:54 rpc error: code = Canceled desc = context canceled 2020/12/14 18:27:54 context deadline exceeded --- FAIL: TestNewExporter_withMultipleAttributeTypes (0.37s) otlp_integration_test.go:541: resource span count: got 0, want 1 FAIL FAIL go.opentelemetry.io/otel/exporters/otlp 5.278s or go test ./... + coverage in ./exporters/otlp 2020/12/14 17:41:16 rpc error: code = Canceled desc = context canceled 2020/12/14 17:41:16 exporter disconnected --- FAIL: TestNewExporter_endToEnd (1.53s) --- FAIL: TestNewExporter_endToEnd/WithCompressor (0.41s) otlp_integration_test.go:246: span counts: got 3, want 4 2020/12/14 17:41:18 context canceled FAIL coverage: 35.3% of statements in ./... FAIL go.opentelemetry.io/otel/exporters/otlp 4.753s
This is to make sure that all batched spans are actually flushed before closing the exporter.
3af8ec7
to
1123f58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work 👍
This commits adds an ConnectionManager interface, which the exporter
will use to connect to the collector and send both metrics and traces
to it. That way, the Exporter type is free from dealing with any
connection/protocol details, as this business is taken over by the
implementations of the ConnectionManager interface.
The gRPC code from the exporter is moved into the implementation of
ConnectionManager. Currently it only maintains a single connection,
just as the Exporter used to do.
With the split, most of the Exporter options became actually gRPC
connection manager's options. Currently the only option that remained
to be Exporter's is about setting the export kind selector.