Skip to content

Commit 950b7eb

Browse files
committed
ref: review fixes
1 parent 58a51b6 commit 950b7eb

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static void LogDebug<TArg, TArg2>(
1717
string message,
1818
TArg arg,
1919
TArg2 arg2)
20-
=> logger.LogIfEnabled(SentryLevel.Debug, message, arg, arg2);
20+
=> logger.LogIfEnabled(SentryLevel.Debug, message, arg, arg2);
2121

2222
public static void LogDebug(
2323
this IDiagnosticLogger logger,
@@ -40,7 +40,7 @@ public static void LogInfo<TArg, TArg2>(
4040
string message,
4141
TArg arg,
4242
TArg2 arg2)
43-
=> logger.LogIfEnabled(SentryLevel.Info, message, arg, arg2);
43+
=> logger.LogIfEnabled(SentryLevel.Info, message, arg, arg2);
4444

4545
public static void LogWarning(
4646
this IDiagnosticLogger logger,

src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public object ExtractPayload(IHttpRequest request)
3131
case RequestSize.Small when request.ContentLength < 1_000:
3232
case RequestSize.Medium when request.ContentLength < 10_000:
3333
case RequestSize.Always:
34-
_options.DiagnosticLogger.LogDebug("Attempting to read request body of size: {0}, configured max: {1}.",
34+
_options.DiagnosticLogger?.LogDebug("Attempting to read request body of size: {0}, configured max: {1}.",
3535
request.ContentLength, size);
3636

3737
foreach (var extractor in Extractors)
@@ -50,14 +50,13 @@ public object ExtractPayload(IHttpRequest request)
5050
break;
5151
// Request body extraction is opt-in
5252
case RequestSize.None:
53-
_options.DiagnosticLogger.LogDebug("Skipping request body extraction.");
54-
break;
55-
default:
56-
_options.DiagnosticLogger.LogWarning("Ignoring request with Size {0} and configuration RequestSize {1}",
57-
request.ContentLength, size);
53+
_options.DiagnosticLogger?.LogDebug("Skipping request body extraction.");
5854
break;
5955
}
6056

57+
_options.DiagnosticLogger?.LogWarning("Ignoring request with Size {0} and configuration RequestSize {1}",
58+
request.ContentLength, size);
59+
6160
return null;
6261
}
6362
}

src/Sentry/Internal/Web/SystemWebRequestEventProcessor.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public SentryEvent Process(SentryEvent @event)
3434

3535
foreach (var key in context.Request.Headers.AllKeys)
3636
{
37-
3837
if (!_options.SendDefaultPii
3938
// Don't add headers which might contain PII
4039
&& (key == "Cookie"
@@ -47,6 +46,13 @@ public SentryEvent Process(SentryEvent @event)
4746

4847
if (_options?.SendDefaultPii == true)
4948
{
49+
if (@event.User.Username == Environment.UserName)
50+
{
51+
// if SendDefaultPii is true, Sentry SDK will send the current logged on user
52+
// which doesn't make sense in a server apps
53+
@event.User.Username = null;
54+
}
55+
5056
@event.User.IpAddress = context.Request.UserHostAddress;
5157
if (context.User.Identity is IIdentity identity)
5258
{
@@ -79,14 +85,7 @@ public SentryEvent Process(SentryEvent @event)
7985
{
8086
@event.Contexts["server-os"] = os;
8187
}
82-
83-
if (_options?.SendDefaultPii == true && @event.User.Username == Environment.UserName)
84-
{
85-
// if SendDefaultPii is true, Sentry SDK will send the current logged on user
86-
// which doesn't make sense in a server apps
87-
@event.User.Username = null;
88-
}
89-
88+
9089
var body = PayloadExtractor.ExtractPayload(new SystemWebHttpRequest(context.Request));
9190
if (body != null)
9291
{

0 commit comments

Comments
 (0)