-
Notifications
You must be signed in to change notification settings - Fork 803
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
feat(instrumentation): remove default value for config in base instrumentation constructor #4695
Conversation
Which is going the be the next change then that requires these additional parameters? what's the use case? |
@david-luna Thank you for the feedback.
Currently, one can extract the instrumentation npm package name and version from the instrumentation instance at runtime, which is useful for distributions to create tooling and report runtime statuses. There is currently an instrumentationDescription property for the instrumentation interface which I want to set as well. Other than that, it would be very useful to also include this metadata per instrumentation:
I intend to address these topics in follow-up PRs and issues, so we will have a chance to discuss them in depth. I also plan to use these new features to introduce some improvements to the
I also plan to use this information in odigos to report back instrumentation statuses to odigos control plane and auto-generate odigos documentation for the js instrumentations (so odigos users will have all the instrumentations info aggregated in one auto-generated markdown). Regardless of the above usecases, I think there are other valid reasons to make the config object required which are listed in PR description. |
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.
LGTM just minor wording nit in the changelog
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4695 +/- ##
==========================================
- Coverage 90.77% 89.79% -0.99%
==========================================
Files 90 149 +59
Lines 1930 3242 +1312
Branches 417 706 +289
==========================================
+ Hits 1752 2911 +1159
- Misses 178 331 +153
|
…mentation constructor (open-telemetry#4695) * fix(instrumentation)make config object required in base instrumentation * chore: CHANGELOG * fix: constructor pattern for instrumentations * chore: lint fix * Update experimental/CHANGELOG.md * Update experimental/CHANGELOG.md Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * Update CHANGELOG.md --------- Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
This PR makes the
config
object for base instrumentations (node + browser), required instead of optional with default value empty object.Motivation
The current implementation of instrumentation base classes requires a config object to be set. The 2 functions that accept a config object (constructor and
setConfig
) currently define the function parameter as optional, with default value{}
. This creates the following problems:{}
, but there is no typescript enforcement that the config object has only optional properties. Thus, this assumption may break and we neededas ConfigType
typescript casting to ignore this justified incompatibility.setConfig
is already defined as required in theInstrumentation
interface. Thus the definition of it as optional in theInstrumentationAbstract
implementaion is not consistent with the interface.enabled
flag.Change
constructor
signatures andsetConfig
signatures.Object.assign({}, config)
with{...config}
so we are consistent in both placesDistributions Considerations
This PR will make it so that instrumentations cannot be written like so:
Since the config object is now required. Even if
FooInstrumentation
does not offer any specific config options, thus might be tempted to exclude it altogether from the constructor, it makes it so users are not able to pass generic config object which definesenabled
value.Making the argument required, communicates that instrumentation need to pass a value and promote better-practices and more robust implementations. This has been aligned in contrib with open-telemetry/opentelemetry-js-contrib#2162
Breaking Change
config
object from the user.