Ejemplo n.º 1
0
        private void Dynamic_All(TraceEvent obj)
        {
            // If we are paused, ignore the event.
            // There's a potential race here between the two tasks but not a huge deal if we miss by one event.
            writer.ToggleStatus(pauseCmdSet);

            if (obj.EventName.Equals("EventCounters"))
            {
                IDictionary <string, object> payloadVal    = (IDictionary <string, object>)(obj.PayloadValue(0));
                IDictionary <string, object> payloadFields = (IDictionary <string, object>)(payloadVal["Payload"]);

                // If it's not a counter we asked for, ignore it.
                if (!filter.Filter(obj.ProviderName, payloadFields["Name"].ToString()))
                {
                    return;
                }

                // There really isn't a great way to tell whether an EventCounter payload is an instance of
                // IncrementingCounterPayload or CounterPayload, so here we check the number of fields
                // to distinguish the two.
                ICounterPayload payload;
                if (payloadFields.ContainsKey("CounterType"))
                {
                    payload = payloadFields["CounterType"].Equals("Sum") ? (ICounterPayload) new IncrementingCounterPayload(payloadFields) : (ICounterPayload) new CounterPayload(payloadFields);
                }
                else
                {
                    payload = payloadFields.Count == 6 ? (ICounterPayload) new IncrementingCounterPayload(payloadFields) : (ICounterPayload) new CounterPayload(payloadFields);
                }
                writer.Update(obj.ProviderName, payload, pauseCmdSet);
            }
        }
Ejemplo n.º 2
0
        private void DynamicAllMonitor(TraceEvent obj)
        {
            // If we are paused, ignore the event.
            // There's a potential race here between the two tasks but not a huge deal if we miss by one event.
            _renderer.ToggleStatus(pauseCmdSet);

            if (obj.EventName.Equals("EventCounters"))
            {
                IDictionary <string, object> payloadVal    = (IDictionary <string, object>)(obj.PayloadValue(0));
                IDictionary <string, object> payloadFields = (IDictionary <string, object>)(payloadVal["Payload"]);

                // If it's not a counter we asked for, ignore it.
                if (!filter.Filter(obj.ProviderName, payloadFields["Name"].ToString()))
                {
                    return;
                }

                ICounterPayload payload = payloadFields["CounterType"].Equals("Sum") ? (ICounterPayload) new IncrementingCounterPayload(payloadFields, _interval) : (ICounterPayload) new CounterPayload(payloadFields);
                _renderer.CounterPayloadReceived(obj.ProviderName, payload, pauseCmdSet);
            }
        }