At my employer, lob.com, we do use a middleware where we're able to then sort of, you know, create, like, a deny list of fields that we want to prevent from getting logged. So, for example, we don't want to log names and addresses. And so, there certainly are tools out there that can both either automatically automatically remove them or allow you to provide your own deny list.
You can just give some keys, like if this is the key, don't log the value, please. Which can be done by hand easily, too.
Next question is from the house of Alejandro. Awesome talk. Well, that's always nice to hear. Any recommendation or experience using logging for serverless functions, an example of Firebase functions or Google Cloud or AWS Lambda?
Sadly, I don't have much hands-on experience with serverless when it comes to logging. Certainly, tools like CloudFormation extract some of those logs for you. But at the end of the day, though, you can instantiate a logger that ships logs out to a different service. So, for example, you can have a Logstash instance listening on a port, which then receives UDP messages that contain JSON payloads, and you can transmit those messages to that listener from your serverless environment. So, that's a way to sort of push logs out, which might make it easier in a serverless situation.
All right. Let's see how much time we have left. Okay, next question is from David Lime. Can you recommend ways to instrument Node.js internals like event loop delays or GC frequency to send to the surfaces? That's a good question. I like that one. Yeah, absolutely you can. There are a bunch of different metrics that are exposed within Node itself, and so you can measure the size of the heap or some of the ones I recently introduced in a live application is the number of open file handlers and the number of concurrent connections on a web server. And so, off the top of my head, I don't know where those properties are located, but if you buy my book, certainly there's a section in there with a bunch of examples. Nice plug.
Next question is from 1LV4N what is the expected overhead of gathering logs, traces, etc in your system? Great, great question. So, things like metrics usually end up having a lower overhead because you know, like with the metrics, with the data you're sending to StatsD, you're actually just sending tiny strings of plain text that you're just dispatching using UDP, which has very, very minimal overhead. Even logs usually end up having fairly low overhead. You know, there's the cost of serializing the log, but usually that information is sent asynchronously and shouldn't really slow down the main components of the application. Tracing though, tracing can get a little bit heavier, especially if you're using like an automatic tracing solution. I believe the performance impact of that is going to be a little bit higher. So yeah, if you're using an automatic, like APM style tool, it's going to be instrumenting basically everything.
Comments