Missing @opentelemetry/api module at runtime when upgrading to 0.28.4
Just upgraded
drizzle-orm
to 0.28.4
, and running my project (after a successful typecheck) I get the error Cannot find module '@opentelemetry/api'
. Here is the full stack trace:
For reference I'm using PNPM and CJS32 Replies
Also I would like to know what is that
@opentelemetry/api
even doing in drizzle?+1 for this issue
I don't know the codebase very well, so I might be wrong about it, but from a quick glance it looks like they use it for tracing (seen here https://github.com/drizzle-team/drizzle-orm/blob/594e96538e588fee5748e372884dbaf32c331524/drizzle-orm/src/postgres-js/session.ts#L29). I've never used opentelemetry, but it looks like it keeps very minimal information (a name, timestamp, duration, and not much else) that I'd assume helps the Drizzle team debug issues and benchmark.
It also looks like (https://github.com/drizzle-team/drizzle-orm/blob/594e96538e588fee5748e372884dbaf32c331524/drizzle-orm/src/tracing.ts#L5) it is not required (although I don't know if it is an optional peer dependency or bundled with
drizzle-orm
), and for the record I don't see anywhere that would indicate the information is being sent anywhere.
Again, take this with a grain of salt, this is from about 5 minutes of going through the codebase/open telemetry docsGitHub
drizzle-orm/drizzle-orm/src/tracing.ts at 594e96538e588fee5748e3728...
TypeScript ORM that feels like writing SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
GitHub
drizzle-orm/drizzle-orm/src/postgres-js/session.ts at 594e96538e588...
TypeScript ORM that feels like writing SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
So... installing the package solves this. Should this not be a peer dependency?
Confused why this is a thing. Installing @opentelemetry/api until this is sorted I guess. 10/10 release
If it's used for what I think it is used for, it seems like it should be an optional peer dependency. That was my takeaway from the code in
tracing.ts
linked above, since they check if it exists and skip it if it doesn't.
Regardless, it's definitely a bug, I don't think Drizzle would require a peer dependency like that unless @bloberenober just wants to know all of our dirty little Can confirm installing it works
I ran into this, too
It’s not required and not used by us 😅
It came from one of beta releases to support opentelemetry for your projects
So if you need to check query execution for your apps, you can install this package and setup your credentials for that
After that it will send needed data you your OT instance
It shouldn’t be required, so I guess @bloberenober will check why the error is back
Drizzle ORM has 0 dependencies bundled, so nothing is required, unless you need specific driver to install
Yeah also getting this error🙈
Sending internal branch with fix to check
sorry, was working on checking this one
we will start doing beta/pre-prod/similar releases, I promise
Let's check and fix this one
give me 10 mins and I'll send you internal branch with fixes
drizzle-orm@types-bugs
Could someone please check this tag. It worked well for meseems to be working
good
need a few more approves, just to be sure
now i'm a bit confused because if i deploy my lambdas locally then it works but if i deploy it through the aws codepipeline then it breaks with the same error
You deploy same versions?
No cache, etc.?
yeah it should be the version
drizzle-orm@types-bugs
without any cacheNot sure how it’s possible. I just commented all opentelemetry code for now, because we will rewrite it anyway
GitHub
Types bugs by AndriiSherman · Pull Request #1107 · drizzle-team/dri...
The OTEL-specific functions have been removed from Postgres for now. They were added for testing purposes in the beta branch and were accidentally merged into the main branch. They have been left c...
i'll look into it a bit further, might be something on my side
I also had this issue this morning, but the
drizzle-orm@types-bugs
tag fixed it 🎉@here As @Andrew Sherman mentioned, the OpenTelemetry logic isn't meant to be used by Drizzle and no stats are collected by Drizzle. OpenTelemetry is simply a protocol. If you take a look at the actual code that uses it in
drizzle-orm
, it simply uses the tracer to collect the query stats and doesn't send it anywhere. It was designed for the ORM users to be able to send those stats to their own telemetry consumers.
The important thing is - the OpenTelemetry logic is disabled on the current version. It literally does nothing. We experimented with it at some point in the past, but disabled it before the release.
As to the reason of the current issue: it happens because of an incorrect type import on this line - https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/tracing.ts#L1. I've used import {type ... }
syntax instead of import type { ... }
, which resulted in the import '@opentelemetry/api'
line at runtime. This change was made some time ago and I have no idea why it became an issue only after the last release.
In any case, I've fixed the immediate issue by fixing the type import and deployed a new drizzle-orm@beta
version. Please test it and let me know if you still experience the error.It fixed it!
Fixed in
0.28.5
.Thanks for the quick fix y'all!
I had complete faith that Drizzle wasn't stealing my proprietary, horribly written, overcomplicated, truly first-of-their-kind SQL queries!
😅😅
I will ask though, it sounds like it's planned to be added back in the future. Will that be a way for us to trace how Drizzle is performing our own queries? Are the spans something we can use in our own queries to help document our performance? Never used opentelemetry but it seems like that's what it could be useful for
Nevermind, I completely missed the line where Dan explained exactly that
Yes, you are right
It will help to check all of that
For your app
And the where are bottlenecks or slow performance
We will add diagrams on how that works with all the examples, but in the future, after we will add a proper support for it
Great to know!
Hey I'm quite interested in this, where can we track progress/contribute?
Do you mean a fix for this or the implementation of @opentelemetry/api working?
The OTEL implementation is already there, it's just disabled for the time being because it was causing import issues. I plan to rework it to remove conditional imports from the code and move them to the user land.
But only the small part would need to be reworked, specifically the initialization
any updates on this, would love to contribute for it aswell if wanted?