Skip to content
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

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

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

nblumhardt
Copy link
Member

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.


var skipSpanProperties = false;
if (logEvent is {TraceId: not null, SpanId: not null} &&
logEvent.Properties.TryGetValue("SpanStartTimestamp", out var st) &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept to the convention of using string literals in this file, since it makes the code easier to inspect (juggling hard-coded strings is pretty much all this class does :-) )

@KodrAus KodrAus merged commit 384b2d4 into datalust:dev Feb 21, 2024
1 check passed
@nblumhardt nblumhardt mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants