-
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
Allow global ErrorHandler to be set multiple times #2160
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## main #2160 +/- ##
=====================================
Coverage 72.2% 72.2%
=====================================
Files 176 176
Lines 12088 12091 +3
=====================================
+ Hits 8731 8741 +10
+ Misses 3115 3110 -5
+ Partials 242 240 -2
|
MrAlias
requested review from
Aneurysm9,
dashpole,
evantorrie,
jmacd,
MadVikingGod,
paivagustavo,
pellared and
XSAM
as code owners
August 4, 2021 17:12
Aneurysm9
approved these changes
Aug 4, 2021
jmacd
approved these changes
Aug 5, 2021
XSAM
reviewed
Aug 6, 2021
XSAM
approved these changes
Aug 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2140
These changes allow a user to set the global
ErrorHandler
multiple times. This is done by storing the state in anatomic.Value
.This also adds a benchmark to track performance and overhead of these changes. The increase in memory usage and allocations appears related to the setting operation. Prior to the changes setting a global
ErrorHandler
had no memory overhead and with these changes it requires an allocation. This seems acceptable given this code correctly allows multiple setting of anErrorHandler
and this operation is expected to be called a limited amount of times during initialization of user code.Benchmark Before
$ go test -timeout 300s -bench=. goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz BenchmarkErrorHandler-8 542686 2256 ns/op 144 B/op 6 allocs/op BenchmarkGetDefaultErrorHandler-8 1000000000 0.7989 ns/op 0 B/op 0 allocs/op BenchmarkGetDelegatedErrorHandler-8 1000000000 0.9686 ns/op 0 B/op 0 allocs/op BenchmarkDefaultErrorHandlerHandle-8 2890158 415.4 ns/op 48 B/op 1 allocs/op BenchmarkDelegatedErrorHandlerHandle-8 4011504 303.8 ns/op 48 B/op 1 allocs/op BenchmarkSetErrorHandlerDelegation-8 7772974 158.2 ns/op 0 B/op 0 allocs/op BenchmarkSetErrorHandlerNoDelegation-8 344574063 3.454 ns/op 0 B/op 0 allocs/op
Benchmark After
$ go test -timeout=300s -bench=. goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz BenchmarkErrorHandler-8 480949 2306 ns/op 176 B/op 8 allocs/op BenchmarkGetDefaultErrorHandler-8 660670377 1.887 ns/op 0 B/op 0 allocs/op BenchmarkGetDelegatedErrorHandler-8 627903168 1.903 ns/op 0 B/op 0 allocs/op BenchmarkDefaultErrorHandlerHandle-8 4298862 288.5 ns/op 48 B/op 1 allocs/op BenchmarkDelegatedErrorHandlerHandle-8 3892299 301.8 ns/op 48 B/op 1 allocs/op BenchmarkSetErrorHandlerDelegation-8 3984223 342.1 ns/op 16 B/op 1 allocs/op BenchmarkSetErrorHandlerNoDelegation-8 25017502 46.58 ns/op 16 B/op 1 allocs/op