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

FormatException is thrown when an invalid env var value is set #3690

Closed
pellared opened this issue Sep 22, 2022 · 7 comments · Fixed by #4099
Closed

FormatException is thrown when an invalid env var value is set #3690

pellared opened this issue Sep 22, 2022 · 7 comments · Fixed by #4099
Assignees
Labels
bug Something isn't working pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Milestone

Comments

@pellared
Copy link
Member

pellared commented Sep 22, 2022

According the OTel spec:

For variables accepting an enum value, if the user provides a value the SDK does not recognize, the SDK MUST generate a warning and gracefully ignore the setting.

This is not what is done in multiple places like here.

Moreover, because of this, it won't be easy to set defaults for these values in .NET Automatic Instrumentation.

Can/do we want to address this? Won't it be seen as a breaking change?

Reference: open-telemetry/opentelemetry-specification#2766

CC @reyang @cijothomas @CodeBlanch

@pellared pellared added bug Something isn't working pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Sep 22, 2022
@reyang
Copy link
Member

reyang commented Sep 22, 2022

This is not what is done in multiple places like here.

The link is broken?

Moreover, because of this, it won't be easy to set defaults for these values in .NET Automatic Instrumentation.

Can/do we want to address this? Won't it be seen as a breaking change?

This looks like an implementation bug to me. Guess the fix should be swallow the exception and fallback to a default value. Doesn't sound like a breaking change.

@pellared
Copy link
Member Author

pellared commented Sep 26, 2022

@reyang Thanks. I fixed the link. Feel free to hide/delete this comment

@moonbox3
Copy link
Contributor

I see in the example code you linked to @pellared, the Protocol property has a default value (OtlpExportProtocol.Grpc):

public OtlpExportProtocol Protocol { get; set; } = DefaultOtlpExportProtocol;

Based on @reyang's comment to swallow the exception and fallback to a default value would mean we can essentially remove the else block where the FormatException is thrown, correct? Thus, the code would attempt to parse the proper protocol, and if it can't, the fallback value will be that default value of OtlpExportProtocol.Grpc.

I'm new to the project and if my understanding is incorrect, please let me know. If my understanding is correct, I can work on the fix. Thanks!

@moonbox3
Copy link
Contributor

@pellared I've been looking through the code and it looks like this issue has been handled in the following PRs:

I've done a more thorough search for any remaining clean-up that may be needed and I am not finding anything. It feels safe to close this issue.

@pellared
Copy link
Member Author

Thanks

@pellared
Copy link
Member Author

@moonbox3 Reopening; see:

Also the docs are not updated (find: FormatException)

There are even some tests which checks if FormatException is thrown.

@pellared pellared reopened this Nov 28, 2022
@pellared pellared added this to the 1.4.0 milestone Nov 28, 2022
@TimothyMothra
Copy link
Contributor

Hi, I'm interested in working on this.
Seems pretty straightforward, I found the tests and the related docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants