-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Make debug diagnostic logger obsolete and add Trace diagnostic logger. #1048
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1048 +/- ##
==========================================
- Coverage 81.33% 81.17% -0.16%
==========================================
Files 193 194 +1
Lines 6338 6349 +11
Branches 1528 1530 +2
==========================================
- Hits 5155 5154 -1
- Misses 747 758 +11
- Partials 436 437 +1
Continue to review full report at Codecov.
|
private static TraceListener? GetFirstOrDefaultListener() | ||
{ | ||
var listeners = Trace.Listeners; | ||
return listeners.Count > 0 ? listeners[0] : null; |
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.
It works, not a fan of this line and linq doesn't work with listeners.
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.
Maybe we should write to all listeners, not just one?
src/Sentry/Sentry.csproj
Outdated
@@ -7,7 +7,7 @@ | |||
<RootNamespace>Sentry</RootNamespace> | |||
<Description>Official SDK for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.</Description> | |||
<NoWarn Condition="$(TargetFramework) == 'netstandard2.0'">$(NoWarn);RS0017</NoWarn> | |||
<DefineConstants>$(AdditionalConstants)</DefineConstants> | |||
<DefineConstants>$(AdditionalConstants);TRACE</DefineConstants> |
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.
Does the trace logger not work without TRACE
constant?
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.
I wonder if we're adding overhead to the SDK by setting this. We're not explicitly adding anything that depends on TRACE
constant being defined so I assume it wouldn't matter but it does make me wonder. Does it affect the size of the binary at all for example?
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.
Trace.Write/WriteLine doesn't work without the TRACE
trace constant. Trace.Listeners are exposed with or without the TRACE constant, but in my opinion, it's better to use set the TRACE constant and using the build-in Trace.Write instead of reinventing the wheel.
The package sizes are:
1,076,098 bytes with the TRACE constant
1,076,158 bytes without the TRACE constant and without the Trace Logger file
1,077,102 bytes without it.
1,077,858 bytes without the trace constant with the addition of a loop to write to all listeners.
1,080,993 bytes adding the DEBUG constant (out of curiosity, this allows the debug diagnostic logger to work properly in release)
src/Sentry/Sentry.csproj
Outdated
@@ -7,7 +7,7 @@ | |||
<RootNamespace>Sentry</RootNamespace> | |||
<Description>Official SDK for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.</Description> | |||
<NoWarn Condition="$(TargetFramework) == 'netstandard2.0'">$(NoWarn);RS0017</NoWarn> | |||
<DefineConstants>$(AdditionalConstants)</DefineConstants> | |||
<DefineConstants>$(AdditionalConstants);TRACE</DefineConstants> |
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.
I wonder if we're adding overhead to the SDK by setting this. We're not explicitly adding anything that depends on TRACE
constant being defined so I assume it wouldn't matter but it does make me wonder. Does it affect the size of the binary at all for example?
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
@lucas-zimerman and I talked on a call and decided to drop the constant and use the listeners. This is a logger for debug purposes and we don't wanta to add a trace constant to a release build |
…/getsentry/sentry-dotnet into feat/add-trace-diagnostic-logger
DebugDiagnosticLogger only works with projects inside Sentry.NET.snl since Release builds remove the Debug code, making it useless to the end-user.
Another approach is to use Trace as a replacement, it's not as simple as the good old DebugDiagnosticLogger but it should work just fine even in Release mode.
Close #1040.
It would be great if I could simply use Trace.Write but it seems like the compiler gets rid of it if not called from the current process.
EDIT: Validated on