datalust / serilog-sinks-seq

A Serilog sink that writes events to the Seq structured log server
https://datalust.co/seq
Apache License 2.0
225 stars 50 forks source link

Automatically recognize `SpanStartTimestamp`, `ParentSpanId`, and `SpanKind` from SerilogTracing #209

Closed nblumhardt closed 7 months ago

nblumhardt commented 7 months ago

SerilogTracing is a nice low-dependency way to light up Serilog output with timed/hierarchical traces. Its tracing output boils down to three properties, listed in the title.

There's currently a SerilogTracing.Sinks.Seq package that maps these three properties into underlying top-level compact JSON fields to send to Seq.

Since the whole thing is gated on the existence of SpanStartTimestamp, on a log event that is already marked with a trace and span id, adding support directly here seems reasonable: it's unlikely this will break any existing usage, and we'll avoid having to support yet another same-but-not-quite client library for people who want to use Serilog with tracing.

SpanStartTimestamp maps to @st, which Seq already recognizes, and this is the case for ParentSpanId mapping to @ps, also.

The @sk property name is not currently recognized by Seq and will be recorded verbatim; I'm expecting we'll either ignore or ingest this in 2024.2, and we'll have time to validate that decision before this sink reaches 7.0.0.