Closed aroman closed 1 year ago
Hi @aroman,
Thank you for the fork and for raising this. I appreciate it.
Officially supporting serverless is definitely makes a lot of sense. I have added this to our internal tracking. I can't share a time estimate but I will keep you updated here once we support serverless officially.
The fork looks great. Thanks again for submitting it!
Hi @curusarn,
Any updates on this one?
Best regards, Magnus
Hi @magnuslundin,
Supporting serverless is still something we want to do. The task has moved the backlog but I don't have specific time estimate. I expect, we should get to it within the next 30 days or so.
Thanks for keeping in touch!
Best, Simon
Hello @aroman, thanks for bringing up the serverless support 🙌
Just wanted to clarify. I've tested logtail/node
in a serverless environment I had the easiest access to - AWS Lambda - and it worked just fine out of the box.
From the docs it seems that Cloudflare Workers run in their own workerd
runtime, but Vercel Serverless Functions run on node
. It seems that Vercel Serverless should be fine with logtail/node
just like AWS Lambda, right? Have you tried it as well, or did you test Cloudflare only?
I'll double-check, but if it's mainly for Cloudflare Worker support, I'd go with naming it logtail/workerd
. From your fork it looks like there is not much changes required, so it's definitely worthwhile 👍
@PetrHeinz yes, cloudflare workers and other "edge" runtimes are quite a bit different than the older "serverless" offerings like lamba.
1) re:serverless vs edge modern edge runtimes (cloudflare workers, deno) do not boot full nodejs instances, but typically run much lighter-weight runtimes, e.g. V8 isolates, which do not implement the full nodejs API, but have the advantage of essentially instant startup times, eliminating the "cold start" problem which impacts traditional serverless offerings. This article offers a great high-level overview of the architecture.
2) re:changes needed for this module In practice, making this (or any) javascript module work in an edge computing runtime (cloudflare workers, deno) is simply a matter of NOT using nodejs APIs, and instead only utilizing the JS standard library, for example using the built-in fetch
instead of e.g. http.request()
.
that's exactly what I did in our fork of this library. we are using it happily in production on cloudflare workers, running in the workerd
environment.
3) re:naming you could call it logtail/workerd
, or i've also seen <name>/edge
, such as this fork of openai's nodejs package. in the past few weeks, openai rewrote their npm package from scratch to offer first-class support for edge runtimes like cloudflare, so that package is soon to be no longer needed, but we and i'm sure many others are still using it in production for the time being.
hope this helps!
Hello, @aroman, @Ehesp, @magnuslundin, I just released a new package @logtail/edge for logging in Edge runtime (tested in Cloudflare Worker). If you find any issue or inconsistency, feel free to open an issue or a PR 🙏
Thanks @aroman for sharing your fork and feedback 👍
Awesome will give it a go!
Hey!
I saw y'all have been active on this repo lately, so wanted to make sure I raised this :)
tl;dr this library should offer support for using logtail in modern serverless environments like Cloudflare Workers.
I forked your node logger to do this, and have been using it in our product, you can see the changes here: https://github.com/logtail/logtail-js/compare/master...magic-circle-studio:logtail-js-cfworker:master, and you can play with it on NPM here: @magiccircle/logtail-cfworker
Of course, it was just a quick and dirty have, and I don't really want to be maintaining a fork — but it does work nicely so far.
My suggestion is that you introduce a new package, like
node
orbrowser
, which is designed to run in serverless environments. You could perhaps call it "edge" or "workers". Then, I could use it like@logtail/edge
.As you can see, there isn't really anything new to add to support these environments — it's more a matter of slightly switching types and avoiding using node-specific libraries like
fs
.Let me know if you have any thoughts!