-
Notifications
You must be signed in to change notification settings - Fork 9
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
Import OpenTelemetry types rather than duplicate #659
Conversation
Use Typescript's `import type` and `export type` to include the OpenTelemetry types into our package without having to copy the code into our project directly. This was suggested by @unflxw in PR #651 (comment) I'm not sure if this is more or less fragile. If the OpenTelemetry package changes the interface we'd be shipping an older version that doesn't work with older versions anymore. The package from which we import is a dev dependency only, and used during the compile step, and won't ship as a dependency in the final release. I got an issue when using the OpenTelemetry SpanProcessor type for the `onEnd` function. It doesn't have a second argument. The `onStart` also needed another type, from `SpanContext` to `Context`.
@unflxw is this what you had in mind? |
@tombruijn Yes, this is what I had in mind :) I hoped we could remove the file in If possible, I'd wait for @jeffkreeftmeijer's input on this as well? There may be something I'm missing that makes the previous approach preferable. |
Ok, asking for a review from Jeff as well. |
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 added that interface to save us a dependency on @opentelemetry/sdk-trace-base
, to allow us to only depend on the types package, but this seems to make more sense indeed.
In PR #659 we tried to import the OpenTelemetry types at compile time and include them in our own package, but that's not how TypeScript's `import type` turns out to work. This breaks the app for non-OpenTelemetry users as reported in #684. The easiest fix we can ship right now is to add the package as a runtime dependency rather than only a development dependency. Ideally though, we do not ship additional dependencies for thing not all our users use, but we can figure that out after this immediate fix. I had missed this in PR #659, but we've also already included the `@opentelemetry/api` as a dependency since PR #651. Already doing the same this change does for the `@opentelemetry/sdk-trace-base` package.
In PR #659 we tried to import the OpenTelemetry types at compile time and include them in our own package, but that's not how TypeScript's `import type` turns out to work. This breaks the app for non-OpenTelemetry users as reported in #684. The easiest fix we can ship right now is to add the package as a runtime dependency rather than only a development dependency. Ideally though, we do not ship additional dependencies for thing not all our users use, but we can figure that out after this immediate fix. I had missed this in PR #659, but we've also already included the `@opentelemetry/api` as a dependency since PR #651. Already doing the same this change does for the `@opentelemetry/sdk-trace-base` package.
Use Typescript's
import type
andexport type
to include theOpenTelemetry types into our package without having to copy the code
into our project directly.
This was suggested by @unflxw in PR #651 (comment)
I'm not sure if this is more or less fragile. If the OpenTelemetry
package changes the interface we'd be shipping an older version that
doesn't work with older versions anymore.
The package from which we import is a dev dependency only, and used
during the compile step, and won't ship as a dependency in the final
release.
I got an issue when using the OpenTelemetry SpanProcessor type for the
onEnd
function. It doesn't have a second argument.The
onStart
also needed another type, fromSpanContext
toContext
.