-
Notifications
You must be signed in to change notification settings - Fork 13
Writing OpenTelemetry traces to Serilog logs #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Writing OpenTelemetry traces to Serilog logs #41
Conversation
3f6b24a
to
4ca0f31
Compare
@nblumhardt, I've updated this PoC with a few tests and a (very) small refactoring to SerilogTracing to show the minimal changes required to allow this functionality. Basically, we only need to expose a common activity writing method (I've decided to encapsulate it in a class as I expect there to be some configuration if we decide to move on with this), and then we get the OpenTelemetry front working with Serilog backend practically for free. Of course there's a lot of writing to be done on the exporter side to support the functionality expected by OpenTelemetry users, but that's fairly trivial. (I've decided to move the discussion here to avoid bloating #34) |
Thanks for the update @srogovtsev. We'll need some time to think though this approach, we're currently pushing on the core abstractions/API and will loop back to this once we have a bit more of the picture in view 👍 |
I put this out precisely so that you could consider this use case when pushing the core. Thanks! |
Sorry, I should have been more specific - we've run over the scenario in your PR, we're just not sure what the shape of the solution might be :-) |
This is totally fine by me! |
Hi Sergei, hope all's well. Just checking in, we've reviewed this scenario and don't think we'll provide an API directly for this, but there should still be a fairly straightforward way to do what you're after by relying on SerilogTracing conventions and implementing your own mapping from Keen to help unblock anything you hit if you still want to do something along these lines, just let me know. |
Hi, Nicholas, thank you for following up. While I'm still thinking in this direction, right now my main concern is that if the logging pipeline itself produces some activities (big example would be any sink using HttpClient when HttpClient instrumentation is on) we might end up in a feedback loop. Would you happen to have some recommendations on this? I know that, for example, Serilog.Sinks.Seq just suppresses the instrumentation (on some frameworks), but we do not control the sinks that we use (user can add their own in the configuration file). |
Thanks for the follow-up, Sergei. Right now, unfortunately, there's no generic way to suppress instrumentation in arbitrary Serilog sinks. This could almost be achieved using a sink wrapper (set an The problem is really a Serilog one, in that it applies to sinks that generate logs just as much as those that generate traces - it's just that it's easier to implicitly/unknowingly generate traces. It'd be reasonable to propose an upstream solution in Serilog, but I'll raise a new ticket here until we have some idea of what a solution (if any) would look like. |
Yes, batching was the first problem I thought of. |
This is not supposed to be merged, this is just an proof of concept I've mentioned in #34 (comment). Everything before 2bc12c7 is just a set-up.
To reiterate, the premise is the same as in #18:
So, the idea is simple: because we already use OpenTelemetry, and we happen to prefer its instrumentation for some dependencies we use, why don't we create an OpenTelemetry exporter that would output the traces captured by OpenTelemetry into Serilog logs? This allows us to avoid the configuration issues discussed in #34 and still get the nice logs we love Serilog for.
(there might be issues when combining OLTP logs and traces, but we'll get there when we get there)
Here's the example configuration (notice the lack of
TracingConfiguration
from SerilogTracing):And here's the output: