serilog / serilog-sinks-opentelemetry

A Serilog OpenTelemetry Protocol (OTLP) sink
Apache License 2.0
117 stars 19 forks source link

A Serilog sink that'd use OpenTelemetry SDK #159

Open srogovtsev opened 1 week ago

srogovtsev commented 1 week ago

First, I want to make clear that this is not a feature request for Serilog.Sinks.OpenTelemetry, as this is very obviously contrary to its original design decision. It's just that I haven't found a better place to ask this question.

Is there any Serilog sink implementation that would rely on OpenTelemetry SDK?

The rationale is that if the system already uses OpenTelemetry SDK, the dependencies are not an issue, and going through the SDK for logs would allow them to share settings and, e.g., Resource definitions.

nblumhardt commented 1 week ago

Hi @srogovtsev!

I think @CodeBlanch had one of these in the works; I'm not sure where it landed, it may just be waiting to hit the top of the backlog :-) IIRC the project name was OpenTelemetry.Serilog.Sink.

If you're keen to dig in and put one of these together independently I'd be happy to help out. I don't have a use case for it myself so not much of an opportunity to dogfood, and no bandwidth to ship or maintain it, unfortunately, but I'm curious what it would look like and how smooth the integration can get.

srogovtsev commented 1 week ago

Let's say, I'm interested at trying my hand at it, but I don't know what my workload would be either. But in our particular case it might be a more reasonable approach than trying to adapt Serilog.Sinks.OpenTelemetry to all our needs.

srogovtsev commented 1 week ago

Were it not for the overhead, this could have been achieved by simply chaining Serilog.Sinks.ILogger and OpenTelemetry's own integration for M.E.L. But the overhead would be unreasonable.

srogovtsev commented 4 days ago

Just as a record, it seems that I was too hasty with this whole idea: OpenTelemetry 1.9.0 (the latest at the time of writing) is very closed WRT logging infrastructure, so doing this right now seems unfeasible. But I'll keep an eye on it, and also dig somewhat.

julealgon commented 4 days ago

OpenTelemetry 1.9.0 (the latest at the time of writing) is very closed WRT logging infrastructure, so doing this right now seems unfeasible.

What do you mean by that @srogovtsev ? Doesn't it expose an implementation of Microsoft.Extensions.Logging.ILogger?

srogovtsev commented 4 days ago

I mean that while it exposes an implementation of Microsoft.Extensions.Logging.ILogger, it doesn't expose telemetry-level primitives (i.e. there's no way to construct a LogRecord).

Using Microsoft.Extensions.Logging.ILogger will mean doing double conversion (first from Serilog to M.E.L, and then from M.E.L to OpenTelemetry), and not having ability to pass some data (e.g. Body or TraceId/SpanId) directly, which is also far from optimal.