Hmm unless I'm missing something, this
Hmm unless I'm missing something, this doesn't seem to be possible? It'd be really helpful to be able to develop locally and see the metrics to help designing database and estimating costs.
.all
and .batch
do return those metrics, but it's very intrusive to modify your code.8 Replies
Hey - just a tech writer here (not a D1 expert yet)
https://developers.cloudflare.com/d1/platform/pricing/#how-can-i-estimate-my-eventual-bill
This might be helpful - like you mentioned, .all, .batch, .exec returns the meta object which has rows_read
Yeah that definitely can work, but I'd prefer a less intrusive way.
.first
doesn't provide meta for example, so I would need to rewrite the code to use .all
(which obviously has different behavior) or wrap it in a .batch
.Hmm yeah I see what you mean. You're right, it's likely to require some code tweaking (but hopefully nothing too large?)
For "less intrusive", did you have in mind something like a Wranger command?
Well if there's no way, I'd probably have my own abstraction on top so it won't affect my code. But yeah, it's not ideal that I now have to maintain my own layer of abstraction.
Correct me if I'm wrong, the local dev environment uses the same runtime as the actual Cloudflare edge network right? So I would assume the same metric tracking code used for billing is also present locally, and they are just not collected/exposed. Ideally it would be nice to have them also available in some form when doing
wrangler dev --local
.I'm not 100% sure on how it works behind the scenes. But thanks for the suggestion, I'll flag it to the team at least.
On a tangential note - we're working to improve the layout of the docs regarding APIs, stay tuned for an update on the docs 😄
Oh yeah that's something I've noticed as well, comparing to other dev products where there's a dedicated page for the APIs, D1 doesn't have it and is instead in https://developers.cloudflare.com/d1/build-with-d1/d1-client-api/ page.
Yup - we'll get that improved soon!
Following up on this - https://developers.cloudflare.com/d1/worker-api/ 😄
Nice.