@@ -984,9 +984,9 @@ internal long TrySNIScopeEnterEvent(string className, [System.Runtime.CompilerSe
984
984
{
985
985
if ( Log . IsSNIScopeEnabled ( ) )
986
986
{
987
- StringBuilder sb = new StringBuilder ( className ) ;
988
- sb . Append ( "." ) . Append ( memberName ) . Append ( " | SNI | INFO | SCOPE | Entering Scope {0 }") ;
989
- return SNIScopeEnter ( sb . ToString ( ) ) ;
987
+ long scopeId = Interlocked . Increment ( ref s_nextSNIScopeId ) ;
988
+ WriteEvent ( SNIScopeEnterId , $ " { className } . { memberName } | SNI | INFO | SCOPE | Entering Scope { scopeId } ") ;
989
+ return scopeId ;
990
990
}
991
991
return 0 ;
992
992
}
@@ -1017,7 +1017,6 @@ internal void BeginExecute(int objectId, string dataSource, string database, str
1017
1017
[ Event ( EndExecuteEventId , Keywords = Keywords . ExecutionTrace , Task = Tasks . ExecuteCommand , Opcode = EventOpcode . Stop ) ]
1018
1018
internal void EndExecute ( int objectId , int compositestate , int sqlExceptionNumber , string message )
1019
1019
{
1020
-
1021
1020
WriteEvent ( EndExecuteEventId , objectId , compositestate , sqlExceptionNumber , message ) ;
1022
1021
}
1023
1022
@@ -1130,10 +1129,17 @@ internal static class EventType
1130
1129
private readonly long _scopeId ;
1131
1130
1132
1131
public TrySNIEventScope ( long scopeID ) => _scopeId = scopeID ;
1133
- public void Dispose ( ) =>
1134
- SqlClientEventSource . Log . SNIScopeLeave ( string . Format ( "Exit SNI Scope {0}" , _scopeId ) ) ;
1132
+ public void Dispose ( )
1133
+ {
1134
+ if ( _scopeId == 0 )
1135
+ {
1136
+ return ;
1137
+ }
1138
+ SqlClientEventSource . Log . TrySNIScopeLeaveEvent ( _scopeId ) ;
1139
+ }
1135
1140
1136
- public static TrySNIEventScope Create ( string message ) => new TrySNIEventScope ( SqlClientEventSource . Log . SNIScopeEnter ( message ) ) ;
1141
+ public static TrySNIEventScope Create ( string className , [ System . Runtime . CompilerServices . CallerMemberName ] string memberName = "" )
1142
+ => new TrySNIEventScope ( SqlClientEventSource . Log . TrySNIScopeEnterEvent ( className , memberName ) ) ;
1137
1143
}
1138
1144
1139
1145
internal readonly ref struct TryEventScope //: IDisposable
0 commit comments