-
Notifications
You must be signed in to change notification settings - Fork 534
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: avoid type imports of the instrumented package in the built assets #1017
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1017 +/- ##
==========================================
- Coverage 95.91% 94.34% -1.57%
==========================================
Files 13 25 +12
Lines 856 1397 +541
Branches 178 280 +102
==========================================
+ Hits 821 1318 +497
- Misses 35 79 +44
|
Although I'm not sure we want to go through with this because of open-telemetry/opentelemetry-js#2256 |
I suspect we will need to do this with all or most of our instrumentations, making the generic sort of pointless. Maybe we can vendor the types ourselves? That would be a lot of work though. |
The generic is not used at all by @opentelemetry/instrumenation therefore I'm quite sure it would be possible to refactor the instrumentation setup in a way to hide this from public interface. But there are quite some instrumentations which offer hooks and these hooks use types as they pass data from the instrumented library via these hooks. We could use |
I agree |
I support doing this
I think for types in hooks the best option is to defer responsibility to the library author:
|
The implementation looks good to me, but the licensing I think we need to be careful of for vendoring outside code (especially code from a company like AWS). As an example, I looked into the aws-sdk-js types license. It is listed in https://github.com/aws/aws-sdk-js/blob/master/package.json#L87 as Apache-2.0 Full license available here: http://www.apache.org/licenses/LICENSE-2.0 The Apache-2.0 license allows redistribution of copyrighted works as long as the following conditions are met:
It seems to me that we at least have to add a copyright header at the top of the file stating it is apache-2.0 licenced and has not (or has it?) been modified. We must also retain the NOTICE.txt file https://github.com/aws/aws-sdk-js/blob/master/NOTICE.txt although we are allowed to append our own wording to it. Personally I would like to have someone with more legal knowledge look over it. Maybe we can get legal resources from the CNCF |
I reached out to the CNCF to see if we can get legal resources to ensure we're doing this correctly |
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.
Maybe in the future we can find some way to bring back a level of type safety without requiring dependencies for end users
Which problem is this PR solving?
#992 explains the issue very well in the context of NestJS instrumentation.
It turns out we have the same issue with importing following packages.
moved to fix: avoid type imports of the aws-sdk package in the built assets #1066aws-sdk
cassandra-driver
knex
mysql2
router
... and more that are not addressed in this PR.
To repro the issue one has to delete hoisted node_modules and do
npm i
in the metapackage.Short description of the changes
InstrumentationBase
andInstrumentationNodeModuleDefinition
generics now useany
,aws-sdk
andmysql2
implementation, how should I address any licensing topics?startSpan
on cassandra instrumentation private,See the issue referenced above.
I'm removing references to any types imported from the instrumented package from exported interfaces of the instrumentation.