-
Notifications
You must be signed in to change notification settings - Fork 539
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
fix!: export instrumentations only as named export #2296
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2296 +/- ##
==========================================
- Coverage 90.97% 90.30% -0.68%
==========================================
Files 146 147 +1
Lines 7492 7263 -229
Branches 1502 1509 +7
==========================================
- Hits 6816 6559 -257
- Misses 676 704 +28
|
Thanks for taking care of this. 🙂 As far as aligning export goes, I wonder if we should actually align them to be explicit exports (instead of wildcard exports) wherever possible. It has happened often that we accidentally add to the public interface by adding something to a file which in We can avoid these accidental exports by using explicit exports wherever we can (see also: open-telemetry/opentelemetry-js#4186) |
Thank you for the review This issue has a bit of history behind it:
All these decisions where made to prevent painful issues which had happen. I am open to discuss alternatives but personally think that using wildcard exports is the safest option, which also communicate the intent of these files to code readers / future maintainers, and reduces the chance of forgetting to export something important or exporting dev dependencies in the public api. |
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 see, thanks for the detailed response. I think in light of that info aligning it the way you did is the correct way then. 🙂
@@ -15,4 +15,4 @@ | |||
*/ | |||
|
|||
export * from './types'; | |||
export { DataloaderInstrumentation } from './instrumentation'; | |||
export * from './instrumentation'; |
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.
Didn't we actually want to move away from export * ...
if we didn't need it? open-telemetry/opentelemetry-js#4186
This PR is targets how we name and export instrumentation classes from our packages across the repo, and introduces consistency and best practices to align the code base.
It makes it so that:
Instrumentation
instead ofFooInstrumentation
)index.ts
file to export consistently - everything frominstrumentation.ts
andtype.ts
. This is to remove complexity and promote safe practices. This aligns the few places which were too complex, to an equivalent import and export statements to align with most packages in the repo.Benefits
index.ts
files and replace with shorter equivalents.types.ts
andinstrumentation.ts
files are intended to be user facing, and only export what the user is expected to consume. More on that in the GUIDELINES. Exporting everything from those files will prevent accidentally forgetting to add new types to theindex.ts
as happen in the pastBreaking Change
This PR is a breaking change by removing the default export for the following instrumentations:
fs
lru-memoizer
tedious
generic-pool
knex
memcahed
mysql2
restify
router
As state above, it is possible breaking change, but very unlikely for real users as this style is supported for only few instrumentations. It will be published as minor patch which should not be pulled automatically by users that has caret dependency, so they need to actively pull new version and will observe the transpilation failing.