Skip to content

Commit

Permalink
Add support netstandard 2.1 & fix the conflict in event source
Browse files Browse the repository at this point in the history
  • Loading branch information
DavoudEshtehari committed Aug 31, 2020
1 parent a56c1c0 commit ada285a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<PropertyGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetFramework)' != 'netcoreapp2.1'">
<DefineConstants>$(DefineConstants);NETCORE3</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetGroup)' == 'netstandard' AND '$(TargetFramework)' != 'netstandard2.0'">
<DefineConstants>$(DefineConstants);NETSTANDARD21</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,12 @@ internal partial class SqlClientEventSource : EventSource
private long _stasisConnectionsCounter = 0;
private long _reclaimedConnectionsCounter = 0;

protected override void OnEventCommand(EventCommandEventArgs command)
public SqlClientEventSource()
{
if (command.Command != EventCommand.Enable)
{
return;
}

_activeHardConnections = _activeHardConnections ??
new EventCounter("active-hard-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Actual active connections are made to servers",
DisplayUnits = "count"
#endif
Expand All @@ -72,7 +67,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_hardConnectsPerSecond = _hardConnectsPerSecond ??
new EventCounter("hard-connects", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Actual connections are made to servers",
DisplayUnits = "count / sec"
#endif
Expand All @@ -81,7 +76,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_hardDisconnectsPerSecond = _hardDisconnectsPerSecond ??
new EventCounter("hard-disconnects", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Actual disconnections are made to servers",
DisplayUnits = "count / sec"
#endif
Expand All @@ -90,7 +85,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_activeSoftConnections = _activeSoftConnections ??
new EventCounter("active-soft-connects", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Active connections got from connection pool",
DisplayUnits = "count"
#endif
Expand All @@ -99,7 +94,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_softConnects = _softConnects ??
new EventCounter("soft-connects", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Connections got from connection pool",
DisplayUnits = "count / sec"
#endif
Expand All @@ -108,7 +103,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_softDisconnects = _softDisconnects ??
new EventCounter("soft-disconnects", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Connections returned to the connection pool",
DisplayUnits = "count / sec"
#endif
Expand All @@ -117,7 +112,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfNonPooledConnections = _numberOfNonPooledConnections ??
new EventCounter("number-of-non-pooled-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of connections are not using connection pooling",
DisplayUnits = "count / sec"
#endif
Expand All @@ -126,7 +121,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfPooledConnections = _numberOfPooledConnections ??
new EventCounter("number-of-pooled-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of connections are managed by connection pooler",
DisplayUnits = "count / sec"
#endif
Expand All @@ -135,7 +130,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfActiveConnectionPoolGroups = _numberOfActiveConnectionPoolGroups ??
new EventCounter("number-of-active-connection-pool-groups", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of active unique connection strings",
DisplayUnits = "count"
#endif
Expand All @@ -144,7 +139,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfInactiveConnectionPoolGroups = _numberOfInactiveConnectionPoolGroups ??
new EventCounter("number-of-inactive-connection-pool-groups", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of unique connection strings waiting for pruning",
DisplayUnits = "count"
#endif
Expand All @@ -153,7 +148,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfActiveConnectionPools = _numberOfActiveConnectionPools ??
new EventCounter("number-of-active-connection-pools", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of active connection pools",
DisplayUnits = "count"
#endif
Expand All @@ -162,7 +157,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfInactiveConnectionPools = _numberOfInactiveConnectionPools ??
new EventCounter("number-of-inactive-connection-pools", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of inactive connection pools",
DisplayUnits = "count"
#endif
Expand All @@ -171,7 +166,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfActiveConnections = _numberOfActiveConnections ??
new EventCounter("number-of-active-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of active connections",
DisplayUnits = "count"
#endif
Expand All @@ -180,7 +175,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfFreeConnections = _numberOfFreeConnections ??
new EventCounter("number-of-free-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of free-ready connections",
DisplayUnits = "count"
#endif
Expand All @@ -189,7 +184,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfStasisConnections = _numberOfStasisConnections ??
new EventCounter("number-of-stasis-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of connections currently waiting to be ready",
DisplayUnits = "count"
#endif
Expand All @@ -198,7 +193,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
_numberOfReclaimedConnections = _numberOfReclaimedConnections ??
new EventCounter("number-of-reclaimed-connections", this)
{
#if NETCORE3
#if NETCORE3 || NETSTANDARD21
DisplayName = "Number of reclaimed connections from GC",
DisplayUnits = "count"
#endif
Expand Down

0 comments on commit ada285a

Please sign in to comment.