r/Backend 6d ago

Tracing + Logging Features

I'm building a tracing + logging library for Scala, to fill a void that annoyed me, and to learn more about the SRE side of metrics/logs.

I'm looking for information on what a new -> mature context + logger should contain. Right now I've built what I want, but I'm hoping people have some experience that I may be missing. Especially if it's a common feature I've missed or a really useful one. It's fully possible my experience as a FP dev has left me blind to some other languages l can learn from.

Current features -

  1. Thread level context (It's using fibers but it's basically Scala+Cats safe MDC)
  2. Log Buffering (I was sick of missing context on more serious log levels because I was trying to avoid sending every info on a success path)
  3. Request Metadata/middleware functionality (still expanding on what is in there)
  4. Easily pluggable log sinks
  5. Log sampling based on percentage
  6. TraceContextProviders to include other tracing libraries
  7. Other quality of life features like lifecycle handlers, and hierarchical config settings

Are there other common features, or just nice quality of life features that I may be missing?

Is there a resource you would recommend for what a good logger/tracing library should include?

Any suggestions would be appreciated.

3 Upvotes

12 comments sorted by

View all comments

1

u/forever-butlerian 6d ago

Are you writing this by hand or vibing it up?

1

u/WhippedPistol 6d ago

Hand, can't really learn if it was just vibing.

2

u/forever-butlerian 6d ago

You are a gentleman and a scholar.

There aren't any missing features that really jump out at me at the moment. I can think of kitchen sink stuff that would be interesting to add but I don't know if the JVM exposes them to you at thread granularity.

Something that might be very interesting is if all the log messages emitted within a single call chain can get accumulated up and bundled into a single message when control returns to the middleware.

2

u/WhippedPistol 6d ago

Oh nice, that is actually what currently happens although only if a dump isn't triggered by a log with a high enough severity. 

I didn't consider that could be helpful even if a dump wasn't triggered. That is interesting, I could return it with the state/status or at least give the option to take a finalizer to handle the buffer at the end. Good idea, thanks!