forked from glennc/BlazingMicroPizzas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sourabh Shirhatti
committed
Nov 18, 2019
1 parent
c8301c7
commit 82b2fde
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Tracing; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlazingPizza.Orders | ||
{ | ||
internal sealed class OrdersEventSource : EventSource | ||
{ | ||
public static readonly OrdersEventSource Log = new OrdersEventSource(); | ||
|
||
private PollingCounter _totalOrdersCounter; | ||
|
||
private long _totalOrders; | ||
|
||
internal OrdersEventSource() | ||
: base("BlazingOrders.Pizza") | ||
{ | ||
|
||
} | ||
|
||
internal void OrderCreated() | ||
{ | ||
Interlocked.Increment(ref _totalOrders); | ||
} | ||
|
||
protected override void OnEventCommand(EventCommandEventArgs command) | ||
{ | ||
if (command.Command == EventCommand.Enable) | ||
{ | ||
_totalOrdersCounter ??= new PollingCounter("total-orders", this, () => _totalOrders) | ||
{ | ||
DisplayName = "Total Orders" | ||
}; | ||
} | ||
} | ||
} | ||
} |