opentelemetry-dotnet
opentelemetry-dotnet copied to clipboard
Implement Serilog Activity enricher
Fixes #3453.
Changes
Implement a Serilog enricher which adds the SpanId
, TraceId
, ParentSpanId
and ActivityTraceFlags
properties to log events when the Activity.Current
is not null, otherwise, these properties are not added
For significant contributions please make sure you have completed the following items:
- [ ] Appropriate
CHANGELOG.md
updated for non-trivial changes - [ ] Design discussion issue #
- [ ] Changes in public API reviewed
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: wilsonrivera / name: Wilson (f94968734b94c9ed9384ff57d819b679a68a02a3)
Oh no :/ I made the changes on my 'main' branch and didn't notice until now, I hope it doesn't matter
Codecov Report
Merging #3546 (ea28962) into main (d1da1d6) will decrease coverage by
0.01%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## main #3546 +/- ##
==========================================
- Coverage 87.44% 87.43% -0.02%
==========================================
Files 278 279 +1
Lines 10087 10098 +11
==========================================
+ Hits 8821 8829 +8
- Misses 1266 1269 +3
Impacted Files | Coverage Δ | |
---|---|---|
...Extensions.Serilog/OpenTelemetrySerilogEnricher.cs | 100.00% <100.00%> (ø) |
|
...tensions.Serilog/OpenTelemetrySerilogExtensions.cs | 100.00% <100.00%> (ø) |
|
src/OpenTelemetry/ProviderExtensions.cs | 81.81% <0.00%> (-9.10%) |
:arrow_down: |
...Telemetry/Metrics/PeriodicExportingMetricReader.cs | 72.72% <0.00%> (-5.46%) |
:arrow_down: |
src/OpenTelemetry/Logs/Pool/LogRecordSharedPool.cs | 97.36% <0.00%> (-2.64%) |
:arrow_down: |
src/OpenTelemetry/BatchExportProcessor.cs | 84.11% <0.00%> (+1.86%) |
:arrow_up: |
@CodeBlanch I am now unsure if this is something OTel repo should provide? Its like a general serilog enricher, for enriching with Activity.Current
. This does not have anything to do with sending serilog logs via OTel pipeline 🙌
@CodeBlanch I am now unsure if this is something OTel repo should provide? Its like a general serilog enricher, for enriching with
Activity.Current
. This does not have anything to do with sending serilog logs via OTel pipeline 🙌
After a small Google search, I found out this https://github.com/RehanSaeed/Serilog.Enrichers.Span project which seems to do exactly just this, could be a better solution in the long run
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.
@wilsonrivera We should probably update the README a bit to explain the different things offered, use cases, etc. Feel like taking that on?
@cijothomas There is a bit on #3453 about the use case. I think this would be good to have. Why? Just to be helpful 🤣 Once a package with "OpenTelemetry" & "Serilog" exists on NuGet people will just naturally look there for this type of thing and it being from the same repo yields some confidence it will work correctly with everything else. Just my opinion!
Yeah, I can do that!
@wilsonrivera An update... we discussed on the weekly .NET SIG call today this PR and we have decided that it is good to be included. Later on we will likely move this project to the "contrib" repo and we might give it a dedicated package at that time, or we might try to contribute to serilog itself, but we don't need to tackle that now. I think we just need to do README updates and then we can get this merged.
@wilsonrivera An update... we discussed on the weekly .NET SIG call today this PR and we have decided that it is good to be included. Later on we will likely move this project to the "contrib" repo and we might give it a dedicated package at that time, or we might try to contribute to serilog itself, but we don't need to tackle that now. I think we just need to do README updates and then we can get this merged.
Not sure the best place to ask this... but when we should end-users (e.g. myself) expect to get a prerelease NuGet package for OpenTelemetry.Extensions.Serilog? I tried copying the code but it won't build because it uses internal classes. Our project is invested in Serilog, and logging associated with traces is the last thing we need in our OTEL evaluation.
@pdonovan I spun up an issue to track your question: #3602
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.
Closed as inactive. Feel free to reopen if this PR is still being worked on.
Sorry for the delay, life got in the way but I've wrote a little documentation on how to setup the activity enricher, directly on the Serilog project
Sorry for the delay, life got in the way but I've wrote a little documentation on how to setup the activity enricher, directly on the Serilog project
Link? I had a quick look around the GitHub serilog pages but couldn't find anything.