Skip to content

Commit b7c4007

Browse files
authored
Enhancement | Add trace logs for packet size (dotnet#2522)
1 parent b178ba5 commit b7c4007

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

+3
Original file line numberDiff line numberDiff line change
@@ -2740,6 +2740,9 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,
27402740
// to MARS initialization!
27412741
int packetSize = int.Parse(env._newValue, NumberStyles.Integer, CultureInfo.InvariantCulture);
27422742

2743+
SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Server sent env packet size change of {2}, ClientConnectionID {3}",
2744+
nameof(TdsParser), nameof(TryProcessEnvChange), packetSize, _connHandler._clientConnectionId);
2745+
27432746
if (_physicalStateObj.SetPacketSize(packetSize))
27442747
{
27452748
// If packet size changed, we need to release our SNIPackets since

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

+3
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,9 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,
31823182
// to MARS initialization!
31833183
int packetSize = int.Parse(env._newValue, NumberStyles.Integer, CultureInfo.InvariantCulture);
31843184

3185+
SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Server sent env packet size change of {2}, ClientConnectionID {3}",
3186+
nameof(TdsParser), nameof(TryProcessEnvChange), packetSize, _connHandler._clientConnectionId);
3187+
31853188
if (_physicalStateObj.SetPacketSize(packetSize))
31863189
{
31873190
// If packet size changed, we need to release our SNIPackets since

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,9 @@ internal bool SetPacketSize(int size)
10971097
(_outBytesUsed == _outputHeaderLen && _outputPacketNumber == 1),
10981098
"SetPacketSize called with data in the buffer!");
10991099

1100+
SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | State Object Id {2}, Setting packet size to {3}",
1101+
nameof(TdsParserStateObject), nameof(SetPacketSize), _objectID, size);
1102+
11001103
if (_inBuff == null || _inBuff.Length != size)
11011104
{ // We only check _inBuff, since two buffers should be consistent.
11021105
// Allocate or re-allocate _inBuff.

0 commit comments

Comments
 (0)