-
Notifications
You must be signed in to change notification settings - Fork 793
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
remove unreachable ?? new ConsoleExporterOptions() in ConsoleExporter #6079
base: main
Are you sure you want to change the base?
remove unreachable ?? new ConsoleExporterOptions() in ConsoleExporter #6079
Conversation
…s()-in-ConsoleExporter
…s()-in-ConsoleExporter
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6079 +/- ##
==========================================
- Coverage 86.39% 86.39% -0.01%
==========================================
Files 257 257
Lines 11640 11639 -1
==========================================
- Hits 10056 10055 -1
Misses 1584 1584
|
…s()-in-ConsoleExporter
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 am fine with this change, but there is one comment to this.
Historically, this project was released without Nullability check. When introduced, this kind of checks stays in place to avoid any hidden breaking changes. What is more, it is still possible to pass null here by null forgiving operator !
/disabling nullability in the project. IMO the problem is similar to the Debug.Assert discussed in #6101
@@ -10,7 +10,7 @@ public abstract class ConsoleExporter<T> : BaseExporter<T> | |||
|
|||
protected ConsoleExporter(ConsoleExporterOptions options) | |||
{ | |||
this.options = options ?? new ConsoleExporterOptions(); | |||
this.options = options; |
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 don't think this is the correct direction.
This is a public API. We can't control what users will pass it. Even though we say it shouldn't be null
(via the nullable annotations), it is still possible for users to pass null
.
It probably should have been written like this:
protected ConsoleExporter(ConsoleExporterOptions options)
{
Guard.ThrowIfNull(options);
this.options = options;
}
But technically a breaking change to do now.
If we really want to clean up the oddity, why not just embrace the fact that it allows null
?
- protected ConsoleExporter(ConsoleExporterOptions options)
+ protected ConsoleExporter(ConsoleExporterOptions? options)
{
this.options = options ?? new ConsoleExporterOptions();
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.
More to consider:
- OTLP Exporter - Debug.Assert
- Zipkin Exporter - Guar.ThrowIfNull
- Prometheus Exporter - Gurad.ThrowIfNull
- In Memory - no options class
I would say that we should have common behavior in all these exporters. I do no think that adding support for null value will be the best option. The question is, if the constructor behavior can be changes and it can throw the exception.
If we decide to go this way, OTLP Exporter should be also modified. IMO worth to add a changelog note, that the behavior was fixed/changed.
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.
Should we bundle this kind of "minor" breaking change with other breaking changes in a future major version? Or it's ok to just go and change them now?
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
…s()-in-ConsoleExporter
Fixes #
Design discussion issue #
Changes
since it cant be null
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes