-
Notifications
You must be signed in to change notification settings - Fork 773
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
Draft: Add ActivityEventAttachingLogProcessor to build ActivityEvents from logs in OpenTelemetry.Extensions #1907
Draft: Add ActivityEventAttachingLogProcessor to build ActivityEvents from logs in OpenTelemetry.Extensions #1907
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1907 +/- ##
==========================================
+ Coverage 83.89% 84.17% +0.27%
==========================================
Files 193 188 -5
Lines 6247 6092 -155
==========================================
- Hits 5241 5128 -113
+ Misses 1006 964 -42
|
<Import Project="$(RepoRoot)\build\CodeAnalysis.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net452;net461;netstandard2.0;net5.0</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious -is there a need to explicitly add net5.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new project so I figured it would be a good chance to use some of the new tooling. You saw CodeAnalysis.props I'm sure. That file is turning on Microsoft.CodeAnalysis.NetAnalyzers (the successor to Microsoft.CodeAnalysis.FxCopAnalyzers) & nullable reference types. The one bummer with nullable enabled is that VS only properly does analysis for netcoreapp3.1, netstandard2.1, and/or net5.0. If you turn it on for anything older, you get a lot of noise. So I added net5.0 to get proper analysis, it isn't used by any of the code directly. I know that sucks. I just moved it behind a Debug
condition, that way it won't be part of the release. Let me know what you think about that.
|
||
if (data.Exception != null) | ||
{ | ||
activity.RecordException(data.Exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use data.Timestamp
even for the exception event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't think so? It's a log event with an exception added. The timestamp of the log still feels valid to me, but I don't feel strongly about it.
@cijothomas FYI updated for the log scope changes. Also simplified the default state + scope converters. Looking for some feedback before I continue on with this. |
src/OpenTelemetry.Extensions/Logs/ActivityEventAttachingLogProcessorOptions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach and the feature LGTM.
Not marking explicit approval, as PR is draft. We could modify the readme.md in the extensions to document this feature (separate from this PR)
Also there are few unrelated changes to public api analyzers which can be done separately.
Moved to contrib. |
[Moved from #1833]
Fixes #1739
Changes
ActivityEventAttachingLogProcessor
which will convertLogRecord
objects intoActivityEvent
objects on theActivity.Current
instance.Considerations + Design
I wanted to allow users to push details from their
ILogger
structured logging into their traces but parsing state & scope(s) is an expensive operation. There are also many ways to approach it.Took inspiration from iSeiryu@c132085 & OpenTracing.Contrib.NetCore.
Public API
New assembly OpenTelemetry.Extensions
Examples
Example code:
No state, no scope, no message:
Message, no state, no scope:
State, no scopes, no message:
State + scopes, no message:
TODOs
CHANGELOG.md
updated for non-trivial changesREADME.md
updated about the feature