Skip to content
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

Some cleanups in otlp exporter #1350

Merged
merged 5 commits into from
Nov 20, 2020

Conversation

krnowak
Copy link
Member

@krnowak krnowak commented Nov 19, 2020

This is a first batch of work I did on otlp exporter. It's a small one, since the next commit belongs to a different person and I'd like to retain the authorship of it by filing a separate PR for it.

The whole work is in my branch: https://github.com/krnowak/opentelemetry-go/tree/otlp-conn

@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #1350 (c67cbac) into master (5b5b4ab) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1350   +/-   ##
======================================
  Coverage    77.5%   77.5%           
======================================
  Files         125     125           
  Lines        6131    6127    -4     
======================================
- Hits         4753    4751    -2     
+ Misses       1127    1126    -1     
+ Partials      251     250    -1     
Impacted Files Coverage Δ
exporters/otlp/options.go 55.5% <ø> (+1.0%) ⬆️
exporters/otlp/otlp.go 77.0% <100.0%> (ø)

exporters/otlp/otlp_metric_test.go Show resolved Hide resolved
This is not a good option - the user isn't likely to know how many
worker goroutines is optimal. This should be something that an
exporter should figure out itself. The second problem with the option
is that it is specific to the metric transformation from SDK export
format into protobuf. When the exporter starts supporting other
protocols (HTTP/JSON for example), this option may be of no use. So
the option should rather belong to the protocol, not to the
exporter. Currently both mean the same, but later they will be
separated, and this option breaks the separation.
Signalling channels are idiomatically defined as chan struct{}, so
let's make it so, to avoid confusion about the meaning of the bool
type.
If several goroutines call Shutdown at the same time, then the
following scenario is possible:

goroutine A locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine B locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine A does not return early in the "if !started" conditional and
continues to close the connection and execute the rest of the function
(where it finally sets the started member to false), gets preempted

goroutine B also does not return early, because it got a copy of
started before goroutine A set it to false, so it tries to close the
connection again.
@krnowak
Copy link
Member Author

krnowak commented Nov 19, 2020

Updated.

@Aneurysm9 Aneurysm9 merged commit 6eb6801 into open-telemetry:master Nov 20, 2020
@MrAlias MrAlias mentioned this pull request Nov 20, 2020
@krnowak krnowak deleted the otlp-exporter-1 branch November 20, 2020 16:34
AzfaarQureshi pushed a commit to open-o11y/opentelemetry-go that referenced this pull request Dec 3, 2020
* Drop WorkerCount option

This is not a good option - the user isn't likely to know how many
worker goroutines is optimal. This should be something that an
exporter should figure out itself. The second problem with the option
is that it is specific to the metric transformation from SDK export
format into protobuf. When the exporter starts supporting other
protocols (HTTP/JSON for example), this option may be of no use. So
the option should rather belong to the protocol, not to the
exporter. Currently both mean the same, but later they will be
separated, and this option breaks the separation.

* Make stop channel a typical signalling channel

Signalling channels are idiomatically defined as chan struct{}, so
let's make it so, to avoid confusion about the meaning of the bool
type.

* Close a race when grpc connection is closed multiple times

If several goroutines call Shutdown at the same time, then the
following scenario is possible:

goroutine A locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine B locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine A does not return early in the "if !started" conditional and
continues to close the connection and execute the rest of the function
(where it finally sets the started member to false), gets preempted

goroutine B also does not return early, because it got a copy of
started before goroutine A set it to false, so it tries to close the
connection again.

* Update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants