SimpleTracer 0.1.5
dotnet add package SimpleTracer --version 0.1.5
NuGet\Install-Package SimpleTracer -Version 0.1.5
<PackageReference Include="SimpleTracer" Version="0.1.5" />
paket add SimpleTracer --version 0.1.5
#r "nuget: SimpleTracer, 0.1.5"
// Install SimpleTracer as a Cake Addin #addin nuget:?package=SimpleTracer&version=0.1.5 // Install SimpleTracer as a Cake Tool #tool nuget:?package=SimpleTracer&version=0.1.5
SimpleTracer
Simplest way to listen and collect events for .Net/.Net Core applications.!
Build | Test | Coverage | Nuget |
---|---|---|---|
If you have an application that you need to listen some events, you should implement the followings which is fairly painful;
- Create a class that inherits from EventListener
- Call
EnableEvents(...)
method for every source and try to eliminate the concurrency problem - To listen multiple different sources, be familiar with bitwise operations
Here we go! OnEventWritten(...)
method will be triggered for every written events and you should concern;
- Concurrency because events might be written from different threads
- Buffering because events count per specific time might be more than you can handle this.
- Separation because you wouldn't like to handle every event in same way
SimpleTracer addresses many of the common concern to provide fault tolerant, thread safe and TPL friendly solution.
Simplest way to collect Garbage Collection events, ever!
You can configure how often and which method will be triggered by calling WithInterval
and WithDelegate
methods. Also WithMaxTake
could be handy to set event limit for each trigger.
var builder = SubscriptionContainerBuilder
.New()
.WithSubscription(s => s
.WithEvents(e => e.DotNetRuntime.GC.AllInformationals())
.WithOptions()
.WithExecution(e => e
.WithInterval(TimeSpan.FromSeconds(30))
.WithDelegate(OnEventsCollected)
.WithMaxTake(300)));
var container = builder.Build();
container.Start();
You could store it wherever you want
SimpleTracer supports awaitable
methods. Every execution occurs in a Task
which was dedicated per Subscription for your workload!
private static Task OnEventsCollected(IEventNotification arg)
{
foreach (IEventEntry item in arg.Events)
Console.WriteLine($"{item.CreatedOn}\t{item.Id} : {item.Name}");
return Task.CompletedTask;
}
Multiple EventSource in one Subscription
You don't have to create different subscriptions for every EventSource.
One subscription can listen multiple EventSource
with various EventLevel
and EventKeywords
.
var builder = SubscriptionContainerBuilder
.New()
.WithSubscription(s => s
.WithEvents(e => e.DotNetRuntime.GC.AllInformationals())
.WithEvents(e => e.SystemNetHttp.AllWarnings())
.WithEvents(new SourceDefinition("Custom-Event-Source", EventLevel.Error, EventKeywords.All))
.WithExecution(e => e
.WithInterval(TimeSpan.FromSeconds(3))
.WithDelegate(OnEventsCollected)
.WithMaxTake(300))
.WithOptions());
var container = builder.Build();
container.Start();
Don't want to involve too much details?
You can create a Subscription to listen all of EventSource objects with EventLevel
filter.
It gives you to a massive insight about your application but also more than a thousand events to be queued.
Don't worry! By calling WithQueueCapacity
, it is possible to limit to be enqueued event count.
var builder = SubscriptionContainerBuilder
.New()
.WithSubscription(EventLevel.Error, c => c
.WithExecution(e => e
.WithInterval(TimeSpan.FromSeconds(3))
.WithDelegate(OnEventsCollected)
.WithMaxTake(300))
.WithOptions(o => o
.WithQueueCapacity(3000)));
var container = builder.Build();
container.Start();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.