Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding EventSource to NetFx #399

Merged
merged 51 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4670349
EventTrace for NetFx, changes made to SqlConnection
Jan 18, 2020
c7c1504
EventSource for NetFx
Jan 28, 2020
aab8e8b
Adding IsTraceEnabled
Jan 29, 2020
2dd4373
EventSource NetFx to Review
Jan 30, 2020
ebca243
Taking unused variable out
Jan 30, 2020
c4d9289
Ignore on .NetCore
Jan 30, 2020
7a747b4
Update EventSourceTest.cs
Jan 31, 2020
5b73edb
Adding if blocks
Jan 31, 2020
8049005
Merge branch 'EventSource' of https://github.com/JRahnama/SqlClient i…
Jan 31, 2020
5198d21
EventSource
Jan 31, 2020
9fb8af8
Documentation
Feb 3, 2020
d373dd1
Adding Tests and documentation
Feb 4, 2020
c3a27a4
Fixing Tests issues in NetCore
Feb 4, 2020
f39321c
moving from Functional to Manual Tests
Feb 4, 2020
40df85b
EventSource
Feb 4, 2020
8c5af73
EventSource unwanted reference
Feb 4, 2020
44bb6c2
Taking extra documentation file out.
Feb 4, 2020
a650fa8
Deleting unwanted file from NetCore
Feb 4, 2020
4b3a737
EventSource
Feb 4, 2020
435c9d7
Additional Improvments
Feb 5, 2020
4bc920c
Taking the Static reference out
Feb 5, 2020
7ac0742
Removing Extra lines and unwanted SqlClient Reference from SqlClientE…
Feb 5, 2020
2da6e5b
Merge branch 'master' into EventSource
Feb 5, 2020
ab912e6
Changing documentation and adding Advanced Keyword
Feb 7, 2020
23c6d0e
Merge branch 'EventSource' of https://github.com/JRahnama/SqlClient i…
Feb 7, 2020
9557b3a
Adding Overloaded methods in EventSource
Feb 11, 2020
1a098a3
Merge branch 'master' of https://github.com/dotnet/SqlClient into Eve…
Feb 11, 2020
9d11677
Fixing test issues
Feb 11, 2020
6397d77
more fixes
Feb 11, 2020
4cf1a08
EventSource
Feb 12, 2020
388bba6
ActivityCorrelator added.
Feb 13, 2020
96614db
ActivityCorrelator added.
Feb 13, 2020
fd7f452
Merge branch 'EventSource' of https://github.com/JRahnama/SqlClient i…
Feb 13, 2020
f0c1c0a
fixing AdvanceTraceOn issues
Feb 13, 2020
11b90fc
StateDump
Feb 13, 2020
71fee3d
Removing if statement from code and placing them inside EventSource
Feb 19, 2020
6e52add
integrating SqlEventSource to SqlClientEventSource
Feb 19, 2020
26d3c2e
Adding null value checker to SqlDependencyListener EventSource logger
Feb 20, 2020
5b1a7ee
EventSource
Feb 20, 2020
34bedaf
Fixing ScopeLeave related logic
Feb 21, 2020
e3fa4a4
Fixing PR issues and Tests
Feb 24, 2020
7e293d3
EventSource
Feb 24, 2020
42df9ec
EventSource
Feb 24, 2020
959ca03
EventSource
Feb 25, 2020
7c55d8c
Removing Doc
Feb 25, 2020
ad7a3bd
ExceptionTrace Fix
Feb 25, 2020
dac6ecf
Update SqlAuthenticationProviderManager.cs
Feb 27, 2020
dc79898
Update SqlBulkCopy.cs
Feb 27, 2020
52b9e6d
Update SqlConnectionFactory.cs
Feb 27, 2020
18eccbe
Update SqlConnectionPoolGroupProviderInfo.cs
Feb 27, 2020
27f3bba
Update SqlCommand.cs
Feb 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="Microsoft\Data\SqlClient\SqlClientEventSource.cs" />
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
<Compile Include="Resources\SR.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Text;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Microsoft.Data.SqlClient.ManualTesting.Tests")]
namespace Microsoft.Data.SqlClient
{

[EventSource(Name = "Microsoft.Data.SqlClient.EventSource")]
internal class SqlClientEventSource : EventSource
{
internal static readonly SqlClientEventSource Log = new SqlClientEventSource();
private static long s_nextScopeId = 0;
private static long s_nextNotificationScopeId = 0;

private const int TraceEventId = 1;
private const int EnterScopeId = 2;
private const int ExitScopeId = 3;
private const int TraceBinId = 4;
private const int CorrelationTraceId = 5;
private const int NotificationsScopeEnterId = 6;
private const int NotificationsTraceId = 7;
private const int PoolerScopeEnterId = 8;
private const int PoolerTraceId = 9;
private const int PutStrId = 10;

//Any Prropery added to this class should be a power of 2.
public class Keywords
{
internal const EventKeywords Trace = (EventKeywords)0x0001; // Integer 1
internal const EventKeywords Scope = (EventKeywords)0x0002; // Integer 2
internal const EventKeywords NotificationTrace = (EventKeywords)0x0004; // Integer 4
internal const EventKeywords Pooling = (EventKeywords)0x0008; // Integer 8
internal const EventKeywords Correlation = (EventKeywords)0x0010; // Integer 16
internal const EventKeywords NotificationScope = (EventKeywords)0x0020; // Integer 32
internal const EventKeywords PoolerScope = (EventKeywords)0X0040; // Integer 64
internal const EventKeywords StringPrintOut = (EventKeywords)0x0080; // Integer 128
internal const EventKeywords PoolerTrace = (EventKeywords)0x0200; //Integer 512

public static EventKeywords GetAll()
{
return Trace | Scope | NotificationTrace | Pooling | Correlation | NotificationScope | PoolerScope | StringPrintOut;
}
}

[NonEvent]
internal bool IsTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Trace);

[NonEvent]
internal bool IsScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Scope);

[NonEvent]
internal bool IsPoolerScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope);

[NonEvent]
internal bool IsCorrelationEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Correlation);

[NonEvent]
internal bool IsNotificationScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope);

[NonEvent]
internal bool IsPoolingEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Pooling);

[NonEvent]
internal bool IsNotificationTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace);

[NonEvent]
internal bool IsPoolerTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace);


[Event(TraceEventId, Level = EventLevel.Informational, Channel = EventChannel.Debug, Keywords = Keywords.Trace)]
internal void Trace(string message)
{
WriteEvent(TraceEventId, message);
}

[Event(EnterScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)]
internal long ScopeEnter(string message)
{
StringBuilder MsgstrBldr = new StringBuilder(message);
long scopeId = 0;
if (Log.IsEnabled())
{
scopeId = Interlocked.Increment(ref s_nextScopeId);
WriteEvent(EnterScopeId, MsgstrBldr.Append($" Scope ID ='[{ scopeId}]'"));
}
return scopeId;
}

[Event(ExitScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)]
internal void ScopeLeave(long scopeId)
{
if (!Log.IsEnabled())
{
return;
}
WriteEvent(ExitScopeId, scopeId);
}

[Event(TraceBinId, Level = EventLevel.Informational, Keywords = Keywords.Trace)]
internal void TraceBin(string message, byte[] whereabout, int length)
{
if (Log.IsEnabled(EventLevel.Informational, Keywords.Trace))
{
WriteEvent(TraceBinId, message, whereabout, length);
}

}

[Event(CorrelationTraceId, Level = EventLevel.Informational, Keywords = Keywords.Correlation, Opcode = EventOpcode.Start)]
internal void CorrelationTrace(string message)
{

WriteEvent(CorrelationTraceId, message);
}

[Event(NotificationsScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.NotificationScope)]
internal long NotificationsScopeEnter(string message)
{
long scopeId = 0;
if (Log.IsEnabled())
{
StringBuilder MsgstrBldr = new StringBuilder(message);
scopeId = Interlocked.Increment(ref s_nextNotificationScopeId);
WriteEvent(NotificationsScopeEnterId, MsgstrBldr.Append($" Scope ID ='[{ scopeId}]'"));
}
return scopeId;
}

[Event(PoolerScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.PoolerScope)]
internal long PoolerScopeEnter(string message)
{
long scopeId = 0;
if (Log.IsEnabled())
{

StringBuilder MsgstrBldr = new StringBuilder(message);
WriteEvent(PoolerScopeEnterId, MsgstrBldr.Append($" Scope ID ='[{ scopeId}]'"));
}
return scopeId;
}

[Event(NotificationsTraceId, Level = EventLevel.Informational, Keywords = Keywords.Trace)]
internal void NotificationsTrace(string message)
{
WriteEvent(PoolerScopeEnterId, message);
}

[Event(PoolerTraceId, Level = EventLevel.Informational, Keywords = Keywords.PoolerTrace)]
internal void PoolerTrace(string message)
{
WriteEvent(PoolerTraceId, message);
}

[Event(PutStrId, Level = EventLevel.Informational, Keywords = Keywords.StringPrintOut)]
internal void PutStr(string message)
{
if (Log.IsEnabled(EventLevel.Informational, Keywords.StringPrintOut))
{
WriteEvent(PutStrId, message);

}
}
}
}

This file was deleted.

145 changes: 0 additions & 145 deletions src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/BidPrivateBase.cs

This file was deleted.

Loading