-
Notifications
You must be signed in to change notification settings - Fork 837
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
Instrumentation "enabled" configuration inconsistent with OpenTelemetry #4651
Comments
By the way, the handling of I think a single
|
So the In this case, when will instrumentation |
I would never call I think It might be reasonable to expect that setting |
🤔 If we change this to Because of the potentially large impact on end users, I'd be more in favor of Option 2 to keep things as consistent as possible. As we look to stabilize, we may consider reversing the enabled/disabled flag and evangelizing it (similar to how we will need to do it with the http attributes). |
Is there a possible third option of implementing number 1, with a deprecated codepath that checks for |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
The "@opentelemetry/instrumentation" defines a generic InstrumentationConfig interface:
This interface defines an optional configuration for all instrumentations, named "enabled", with the default value "true". The default value is enforced In InstrumentationAbstract:
Which introduces the following issues:
Inconsistent With OpenTelemetry Specification
The OpenTelemetry specification for environment variables says:
The concept is applied in the specification with the
OTEL_SDK_DISABLED
env variable.Although this configuration is not an environment variable in the exact context, having the default value as
true
creates inconsistencies in the OpenTelemetry JS implementation which can be a source of confusions for end users and code maintainers, and increases cognitive load for consumers which should be aware of default values per use-case.For node-sdk implementation, the property is used with compliance to spec:
Harder to Maintain
When a user chooses not to set the
enabled
flag (which is very common) leaving it asundefined
, the implementation code needs to be aware of the default and make sure to use nullish-coalescing or some other fallback mechnisim everywhere it is accessed.This practice requires awareness which is not straightforward to comply with, as the
enabled
flag is a public API property and can be consumed in OpenTelemetry package but also by any user of the@opentelemetry/instrumentation
package.Buggy
The current implementation of
InstrumentationAbstract
assumes that the config object is sanitized in the constructor:And then read the value freely without checking for
undefined
and defaulting thetrue
. For example, the value is read as-is here.Since the logic to change enabled
undefined
totrue
is not applied in theInstrumentationAbstract
class withsetConfig
function:any call to
setConfig
will invalidate the assumption which is a bug. Even if we fix it for the base class, It is still extremely easy for instrumentation authors that overridesetConfig
to miss this nuance and introduce bugs to the implementation.Fix
I can think of 2 ways to fix this issue:
enabled
property todisabled
, and change the default value tofalse
. This will be a potential breaking change for the package which we can introduce at the moment but not after the package is stable.enabled
but fix the places where it is used, as well as add documentation for consumers on how to use it safely.I personally think that since the package is still experimental and breaking changes are allowed, it is a good opportunity to introduce changes that will promote consistent and robust use of the package.
Would love to hear more opinions and to work on changing this property if there isn't any push-back.
The text was updated successfully, but these errors were encountered: