-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from glennc/shirhatti/counters
Add total-orders EventCounter
- Loading branch information
Showing
3 changed files
with
47 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" | ||
}; | ||
} | ||
} | ||
} | ||
} |
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