/// <summary> /// Get callbacks when the ETW sends us commands` /// </summary> protected override void OnEventCommand(EventCommandEventArgs command) { if (IsEnabled(EventLevel.Informational, Keywords.TasksFlowActivityIds)) { ActivityTracker.Instance.Enable(); } else { TasksSetActivityIds = IsEnabled(EventLevel.Informational, Keywords.TasksSetActivityIds); } Debug = IsEnabled(EventLevel.Informational, Keywords.Debug); DebugActivityId = IsEnabled(EventLevel.Informational, Keywords.DebugActivityId); }
protected override void OnEventCommand(EventCommandEventArgs command) { try { Removed(); } catch { try { Removed(); } catch { Removed(); throw; } throw; } }
/// <summary> /// Get callbacks when the ETW sends us commands` /// </summary> protected override void OnEventCommand(EventCommandEventArgs command) { // To get the AsyncCausality events, we need to inform the AsyncCausalityTracer if (command.Command == EventCommand.Enable) AsyncCausalityTracer.EnableToETW(true); else if (command.Command == EventCommand.Disable) AsyncCausalityTracer.EnableToETW(false); if (IsEnabled(EventLevel.Informational, Keywords.TasksFlowActivityIds)) ActivityTracker.Instance.Enable(); else TasksSetActivityIds = IsEnabled(EventLevel.Informational, Keywords.TasksSetActivityIds); Debug = IsEnabled(EventLevel.Informational, Keywords.Debug); DebugActivityId = IsEnabled(EventLevel.Informational, Keywords.DebugActivityId); }
/// <inheritdoc /> protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Update || command.Command == EventCommand.Enable) { if (!command.Arguments.TryGetValue("FilterSpecs", out var filterSpec)) { filterSpec = string.Empty; // This means turn on everything. } SetFilterSpec(filterSpec); } else if (command.Command == EventCommand.Disable) { SetFilterSpec(null); // This means disable everything. } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // The cumulative number of name resolution requests started since events were enabled _lookupsRequestedCounter ??= new PollingCounter("dns-lookups-requested", this, () => Interlocked.Read(ref _lookupsRequested)) { DisplayName = "DNS Lookups Requested" }; _lookupsDuration ??= new EventCounter("dns-lookups-duration", this) { DisplayName = "Average DNS Lookup Duration", DisplayUnits = "ms" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { base.OnEventCommand(command); if (command.Command == EventCommand.SendManifest || command.Command != EventCommand.Disable || FunctionDefinitionRequested(command)) { if (!initialized) { // We're still in the constructor, need to defer sending until we've finished initializing Task.Yield().GetAwaiter().OnCompleted(SendFunctionDefinitionsAsync); return; } SendFunctionDefinitions(); } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). // They aren't disabled afterwards... // The cumulative number of HTTP requests started since the process started. _startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests)) { DisplayName = "Requests Started", }; // The number of HTTP requests started per second since the process started. _startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests)) { DisplayName = "Requests Started Rate", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; // The cumulative number of HTTP requests aborted since the process started. // Aborted means that an exception occurred during the handler's Send(Async) call as a result of a // connection related error, timeout, or explicitly cancelled. _abortedRequestsCounter ??= new PollingCounter("requests-aborted", this, () => Interlocked.Read(ref _abortedRequests)) { DisplayName = "Requests Aborted" }; // The number of HTTP requests aborted per second since the process started. _abortedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-aborted-rate", this, () => Interlocked.Read(ref _abortedRequests)) { DisplayName = "Requests Aborted Rate", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; // The current number of active HTTP requests that have started but not yet completed or aborted. // Use (-_stoppedRequests + _startedRequests) to avoid returning a negative value if _stoppedRequests is // incremented after reading _startedRequests due to race conditions with completing the HTTP request. _currentRequestsCounter ??= new PollingCounter("current-requests", this, () => - Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests)) { DisplayName = "Current Requests" }; } }
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) }; } }
private void OnEventSourceCommand(object sender, EventCommandEventArgs e) { if (e.Command == EventCommand.Enable || e.Command == EventCommand.Update) { string valueStr; float value; if (e.Arguments.TryGetValue("EventCounterIntervalSec", out valueStr) && float.TryParse(valueStr, out value)) { // Recursion through EventSource callbacks possible. When we enable the timer // we synchonously issue a EventSource.Write event, which in turn can call back // to user code (in an EventListener) while holding this lock. This is dangerous // because it means this code might inadvertantly participate in a lock loop. // The scenario seems very unlikely so we ignore that problem for now. lock (this) // Lock the CounterGroup { EnableTimer(value); } } } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _rejectedRequestsCounter ??= new PollingCounter("requests-rejected", this, () => _rejectedRequests) { DisplayName = "Rejected Requests", }; _queueLengthCounter ??= new PollingCounter("queue-length", this, () => _queueLength) { DisplayName = "Queue Length", }; _queueDuration ??= new EventCounter("queue-duration", this) { DisplayName = "Average Time in Queue", }; } }
/// <remarks> /// This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). /// They aren't disabled afterwards /// </remarks> protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _cacheItemCounter ??= new PollingCounter(CacheItemCounterName, this, () => Interlocked.Read(ref _totalItemCount)) { DisplayName = "Total cache items (Write - Remove)" }; _cacheWriteCounter ??= new PollingCounter(CacheWriteCounterName, this, () => Interlocked.Read(ref _writeCount)) { DisplayName = "Total cache write calls" }; _cacheReadCounter ??= new PollingCounter(CacheReadCounterName, this, () => Interlocked.Read(ref _readCount)) { DisplayName = "Total cache read calls" }; _cacheReadMissCounter ??= new PollingCounter(CacheReadMissCounterName, this, () => Interlocked.Read(ref _readMissCount)) { DisplayName = "Total cache read misses" }; _cacheRemoveCounter ??= new PollingCounter(CacheRemoveCounterName, this, () => Interlocked.Read(ref _removeCount)) { DisplayName = "Total cache remove calls" }; _cacheSizeCounter ??= new PollingCounter(CacheSizeCounterName, this, () => Interlocked.Read(ref _cacheSizeInBytes)) { DisplayName = "Total cache size", DisplayUnits = "B" }; _cacheReadDurationCounter ??= new EventCounter(CacheReadDurationCounterName, this) { DisplayName = "Cache read duration", DisplayUnits = "ms" }; _cacheWriteDurationCounter ??= new EventCounter(CacheWriteDurationCounterName, this) { DisplayName = "Cache write duration", DisplayUnits = "ms" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _connectionOpenedCounter ??= new PollingCounter("total-connections-opened", this, () => ConnectionsOpened) { DisplayName = "Total connections opened" }; _openConnectionCounter ??= new PollingCounter("current-open-connections", this, () => ConnectionsOpened - ConnectionsClosed) { DisplayName = "Current open connections count" }; _channelOpenedCounter ??= new PollingCounter("total-channels-opened", this, () => ChannelsOpened) { DisplayName = "Total channels opened" }; _openChannelCounter ??= new PollingCounter("current-open-channels", this, () => ChannelsOpened - ChannelsClosed) { DisplayName = "Current open channels count" }; _bytesSentCounter ??= new IncrementingPollingCounter("bytes-sent-rate", this, () => Interlocked.Read(ref BytesSent)) { DisplayName = "Byte sending rate", DisplayUnits = "B", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _bytesReceivedCounter ??= new IncrementingPollingCounter("bytes-received-rate", this, () => Interlocked.Read(ref BytesReceived)) { DisplayName = "Byte receiving rate", DisplayUnits = "B", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _commandSentCounter ??= new IncrementingPollingCounter("AMQP-method-sent-rate", this, () => Interlocked.Read(ref CommandsSent)) { DisplayName = "AMQP method sending rate", DisplayUnits = "B", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; _commandReceivedCounter ??= new IncrementingPollingCounter("AMQP-method-received-rate", this, () => Interlocked.Read(ref CommandsReceived)) { DisplayName = "AMQP method receiving rate", DisplayUnits = "B", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; } }
// Token: 0x0600415C RID: 16732 RVA: 0x000F2FD8 File Offset: 0x000F11D8 protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { AsyncCausalityTracer.EnableToETW(true); } else if (command.Command == EventCommand.Disable) { AsyncCausalityTracer.EnableToETW(false); } if (base.IsEnabled(EventLevel.Informational, (EventKeywords)128L)) { ActivityTracker.Instance.Enable(); } else { this.TasksSetActivityIds = base.IsEnabled(EventLevel.Informational, (EventKeywords)65536L); } this.Debug = base.IsEnabled(EventLevel.Informational, (EventKeywords)131072L); this.DebugActivityId = base.IsEnabled(EventLevel.Informational, (EventKeywords)262144L); }
protected override void OnEventCommand(EventCommandEventArgs command) { // On every command (which the debugger can force by turning on this EventSource with ETW) // call a function that the debugger can hook to do an arbitrary func evaluation. BreakPointWithDebuggerFuncEval(); lock (this) { if ((command.Command == EventCommand.Update || command.Command == EventCommand.Enable) && IsEnabled(EventLevel.Informational, Keywords.Events)) { string filterAndPayloadSpecs; command.Arguments.TryGetValue("FilterAndPayloadSpecs", out filterAndPayloadSpecs); FilterAndTransform.CreateFilterAndTransformList(ref _specs, filterAndPayloadSpecs, this); } else if (command.Command == EventCommand.Update || command.Command == EventCommand.Disable) { FilterAndTransform.DestroyFilterAndTransformList(ref _specs); } } }
void WireEventToItem(IApplicationBarMenuItem item) { //if (commandSubscription != null) //{ // commandSubscription.Dispose(); // commandSubscription = null; //} //commandSubscription = Observable.FromEventPattern( eh => item.Click += eh, eh => item.Click -= eh) .Subscribe( ev => { var agg = EventCommandEventArgs.Create(AssociatedObject.CommandParameter, null, ev.Sender, ev.EventArgs, "Click", typeof(EventHandler)); EventRouting.EventRouter.Instance .RaiseEvent(item, agg, EventFilterName); } ); }
private void OnEventSourceCommand(object?sender, EventCommandEventArgs e) { if (e.Command == EventCommand.Enable || e.Command == EventCommand.Update) { Debug.Assert(e.Arguments != null); if (e.Arguments.TryGetValue("EventCounterIntervalSec", out string?valueStr) && float.TryParse(valueStr, out float value)) { lock (this) // Lock the CounterGroup { EnableTimer(value); } } } else if (e.Command == EventCommand.Disable) { lock (this) { _pollingIntervalInMilliseconds = 0; } } }
protected override void OnEventCommand(EventCommandEventArgs command) { base.OnEventCommand(command); if (command.Command == EventCommand.SendManifest || command.Command != EventCommand.Disable || FunctionDefinitionRequested(command)) { // Use helper functions rather than lambdas since the auto-generated manifest // doesn't know what to do with compiler generated methods. // here, we use Task to make things run in background thread if (initialized) { SendFunctionDefinitionsAsync(); } else { // We're still in the constructor, need to defer sending until we've finished initializing Task.Yield().GetAwaiter().OnCompleted(SendFunctionDefinitionsAsync); } } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _cacheItemCounter ??= new PollingCounter(CacheItemCounterName, this, () => _totalItemCount) { DisplayName = "Total cache items (Write - Remove)" }; _cacheWriteCounter ??= new PollingCounter(CacheWriteCounterName, this, () => _writeCount) { DisplayName = "Total cache write calls" }; _cacheReadCounter ??= new PollingCounter(CacheReadCounterName, this, () => _readCount) { DisplayName = "Total cache read calls" }; _cacheRemoveCounter ??= new PollingCounter(CacheRemoveCounterName, this, () => _removeCount) { DisplayName = "Total cache remove calls" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // NOTE: These counters will NOT be disposed on disable command because we may be introducing // a race condition by doing that. We still want to create these lazily so that we aren't adding // overhead by at all times even when counters aren't enabled. // On disable, PollingCounters will stop polling for values so it should be fine to leave them around. _cpuTimeCounter = _cpuTimeCounter ?? new PollingCounter("cpu-usage", this, () => RuntimeEventSourceHelper.GetCpuUsage()) { DisplayName = "CPU Usage" }; _workingSetCounter = _workingSetCounter ?? new PollingCounter("working-set", this, () => (double)(Environment.WorkingSet / 1000000)) { DisplayName = "Working Set" }; _gcHeapSizeCounter = _gcHeapSizeCounter ?? new PollingCounter("gc-heap-size", this, () => (double)(GC.GetTotalMemory(false) / 1000000)) { DisplayName = "GC Heap Size" }; _gen0GCCounter = _gen0GCCounter ?? new IncrementingPollingCounter("gen-0-gc-count", this, () => GC.CollectionCount(0)) { DisplayName = "Gen 0 GC Count", DisplayRateTimeScale = new TimeSpan(0, 1, 0) }; _gen1GCCounter = _gen1GCCounter ?? new IncrementingPollingCounter("gen-1-gc-count", this, () => GC.CollectionCount(1)) { DisplayName = "Gen 1 GC Count", DisplayRateTimeScale = new TimeSpan(0, 1, 0) }; _gen2GCCounter = _gen2GCCounter ?? new IncrementingPollingCounter("gen-2-gc-count", this, () => GC.CollectionCount(2)) { DisplayName = "Gen 2 GC Count", DisplayRateTimeScale = new TimeSpan(0, 1, 0) }; _exceptionCounter = _exceptionCounter ?? new IncrementingPollingCounter("exception-count", this, () => Exception.GetExceptionCount()) { DisplayName = "Exception Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). // They aren't disabled afterwards... _inflightMessagesCounter ??= new IncrementingPollingCounter("inflight-messages", this, () => _inflightMessages) { DisplayName = "Inflight Messages", DisplayUnits = "Messages" }; _messageProcessDurationCounter ??= new EventCounter("message-process-duration", this) { DisplayName = "Average Message Process Duration", DisplayUnits = "ms" }; _messageDispatchDurationCounter ??= new EventCounter("message-dispatch-duration", this) { DisplayName = "Average Message Dispatch Duration", DisplayUnits = "ms" }; _processedCountCounter ??= new IncrementingPollingCounter("processed-count", this, () => _processedCount) { DisplayName = "Messages Processed", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _dispatchingCounter ??= new IncrementingPollingCounter("dispatching-count", this, () => _dispatchingMessages) { DisplayName = "Messages Dispatching", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _dispatchedCounter ??= new IncrementingPollingCounter("dispatched-count", this, () => _dispatchedMessages) { DisplayName = "Messages Dispatched", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { try { // Do some extra stuff to be extra certain the compiler introduced a local instead of using `dup` var tmp = new VerifyExpectModifiedAttributesWork.ClassForLocal(); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, 3, 4); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, 4, 4); var hashcode = tmp.GetHashCode(); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, hashcode, 3); } catch { try { Removed(); } catch { var tmp = new VerifyExpectModifiedAttributesWork.ClassForLocal(); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, 3, 4); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, 4, 4); var hashcode = tmp.GetHashCode(); VerifyExpectModifiedAttributesWork.CallsToForceALocal(1, hashcode, 3); throw; } throw; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). // They aren't disabled afterwards... _totalCallsCounter ??= new PollingCounter("total-calls", this, () => _totalCalls) { DisplayName = "Total Calls", }; _currentCallsCounter ??= new PollingCounter("current-calls", this, () => _currentCalls) { DisplayName = "Current Calls" }; _callsFailedCounter ??= new PollingCounter("calls-failed", this, () => _callsFailed) { DisplayName = "Total Calls Failed", }; _callsDeadlineExceededCounter ??= new PollingCounter("calls-deadline-exceeded", this, () => _callsDeadlineExceeded) { DisplayName = "Total Calls Deadline Exceeded", }; _messagesSentCounter ??= new PollingCounter("messages-sent", this, () => _messageSent) { DisplayName = "Total Messages Sent", }; _messagesReceivedCounter ??= new PollingCounter("messages-received", this, () => _messageReceived) { DisplayName = "Total Messages Received", }; _callsUnimplementedCounter ??= new PollingCounter("calls-unimplemented", this, () => _callsUnimplemented) { DisplayName = "Total Calls Unimplemented", }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _scanInvocationCounter = new IncrementingEventCounter("scan-invocations", this) { DisplayName = "Scan Invocations", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _scanInvocationDurationCounter = new EventCounter("scan-invocation-duration", this) { DisplayName = "Scan Duration", DisplayUnits = "ms" }; _scanEntriesFoundCounter = new IncrementingEventCounter("scan-entries-count", this) { DisplayName = "Scan XML Count", DisplayUnits = "Entries", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). _currentOutgoingConnectAttemptsCounter ??= new PollingCounter("current-outgoing-connect-attempts", this, () => Interlocked.Read(ref _currentOutgoingConnectAttempts)) { DisplayName = "Current Outgoing Connect Attempts", }; _outgoingConnectionsEstablishedCounter ??= new PollingCounter("outgoing-connections-established", this, () => Interlocked.Read(ref _outgoingConnectionsEstablished)) { DisplayName = "Outgoing Connections Established", }; _incomingConnectionsEstablishedCounter ??= new PollingCounter("incoming-connections-established", this, () => Interlocked.Read(ref _incomingConnectionsEstablished)) { DisplayName = "Incoming Connections Established", }; _bytesReceivedCounter ??= new PollingCounter("bytes-received", this, () => Interlocked.Read(ref _bytesReceived)) { DisplayName = "Bytes Received", }; _bytesSentCounter ??= new PollingCounter("bytes-sent", this, () => Interlocked.Read(ref _bytesSent)) { DisplayName = "Bytes Sent", }; _datagramsReceivedCounter ??= new PollingCounter("datagrams-received", this, () => Interlocked.Read(ref _datagramsReceived)) { DisplayName = "Datagrams Received", }; _datagramsSentCounter ??= new PollingCounter("datagrams-sent", this, () => Interlocked.Read(ref _datagramsSent)) { DisplayName = "Datagrams Sent", }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { _inflightMessagesCounter ??= new IncrementingPollingCounter("inflight-messages", this, () => _inflightMessages) { DisplayName = "Inflight Messages", DisplayUnits = "Messages" }; _processedCountCounter ??= new IncrementingPollingCounter("processed-count", this, () => _processedCount) { DisplayName = "Messages Processed", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _messageDurationCounter ??= new EventCounter("message-duration", this) { DisplayName = "Average Message Duration", DisplayUnits = "ms" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { base.OnEventCommand(command); }
protected virtual void OnEventCommand(EventCommandEventArgs command) { }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command). // They aren't disabled afterwards... // The cumulative number of HTTP requests started since the process started. _startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests)) { DisplayName = "Requests Started", }; // The number of HTTP requests started per second since the process started. _startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests)) { DisplayName = "Requests Started Rate", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; // The cumulative number of HTTP requests failed since the process started. // Failed means that an exception occurred during the handler's Send(Async) call as a result of a connection related error, timeout, or explicitly cancelled. // In case of using HttpClient's SendAsync(and friends) with buffering, this includes exceptions that occured while buffering the response content // In case of using HttpClient's helper methods (GetString/ByteArray/Stream), this includes responses with non-success status codes _failedRequestsCounter ??= new PollingCounter("requests-failed", this, () => Interlocked.Read(ref _failedRequests)) { DisplayName = "Requests Failed" }; // The number of HTTP requests failed per second since the process started. _failedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-failed-rate", this, () => Interlocked.Read(ref _failedRequests)) { DisplayName = "Requests Failed Rate", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; // The current number of active HTTP requests that have started but not yet completed or failed. // Use (-_stoppedRequests + _startedRequests) to avoid returning a negative value if _stoppedRequests is // incremented after reading _startedRequests due to race conditions with completing the HTTP request. _currentRequestsCounter ??= new PollingCounter("current-requests", this, () => - Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests)) { DisplayName = "Current Requests" }; _totalHttp11ConnectionsCounter ??= new PollingCounter("http11-connections-current-total", this, () => Interlocked.Read(ref _openedHttp11Connections)) { DisplayName = "Current Http 1.1 Connections" }; _totalHttp20ConnectionsCounter ??= new PollingCounter("http20-connections-current-total", this, () => Interlocked.Read(ref _openedHttp20Connections)) { DisplayName = "Current Http 2.0 Connections" }; _http11RequestsQueueDurationCounter ??= new EventCounter("http11-requests-queue-duration", this) { DisplayName = "HTTP 1.1 Requests Queue Duration", DisplayUnits = "ms" }; _http20RequestsQueueDurationCounter ??= new EventCounter("http20-requests-queue-duration", this) { DisplayName = "HTTP 2.0 Requests Queue Duration", DisplayUnits = "ms" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { Removed2(); }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { // Comment taken from RuntimeEventSource in CoreCLR // NOTE: These counters will NOT be disposed on disable command because we may be introducing // a race condition by doing that. We still want to create these lazily so that we aren't adding // overhead by at all times even when counters aren't enabled. // On disable, PollingCounters will stop polling for values so it should be fine to leave them around. _bytesWrittenPerSecondCounter = new IncrementingPollingCounter("bytes-written-per-second", this, () => _bytesWritten) { DisplayName = "Bytes Written", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _bytesReadPerSecondCounter = new IncrementingPollingCounter("bytes-read-per-second", this, () => _bytesRead) { DisplayName = "Bytes Read", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _commandsPerSecondCounter = new IncrementingPollingCounter("commands-per-second", this, () => _totalCommands) { DisplayName = "Command Rate", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _totalCommandsCounter = new PollingCounter("total-commands", this, () => _totalCommands) { DisplayName = "Total Commands", }; _currentCommandsCounter = new PollingCounter("current-commands", this, () => _currentCommands) { DisplayName = "Current Commands" }; _failedCommandsCounter = new PollingCounter("failed-commands", this, () => _failedCommands) { DisplayName = "Failed Commands" }; _preparedCommandsRatioCounter = new PollingCounter( "prepared-commands-ratio", this, () => (double)_totalPreparedCommands / (double)_totalCommands) { DisplayName = "Prepared Commands Ratio", DisplayUnits = "%" }; _poolsCounter = new PollingCounter("connection-pools", this, () => _pools) { DisplayName = "Connection Pools" }; _idleConnectionsCounter = new PollingCounter("idle-connections", this, () => GetIdleConnections()) { DisplayName = "Idle Connections" }; _busyConnectionsCounter = new PollingCounter("busy-connections", this, () => GetBusyConnections()) { DisplayName = "Busy Connections" }; _multiplexingAverageCommandsPerBatchCounter = new PollingCounter("multiplexing-average-commands-per-batch", this, () => (double)_multiplexingCommandsSent / _multiplexingBatchesSent) { DisplayName = "Average commands per multiplexing batch" }; _multiplexingAverageWaitsPerBatchCounter = new PollingCounter("multiplexing-average-waits-per-batch", this, () => (double)_multiplexingWaits / _multiplexingBatchesSent) { DisplayName = "Average waits per multiplexing batch" }; _multiplexingAverageWriteTimePerBatchCounter = new PollingCounter("multiplexing-average-write-time-per-batch", this, () => (double)_multiplexingTicksWritten / _multiplexingBatchesSent / 1000) { DisplayName = "Average write time per multiplexing batch (us)", DisplayUnits = "us" }; } }
protected override void OnEventCommand(EventCommandEventArgs command) { base.OnEventCommand(command); }
protected virtual void OnEventCommand (EventCommandEventArgs command) { }
protected override void OnEventCommand(EventCommandEventArgs command) { base.OnEventCommand(command); this.Commands.Add(command.Arguments); }