Thoughts on supporting tracing
as alternative logging framework?
#505
Replies: 5 comments 4 replies
-
Hey @isaacdavis , thanks for bringing this up! I'll also let @ahl and @davepacheco chime in, but here are my first thoughts, for whatever they're worth: I think the idea to internally dispatch logs to one framework or the other seems reasonable, but I'm not sure I love the idea of making this a dynamic runtime flag (this means consumers will need to depend on both slog and tracing in all cases). This "choose your dependencies" behavior seems like it might be a better fit for a feature flag. This way, callers can opt into whichever flavor they want, and discard the alternative from a binary-size perspective. If we do this, then all the calls to I do think this might require some code to intercept the keys (which would have been provided to slog) and instead provide them to one of the two backends as appropriate, but if you think this is an easier approach then parsing them out of the slog KV object then that seems like it would be the way to go. TL;DR: I'm personally open to the attempt; logging is an auxiliary aspect to dropshot, and making the library more usable in more environments seems like a net win. |
Beta Was this translation helpful? Give feedback.
-
Hey @isaacdavis! I'm glad to see y'all are having a good experience with dropshot. Stepping back: I think my goals for dropshot logging are:
Now we're where we are because slog + bunyan + slog-dtrace ticked most of these boxes when we did this back in early 2020. But I haven't been following the space since then. What has you all excited about I'm also curious why it's impossible to adapt the existing slog-tracing shim, since it seems like slog is built to be extended in exactly this way (which was part of the appeal). If the most promising answer is (as I suspect) to somehow support both, I'm really curious what that would look like. Maybe a cheap first step would be to write a separate dummy library crate that supports both, with two consumers (one that uses each backend)? I think the bottom line is: we're definitely open to seeing what this looks like. I'm less excited if it means changing every use of all the slog macros and using some different pattern, but again, open to seeing what that looks like. And part of my reluctance is that slog is already supposed to be general enough that it seems like this shouldn't be necessary, so understanding that better would probably help me get over that. Thanks again. |
Beta Was this translation helpful? Give feedback.
-
Hi @davepacheco and @smklein! Thanks for your thoughtful answers to my inquiry. I set out to do my due diligence in answering all your questions, and in the process discovered some things that have me questioning whether tracing is the right choice for my team at all. A detailed response is below; here's the main concern: Tracing's pattern of routing logs to an implicit global or thread-local "subscriber" doesn't give the maintainer enough control of what information gets logged where. Workarounds, if possible, are convoluted. Slog's pattern of passing around explicit And now, the full write-up: Good things
We are still digging into its features, but the main thing that has stood out to us so far is the instrument attribute macro. This gives us a lot of what we want (logging function arguments/entry and exit points) without much boilerplate. This goes hand-in-hand with tracing's "span" construct, which we've found useful for human readability (though including request ids accomplishes much of the same). So far, we've found parity with slog in all the other features we've tried to use. I will candidly admit that we're also motivated by this message, especially since it's the first thing in the slog README! It looks like tracing
With tracing_bunyan_formatter, tracing can output log lines as bunyan-compatible json, e.g.:
Tracing has the same key/value construct as slog.
Tracing supports this.
Tracing can do this with its "default subscriber" construct.
Tracing supports this via the tracing_appender crate.
There are crates for sending tracing data to OpenTelemetry and Honeycomb.
Could you please explain what you have in mind here? Annoying, but do-able things
The macro syntax is slightly different but broadly equivalent. This means that we'd have to write some wrappers and do compile-time dispatching to the correct macro, as @smklein suggests.
I believe tracing supports this via its "Layer" construct -- it looks like layers can be conditionally activated. Note that someone (me?) would have to write a "tracing-dtrace" crate from scratch, similar to slog-dtrace.
I'm not sure if this exists! In the worst case, we could write our own tracing Bad things
So, Fixing this would require upstreaming a change to slog that introduces an iterator for the
This may be possible, but I think it's going to be surprisingly convoluted. The reason is that tracing doesn't have
This gives me a new appreciation for the control gained by passing around Next stepsSo, where does this leave me, and us? The lack of control imposed by the lack of If my team decides we still want to push for tracing, I'll see if I can get an iterator method added to the slog If that doesn't work out, I may push for getting dropshot to support tracing. Based on what I've laid out, are you all still amenable to me taking this on, or are there hard dealbreakers here?
I think this is a really good idea! This is how I will start, if we do go down this path. |
Beta Was this translation helpful? Give feedback.
-
您好, 您的邮件我已收到,我将尽快回复您。
|
Beta Was this translation helpful? Give feedback.
-
To return to this question a few years later, Is there any interest in moving these days? I haven't investigated how much work this would be, at all, but wanted to leave a comment before I forgot. |
Beta Was this translation helpful? Give feedback.
-
Hi all!
We at Fastly have run into an interesting quandary:
dropshot
for REST-servingtracing
for logging in our ecosystemslog
-based libraries to atracing
-based environment discards all key-value pairs from the slogRecord
when performing the conversion, which makes it useless to us!slog
itself.I am happy to further explain any of the points above.
Anyway:
Would you all be open to an attempt to add
tracing
as an alternative logging framework? Do you all reckon it's feasible to support two logging libraries at once, knowing the dropshot codebase better than I?I'd imagine this would involve adding a wrapper interface to be used internally to dispatch logs to whatever framework is active, as well some expansion of
ConfigLogging
to allow users to chooseslog
ortracing
. I can see lots of ways this could get too complicated, but would you be open to an attempt?Beta Was this translation helpful? Give feedback.
All reactions