@@ -68,6 +68,8 @@ internal virtual void ReclaimedConnectionRequest() { /*no-op*/ }
6868 #endregion
6969 }
7070
71+ // Any changes to event writers might be considered as a breaking change.
72+ // Other libraries such as OpenTelemetry and ApplicationInsight have based part of their code on BeginExecute and EndExecute arguments number.
7173 [ EventSource ( Name = "Microsoft.Data.SqlClient.EventSource" ) ]
7274 internal partial class SqlClientEventSource : SqlClientEventSourceBase
7375 {
@@ -510,22 +512,20 @@ internal void TryScopeLeaveEvent(long scopeId)
510512
511513 #region Execution Trace
512514 [ NonEvent ]
513- internal void TryBeginExecuteEvent ( int objectId , Guid ? connectionId , string commandText , [ System . Runtime . CompilerServices . CallerMemberName ] string memberName = "" )
515+ internal void TryBeginExecuteEvent ( int objectId , string dataSource , string database , string commandText , Guid ? connectionId , [ System . Runtime . CompilerServices . CallerMemberName ] string memberName = "" )
514516 {
515517 if ( Log . IsExecutionTraceEnabled ( ) )
516518 {
517- BeginExecute ( GetFormattedMessage ( SqlCommand_ClassName , memberName , EventType . INFO ,
518- string . Format ( "Object Id {0}, Client Connection Id {1}, Command Text {2}" , objectId , connectionId , commandText ) ) ) ;
519+ BeginExecute ( objectId , dataSource , database , commandText , GetFormattedMessage ( SqlCommand_ClassName , memberName , EventType . INFO , $ "Object Id { objectId } , Client connection Id { connectionId } , Command Text { commandText } ") ) ;
519520 }
520521 }
521522
522523 [ NonEvent ]
523- internal void TryEndExecuteEvent ( int objectId , Guid ? connectionId , int compositeState , int sqlExceptionNumber , [ System . Runtime . CompilerServices . CallerMemberName ] string memberName = "" )
524+ internal void TryEndExecuteEvent ( int objectId , int compositeState , int sqlExceptionNumber , Guid ? connectionId , [ System . Runtime . CompilerServices . CallerMemberName ] string memberName = "" )
524525 {
525526 if ( Log . IsExecutionTraceEnabled ( ) )
526527 {
527- EndExecute ( GetFormattedMessage ( SqlCommand_ClassName , memberName , EventType . INFO ,
528- string . Format ( "Object Id {0}, Client Connection Id {1}, Composite State {2}, Sql Exception Number {3}" , objectId , connectionId , compositeState , sqlExceptionNumber ) ) ) ;
528+ EndExecute ( objectId , compositeState , sqlExceptionNumber , GetFormattedMessage ( SqlCommand_ClassName , memberName , EventType . INFO , $ "Object Id { objectId } , Client Connection Id { connectionId } , Composite State { compositeState } , Sql Exception Number { sqlExceptionNumber } ") ) ;
529529 }
530530 }
531531 #endregion
@@ -995,13 +995,22 @@ internal void TrySNIScopeLeaveEvent(long scopeId)
995995 #endregion
996996
997997 #region Write Events
998+ // Do not change the first 4 arguments in this Event writer as OpenTelemetry and ApplicationInsight are relating to the same format,
999+ // unless you have checked with them and they are able to change their design. Additional items could be added at the end.
9981000 [ Event ( BeginExecuteEventId , Keywords = Keywords . ExecutionTrace , Task = Tasks . ExecuteCommand , Opcode = EventOpcode . Start ) ]
999- internal void BeginExecute ( string message ) =>
1000- WriteEvent ( BeginExecuteEventId , message ) ;
1001+ internal void BeginExecute ( int objectId , string dataSource , string database , string commandText , string message )
1002+ {
1003+ WriteEvent ( BeginExecuteEventId , objectId , dataSource , database , commandText , message ) ;
1004+ }
10011005
1006+ // Do not change the first 3 arguments in this Event writer as OpenTelemetry and ApplicationInsight are relating to the same format,
1007+ // unless you have checked with them and they are able to change their design. Additional items could be added at the end.
10021008 [ Event ( EndExecuteEventId , Keywords = Keywords . ExecutionTrace , Task = Tasks . ExecuteCommand , Opcode = EventOpcode . Stop ) ]
1003- internal void EndExecute ( string message ) =>
1004- WriteEvent ( EndExecuteEventId , message ) ;
1009+ internal void EndExecute ( int objectId , int compositestate , int sqlExceptionNumber , string message )
1010+ {
1011+
1012+ WriteEvent ( EndExecuteEventId , objectId , compositestate , sqlExceptionNumber , message ) ;
1013+ }
10051014
10061015 [ Event ( TraceEventId , Level = EventLevel . Informational , Keywords = Keywords . Trace ) ]
10071016 internal void Trace ( string message ) =>
@@ -1106,7 +1115,7 @@ internal static class EventType
11061115 public const string INFO = " | INFO | " ;
11071116 public const string ERR = " | ERR | " ;
11081117 }
1109-
1118+
11101119 internal readonly struct TrySNIEventScope : IDisposable
11111120 {
11121121 private readonly long _scopeId ;
0 commit comments