-
Notifications
You must be signed in to change notification settings - Fork 896
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
Explicitly allow fail-fast for invalid enum values #2766
Conversation
PTAL @open-telemetry/dotnet-maintainers |
The |
I think this ability to fail fast is particularly important for the .NET auto-instrumentation project, because it is the best way for us to provide something to our users to let them know that the configuration is bad and needs to be fixed. Alternative options would likely lead to potentially unexpected behavior, such as no telemetry data being available. With the .net auto-instrumentation project developers may not even have access to the warnings that could be generated from an invalid enum, depending on how their how responsibilities are separated (separate observability team vs direct control of observability). |
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 understand how would this proposal work - imagine the environment variable is used by some exporter, and that exporter is enabled at a later stage (e.g. the application is using some dynamic setting to allow exporters to be loaded and initialized), the wrong environment variable will cause the application to crash.
I made it explict that it cannot fail later at runtime; stolen from:
|
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
PTAL @open-telemetry/technical-committee @open-telemetry/specs-approvers |
I think this change results in more desirable behavior however it is not clear to me if this is an allowed breaking change or no. The document is marked as "Mixed" and there is no status in the "Enum value" section. For "Mixed" document do we implicitly assume unmarked sections to be "Stable" or "Experimental"? |
I think it is a backward compatible change as the old functionality is still acceptable per spec. Personally, I see it more as clarification (or even fix) as this meets the basic error handling guidelines.
The whole "Special configuration types" section is marked as "Stable". Then I would say that "Enum value" section is "Stable" as well. |
I updated the description to describe some background. |
I think this means this PR makes a breaking change to a "Stable" section of the spec. An application that previously would not fail can now fail after updating to a newer SDK that implements this change. That is not allowed. Now, there is one argument that can be made to still allow this change: .NET SDK already works as this PR describes - it fails fast. Question: what do other language SDKs do currently? Do they fail fast or ignore the invalid values? If all/most other SDKs also fail fast then I think we can say that the spec has a bug and what is written does not match the reality. |
That would be indeed a breaking change but in the SDK 😉 But I do not have a strong opinion here. |
@carlosalberto I have also a different question. Is "auto-instrumentation" seen as "SDK"? Maybe it is reasonable that some behavior in auto-instrumentation is different? E.g. fail-fast becasue the initializtion is done before the application is even started. I cannot find anything in the spec that would clarify it. @reyang @cijothomas I created open-telemetry/opentelemetry-dotnet#3690 |
@@ -21,7 +21,9 @@ If an SDK chooses to support an integer-valued environment variable, it SHOULD s | |||
### Enum value | |||
|
|||
For variables which accept a known value out of a set, i.e., an enum value, SDK implementations MAY support additional values not listed here. | |||
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. | |||
For variables accepting an enum value, if the user provides a value the SDK does not recognize, |
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 not sure why this behavior is only under Enum values, shouldn't there be a common error behavior for all env values? What if integer var is set to blah
?
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 was thinking about it as well, but I want to avoid scope creep in this PR. Even right now it is not clear how to proceed
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. | ||
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, | ||
or _fail fast_ and cause the application to fail at startup, but MUST NOT cause the application to fail later at run time. |
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 change is necessary - #2817 (comment)
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Why
For the auto-instrumentation scenario, we find that crashing the application in case of an invalid configuration is better. The reason is that it gives the users immediate feedback and forces them to fix the issue. Otherwise, it is likely that will find it when it is too late. For example, they want to analyze the telemetry when something strange is going on with the application; it would occur that someone typed
jeager
instead ofjaeger
forOTEL_TRACES_EXPORTER
, and because of that, they will miss spans in their backend.This is our preference in .NET Auto-Instrumentation. Reference:
What
Added
or cause the application to fail on initialization
possibility when the user provides an enum value the SDK does not recognize.AFAIK this is how the .NET SDK is working. See: https://github.com/open-telemetry/opentelemetry-dotnet/blob/a37198c6d0f1814f8f5a995413649436657a2e2b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs#L78
Changes
Make the enum value description compatible with the basic error handling principle:
opentelemetry-specification/specification/error-handling.md
Line 18 in 1fd2db2
I think it is a backward compatible change as the old behavior is still acceptable per spec.
FYI @open-telemetry/dotnet-instrumentation-approvers