Skip to content

Commit 4cfe213

Browse files
afifi-insmconnew
authored andcommitted
Update ExceptionTrace max string length
1 parent 382c37d commit 4cfe213

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/System.ServiceModel.Primitives/src/Internals/System/Runtime/ExceptionTrace.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace System.Runtime
1515
internal class ExceptionTrace
1616
{
1717
private const ushort FailFastEventLogCategory = 6;
18+
internal const int MaxExceptionStringLength = 28 * 1024;
1819
private string _eventSourceName;
1920
private readonly EtwDiagnosticTrace _diagnosticTrace;
2021

@@ -34,21 +35,21 @@ public void TraceEtwException(Exception exception, EventLevel eventLevel)
3435
case EventLevel.Warning:
3536
if (WcfEventSource.Instance.ThrowingEtwExceptionIsEnabled())
3637
{
37-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
38+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
3839
WcfEventSource.Instance.ThrowingEtwException(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException);
3940
}
4041
break;
4142
case EventLevel.Critical:
4243
if (WcfEventSource.Instance.EtwUnhandledExceptionIsEnabled())
4344
{
44-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
45+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
4546
WcfEventSource.Instance.EtwUnhandledException(exception != null ? exception.ToString() : string.Empty, serializedException);
4647
}
4748
break;
4849
default:
4950
if (WcfEventSource.Instance.ThrowingEtwExceptionVerboseIsEnabled())
5051
{
51-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
52+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
5253
WcfEventSource.Instance.ThrowingEtwExceptionVerbose(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException);
5354
}
5455

@@ -64,21 +65,21 @@ public void TraceEtwException(Exception exception, TraceEventType eventLevel)
6465
case TraceEventType.Warning:
6566
if (WcfEventSource.Instance.ThrowingEtwExceptionIsEnabled())
6667
{
67-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
68+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
6869
WcfEventSource.Instance.ThrowingEtwException(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException);
6970
}
7071
break;
7172
case TraceEventType.Critical:
7273
if (WcfEventSource.Instance.EtwUnhandledExceptionIsEnabled())
7374
{
74-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
75+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
7576
WcfEventSource.Instance.EtwUnhandledException(exception != null ? exception.ToString() : string.Empty, serializedException);
7677
}
7778
break;
7879
default:
7980
if (WcfEventSource.Instance.ThrowingEtwExceptionVerboseIsEnabled())
8081
{
81-
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue);
82+
string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength);
8283
WcfEventSource.Instance.ThrowingEtwExceptionVerbose(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException);
8384
}
8485

0 commit comments

Comments
 (0)