diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.NetCoreApp2.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.NetCoreApp2.cs index da7a59b51b..6201e739c5 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.NetCoreApp2.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.NetCoreApp2.cs @@ -2,266 +2,123 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.Tracing; -using System.Threading; - namespace Microsoft.Data.SqlClient { /// - /// supported frameworks: .Net core 2.1 and .Net standard 2.0 + /// not implemented cause of low performance for .Net core 2.1 and .Net standard 2.0 /// internal partial class SqlClientEventSource : SqlClientEventSourceBase { - private EventCounter _activeHardConnections; - private EventCounter _hardConnectsPerSecond; - private EventCounter _hardDisconnectsPerSecond; - - private EventCounter _activeSoftConnections; - private EventCounter _softConnects; - private EventCounter _softDisconnects; - - private EventCounter _numberOfNonPooledConnections; - private EventCounter _numberOfPooledConnections; - - private EventCounter _numberOfActiveConnectionPoolGroups; - private EventCounter _numberOfInactiveConnectionPoolGroups; - - private EventCounter _numberOfActiveConnectionPools; - private EventCounter _numberOfInactiveConnectionPools; - - private EventCounter _numberOfActiveConnections; - private EventCounter _numberOfFreeConnections; - private EventCounter _numberOfStasisConnections; - private EventCounter _numberOfReclaimedConnections; - - private long _activeHardConnectionsCounter = 0; - private long _hardConnectsCounter = 0; - private long _hardDisconnectsCounter = 0; - - private long _activeSoftConnectionsCounter = 0; - private long _softConnectsCounter = 0; - private long _softDisconnectsCounter = 0; - - private long _nonPooledConnectionsCounter = 0; - private long _pooledConnectionsCounter = 0; - - private long _activeConnectionPoolGroupsCounter = 0; - private long _inactiveConnectionPoolGroupsCounter = 0; - - private long _activeConnectionPoolsCounter = 0; - private long _inactiveConnectionPoolsCounter = 0; - - private long _activeConnectionsCounter = 0; - private long _freeConnectionsCounter = 0; - private long _stasisConnectionsCounter = 0; - private long _reclaimedConnectionsCounter = 0; - - protected override void EventCommandMethodCall(EventCommandEventArgs command) - { - if (command.Command != EventCommand.Enable) - { - return; - } - - _activeHardConnections = _activeHardConnections ?? new EventCounter("active-hard-connections", this); - _hardConnectsPerSecond = _hardConnectsPerSecond ?? new EventCounter("hard-connects", this); - _hardDisconnectsPerSecond = _hardDisconnectsPerSecond ?? new EventCounter("hard-disconnects", this); - - _activeSoftConnections = _activeSoftConnections ?? new EventCounter("active-soft-connects", this); - _softConnects = _softConnects ?? new EventCounter("soft-connects", this); - _softDisconnects = _softDisconnects ?? new EventCounter("soft-disconnects", this); - - _numberOfNonPooledConnections = _numberOfNonPooledConnections ?? new EventCounter("number-of-non-pooled-connections", this); - _numberOfPooledConnections = _numberOfPooledConnections ?? new EventCounter("number-of-pooled-connections", this); - _numberOfActiveConnectionPoolGroups = _numberOfActiveConnectionPoolGroups ?? new EventCounter("number-of-active-connection-pool-groups", this); - _numberOfInactiveConnectionPoolGroups = _numberOfInactiveConnectionPoolGroups ?? new EventCounter("number-of-inactive-connection-pool-groups", this); - _numberOfActiveConnectionPools = _numberOfActiveConnectionPools ?? new EventCounter("number-of-active-connection-pools", this); - _numberOfInactiveConnectionPools = _numberOfInactiveConnectionPools ?? new EventCounter("number-of-inactive-connection-pools", this); - _numberOfActiveConnections = _numberOfActiveConnections ?? new EventCounter("number-of-active-connections", this); - _numberOfFreeConnections = _numberOfFreeConnections ?? new EventCounter("number-of-free-connections", this); - _numberOfStasisConnections = _numberOfStasisConnections ?? new EventCounter("number-of-stasis-connections", this); - _numberOfReclaimedConnections = _numberOfReclaimedConnections ?? new EventCounter("number-of-reclaimed-connections", this); - } - /// - /// The number of actual connections that are being made to servers + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - [NonEvent] internal void HardConnectRequest() { - if (IsEnabled()) - { - var counter = Interlocked.Increment(ref _activeHardConnectionsCounter); - _activeHardConnections.WriteMetric(counter); - - counter = Interlocked.Increment(ref _hardConnectsCounter); - _hardConnectsPerSecond.WriteMetric(counter); - } + //no-op } /// - /// The number of actual disconnects that are being made to servers + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - [NonEvent] internal void HardDisconnectRequest() { - if (IsEnabled()) - { - var counter = Interlocked.Decrement(ref _activeHardConnectionsCounter); - _activeHardConnections.WriteMetric(counter); - - counter = Interlocked.Increment(ref _hardDisconnectsCounter); - _hardDisconnectsPerSecond.WriteMetric(counter); - } + //no-op } /// - /// The number of connections we get from the pool + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - [NonEvent] internal void SoftConnectRequest() { - if (IsEnabled()) - { - var counter = Interlocked.Increment(ref _activeSoftConnectionsCounter); - _activeSoftConnections.WriteMetric(counter); - - counter = Interlocked.Increment(ref _softConnectsCounter); - _softConnects.WriteMetric(counter); - } + //no-op } /// - /// The number of connections we return to the pool + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - [NonEvent] internal void SoftDisconnectRequest() { - if (IsEnabled()) - { - var counter = Interlocked.Decrement(ref _activeSoftConnectionsCounter); - _activeSoftConnections.WriteMetric(counter); - - counter = Interlocked.Increment(ref _softDisconnectsCounter); - _softDisconnects.WriteMetric(counter); - } + //no-op } /// - /// The number of connections that are not using connection pooling + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void NonPooledConnectionRequest(bool increment = true) { - Request(ref _numberOfNonPooledConnections, ref _nonPooledConnectionsCounter, increment); + //no-op } /// - /// The number of connections that are managed by the connection pooler + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void PooledConnectionRequest(bool increment = true) { - Request(ref _numberOfPooledConnections, ref _pooledConnectionsCounter, increment); + //no-op } /// - /// The number of unique connection strings + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void ActiveConnectionPoolGroupRequest(bool increment = true) { - Request(ref _numberOfActiveConnectionPoolGroups, ref _activeConnectionPoolGroupsCounter, increment); + //no-op } /// - /// The number of unique connection strings waiting for pruning + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void InactiveConnectionPoolGroupRequest(bool increment = true) { - Request(ref _numberOfInactiveConnectionPoolGroups, ref _inactiveConnectionPoolGroupsCounter, increment); + //no-op } /// - /// The number of connection pools + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void ActiveConnectionPoolRequest(bool increment = true) { - Request(ref _numberOfActiveConnectionPools, ref _activeConnectionPoolsCounter, increment); + //no-op } /// - /// The number of connection pools + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void InactiveConnectionPoolRequest(bool increment = true) { - Request(ref _numberOfInactiveConnectionPools, ref _inactiveConnectionPoolsCounter, increment); + //no-op } /// - /// The number of connections currently in-use + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void ActiveConnectionRequest(bool increment = true) { - Request(ref _numberOfActiveConnections, ref _activeConnectionsCounter, increment); + //no-op } /// - /// The number of connections currently available for use + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void FreeConnectionRequest(bool increment = true) { - Request(ref _numberOfFreeConnections, ref _freeConnectionsCounter, increment); + //no-op } /// - /// The number of connections currently waiting to be made ready for use + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - /// - [NonEvent] internal void StasisConnectionRequest(bool increment = true) { - Request(ref _numberOfStasisConnections, ref _stasisConnectionsCounter, increment); + //no-op } /// - /// The number of connections we reclaim from GC'd external connections + /// not implemented for .Net core 2.1, .Net standard 2.0 and lower /// - [NonEvent] internal void ReclaimedConnectionRequest() { - Request(ref _numberOfReclaimedConnections, ref _reclaimedConnectionsCounter, true); - } - - [NonEvent] - private void Request(ref EventCounter eventCounter, ref long counter, bool increment) - { - if (IsEnabled()) - { - long innerCounter; - if (increment) - { - innerCounter = Interlocked.Increment(ref counter); - } - else - { - innerCounter = Interlocked.Decrement(ref counter); - } - eventCounter.WriteMetric(innerCounter); - } + //no-op } } }