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

Propagate current trace and span ids through LogEvent #409

Merged

Conversation

consulting-dev
Copy link
Contributor

Description

Activity class is essential part of distributed tracing and log correlation, see: https://learn.microsoft.com/en-us/dotnet/core/diagnostics/distributed-tracing.

Activity class by default is created for each asp net request. It produces fields like TraceId and SpanId which helps to identify and correlate calls across multiple services (its automatically included by HttpClient as well) without writing any additional code.

So far emitting these fields was implemented few years ago in Serilog JsonFormatter, see: https://github.com/serilog/serilog/blob/dev/src/Serilog/Formatting/Json/JsonFormatter.cs#L74-L84 .

In my opinion - Http text formatters should also include these fields by default without a need to make custom overrides.

These fields are essential for tracing and correlating log messages.
It also included in default Serilog JsonFormatter:
https://github.com/serilog/serilog/blob/dev/src/Serilog/Formatting/Json/JsonFormatter.cs#L74-L84
@FantasticFiasco
Copy link
Owner

Hi @consulting-dev, I'll look into this during the week.

@FantasticFiasco FantasticFiasco self-assigned this Jan 19, 2025
@FantasticFiasco FantasticFiasco merged commit 8f1730a into FantasticFiasco:main Jan 19, 2025
@consulting-dev consulting-dev deleted the feature/trace-span-ids branch January 19, 2025 07:36
@consulting-dev
Copy link
Contributor Author

Thank you for approving and merging.
Any idea, when this could be released?

@FantasticFiasco
Copy link
Owner

Right about now :-) It's validating, in a few minutes it will be official.

Thanks for the contribution!

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.

2 participants