-
Notifications
You must be signed in to change notification settings - Fork 772
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
[api] Nullable annotations for the trace folder #4873
Merged
CodeBlanch
merged 15 commits into
open-telemetry:main
from
CodeBlanch:api-trace-annotations
Sep 26, 2023
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7a65494
Added nullable annotations for the trace folder in the api project.
CodeBlanch 82e0d8c
Tweaks.
CodeBlanch 504464b
Fixes.
CodeBlanch 9741eaa
Fixes.
CodeBlanch 3241534
Cleanup.
CodeBlanch c596f5b
Test fixes.
CodeBlanch 2ca4f27
Tweaks.
CodeBlanch 36d798c
Fix ApiCompat.
CodeBlanch 6d8d5aa
Cleanup.
CodeBlanch 70ff03f
CHANGELOG patch.
CodeBlanch b439b1d
Add tests for TracerProviderBuilderBase.
CodeBlanch df71aaf
Test improvements.
CodeBlanch 4a64a56
Finished annotations for metrics & tracing.
CodeBlanch 6299189
Merge from main.
CodeBlanch 6a46e0f
CHANGELOG fixes.
CodeBlanch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
2 changes: 1 addition & 1 deletion
2
src/OpenTelemetry.Api/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
src/OpenTelemetry.Api/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt
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
2 changes: 1 addition & 1 deletion
2
src/OpenTelemetry.Api/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt
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
106 changes: 53 additions & 53 deletions
106
src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Shipped.txt
Large diffs are not rendered by default.
Oops, something went wrong.
106 changes: 53 additions & 53 deletions
106
src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt
Large diffs are not rendered by default.
Oops, something went wrong.
106 changes: 53 additions & 53 deletions
106
src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Is it meaningful for instrumentation factories to return null? This code suggests that we expect them to always return a non-null value
opentelemetry-dotnet/src/OpenTelemetry/Metrics/Builder/MeterProviderBuilderSdk.cs
Lines 125 to 138 in 535c819
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.
Good catch/question!
Short answer: Turns out that assert is based on invalid assumptions.
Long answer:
Today you can do this...
Everything will work fine. We don't actually validate that thing returned by the factory is non-null or access it in any way.
What will be logged out is:
SDK logs look like:
So
null
is possible today and allowed. There is thatDebug.Assert
in there, but that won't do anything for real code using release builds. That is only validating the repo's code doesn't return anull
anywhere. Could actually lead us to make the wrong decisions!It was probably an oversight to allow
null
in the first place, but in order to not break anything I annotated it as supported and made sure the code handles it well. If I go the other way and annotate it as not allowingnull
that could be breaking. We would get warnings in our code where we don't validate things (adding that validation would be breaking), and it may generate warnings for consumers and break their builds. Could also be binary breaking with annotations disapearing, not sure. In the end I decided just to embrace the behavior that we have in place.Thoughts?
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.
PS: Updated tests to make sure this case is captured.