public EsquioEventSource() : base("Esquio", EventSourceSettings.EtwSelfDescribingEventFormat) { _featuresPerSecondCounter = new IncrementingPollingCounter(EsquioConstants.FEATURE_EVALUATION_PER_SECOND_COUNTER, this, () => _perSecondFeatureEvaluations) { DisplayName = "Feature Evaluations", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _featureThrowPerSecondCounter = new IncrementingPollingCounter(EsquioConstants.FEATURE_THROWS_PER_SECOND_COUNTER, this, () => _perSecondFeatureThrows) { DisplayName = "Feature Evaluations Throws", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _featureNotFoundPerSecondCounter = new IncrementingPollingCounter(EsquioConstants.FEATURE_NOTFOUND_COUNTER, this, () => _perSecondFeatureNotFound) { DisplayName = "Feature Evaluations NotFound", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _togglePerSecondCounter = new IncrementingPollingCounter(EsquioConstants.TOGGLE_EVALUATION_PER_SECOND_COUNTER, this, () => _perSecondToggleEvaluations) { DisplayName = "Toggle Executions", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _toggleActivationThrowPerSecondCounter = new IncrementingPollingCounter(EsquioConstants.TOGGLE_ACTIVATION_THROWS_PER_SECOND_COUNTER, this, () => _perSecondActivationThrows) { DisplayName = "Toggle Executions Throws", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _featureDynamicCounters = new ConcurrentDictionary <string, EventCounter>(); }
public SimpleEventSource(Func <double> getMockedCount) { _mockedCounter = new IncrementingPollingCounter("failureCount", this, getMockedCount) { DisplayName = "Failure Count", DisplayUnits = "Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; }
private BMCounterSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) { // Counter names should ideally be the same length, so I'm naming them with number-suffix. this.m_eventCounter = new EventCounter("BenchmarkCounter1", this) { // Same thing for these fields DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_pollingCounter = new PollingCounter("BenchmarkCounter2", this, () => 1) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_incrementingEventCounter = new IncrementingEventCounter("BenchmarkCounter3", this) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_incrementingPollingCounter = new IncrementingPollingCounter("BenchmarkCounter4", this, () => 1) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; }
protected override void Dispose(bool disposing) { _requestCounter?.Dispose(); _requestCounter = null; _workingSetCounter?.Dispose(); _workingSetCounter = null; _totalRequestsCounter?.Dispose(); _totalRequestsCounter = null; _incrementingPollingCounter?.Dispose(); _incrementingPollingCounter = null; base.Dispose(disposing); }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { //请求响应耗时 _requestCounter = new EventCounter("request-time", this) { DisplayName = "Request Processing Time", DisplayUnits = "ms" }; //内存占用 _workingSetCounter = new PollingCounter("working-set", this, () => (double)(Environment.WorkingSet / 1_000_000)) { DisplayName = "Working Set", DisplayUnits = "MB" }; //总请求量 _totalRequestsCounter = new PollingCounter("total-requests", this, () => Volatile.Read(ref _totalRequests)) { DisplayName = "Total Requests", DisplayUnits = "次" }; //单位时间请求速率 _incrementingPollingCounter = new IncrementingPollingCounter("Request Rate", this, () => { return Volatile.Read(ref _totalRequests); }) { DisplayName = "Request Rate", DisplayUnits = "次/s", //时间间隔1s DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; var monitorContentionCounter = new IncrementingPollingCounter("monitor-lock-contention-count", this, () => Monitor.LockContentionCount) { DisplayName = "Monitor Lock Contention Count", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; } }
protected override void EventCommandMethodCall(EventCommandEventArgs command) { if (command.Command != EventCommand.Enable) { return; } _activeHardConnections = _activeHardConnections ?? new PollingCounter("active-hard-connections", this, () => _activeHardConnectionsCounter) { DisplayName = "Actual active connections currently made to servers", DisplayUnits = "count" }; _hardConnectsPerSecond = _hardConnectsPerSecond ?? new IncrementingPollingCounter("hard-connects", this, () => _hardConnectsCounter) { DisplayName = "Actual connection rate to servers", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _hardDisconnectsPerSecond = _hardDisconnectsPerSecond ?? new IncrementingPollingCounter("hard-disconnects", this, () => _hardDisconnectsCounter) { DisplayName = "Actual disconnection rate from servers", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _activeSoftConnections = _activeSoftConnections ?? new PollingCounter("active-soft-connects", this, () => _activeSoftConnectionsCounter) { DisplayName = "Active connections retrieved from the connection pool", DisplayUnits = "count" }; _softConnects = _softConnects ?? new IncrementingPollingCounter("soft-connects", this, () => _softConnectsCounter) { DisplayName = "Rate of connections retrieved from the connection pool", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _softDisconnects = _softDisconnects ?? new IncrementingPollingCounter("soft-disconnects", this, () => _softDisconnectsCounter) { DisplayName = "Rate of connections returned to the connection pool", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _numberOfNonPooledConnections = _numberOfNonPooledConnections ?? new PollingCounter("number-of-non-pooled-connections", this, () => _nonPooledConnectionsCounter) { DisplayName = "Number of connections not using connection pooling", DisplayUnits = "count" }; _numberOfPooledConnections = _numberOfPooledConnections ?? new PollingCounter("number-of-pooled-connections", this, () => _pooledConnectionsCounter) { DisplayName = "Number of connections managed by the connection pool", DisplayUnits = "count" }; _numberOfActiveConnectionPoolGroups = _numberOfActiveConnectionPoolGroups ?? new PollingCounter("number-of-active-connection-pool-groups", this, () => _activeConnectionPoolGroupsCounter) { DisplayName = "Number of active unique connection strings", DisplayUnits = "count" }; _numberOfInactiveConnectionPoolGroups = _numberOfInactiveConnectionPoolGroups ?? new PollingCounter("number-of-inactive-connection-pool-groups", this, () => _inactiveConnectionPoolGroupsCounter) { DisplayName = "Number of unique connection strings waiting for pruning", DisplayUnits = "count" }; _numberOfActiveConnectionPools = _numberOfActiveConnectionPools ?? new PollingCounter("number-of-active-connection-pools", this, () => _activeConnectionPoolsCounter) { DisplayName = "Number of active connection pools", DisplayUnits = "count" }; _numberOfInactiveConnectionPools = _numberOfInactiveConnectionPools ?? new PollingCounter("number-of-inactive-connection-pools", this, () => _inactiveConnectionPoolsCounter) { DisplayName = "Number of inactive connection pools", DisplayUnits = "count" }; _numberOfActiveConnections = _numberOfActiveConnections ?? new PollingCounter("number-of-active-connections", this, () => _activeConnectionsCounter) { DisplayName = "Number of active connections", DisplayUnits = "count" }; _numberOfFreeConnections = _numberOfFreeConnections ?? new PollingCounter("number-of-free-connections", this, () => _freeConnectionsCounter) { DisplayName = "Number of ready connections in the connection pool", DisplayUnits = "count" }; _numberOfStasisConnections = _numberOfStasisConnections ?? new PollingCounter("number-of-stasis-connections", this, () => _stasisConnectionsCounter) { DisplayName = "Number of connections currently waiting to be ready", DisplayUnits = "count" }; _numberOfReclaimedConnections = _numberOfReclaimedConnections ?? new IncrementingPollingCounter("number-of-reclaimed-connections", this, () => _reclaimedConnectionsCounter) { DisplayName = "Number of reclaimed connections from GC", DisplayUnits = "count", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; }