Exemplo n.º 1
0
        public void TestLatencyAlert()
        {
            var services   = new[] { "s0", "s1", "s2" };
            var customers  = new[] { "c0", "c1", "c2" };
            var limitSpike = new[] { 15000L, 10000L, 10040L };

            // Set up limits for 3 services/customer combinations
            for (var i = 0; i < services.Length; i++)
            {
                var limit = new LatencyLimit(services[i], customers[i], limitSpike[i]);
                runtime.SendEvent(limit);
            }

            // Send events
            for (int i = 0; i < 100; i++)
            {
                for (int index = 0; index < services.Length; index++)
                {
                    var measurement = new OperationMeasurement(services[index], customers[index], 9950 + i, true);
                    runtime.SendEvent(measurement);
                }
            }

            // Send a new limit
            var nlimit = new LatencyLimit(services[1], customers[1], 8000);

            runtime.SendEvent(nlimit);

            // Send a new spike
            var nmeasurement = new OperationMeasurement(services[1], customers[1], 8001, true);

            runtime.SendEvent(nmeasurement);
        }
Exemplo n.º 2
0
        public DynaLatencySpikeMonitor(LatencyLimit limit)
        {
            Log.Debug("New limit, for operation '" + limit.OperationName +
                      "' and customer '" + limit.CustomerId + "'" +
                      " setting threshold " + limit.LatencyThreshold);

            var filter = "operationName='" + limit.OperationName +
                         "',customerId='" + limit.CustomerId + "'";

            // Alert specific to operation and customer
            _spikeLatencyAlert = _admin.CreatePattern(
                "every alert=" + typeof(OperationMeasurement).FullName +
                "(" + filter + ", latency>" + limit.LatencyThreshold + ")");
            _spikeLatencyAlert.Events += LogLatencyEvent;

            // Stop pattern when the threshold changes
            String      eventName   = typeof(LatencyLimit).FullName;
            EPStatement stopPattern = _admin.CreatePattern(eventName + "(" + filter + ")");

            stopPattern.Events += ((newEvents, oldEvents) => _spikeLatencyAlert.Stop());
        }
Exemplo n.º 3
0
        public DynaLatencySpikeMonitor(LatencyLimit limit)
        {
            Log.Debug("New limit, for operation '" + limit.OperationName +
                      "' and customer '" + limit.CustomerId + "'" +
                      " setting threshold " + limit.LatencyThreshold);

            var filter = "operationName='" + limit.OperationName +
                         "',customerId='" + limit.CustomerId + "'";

            // Alert specific to operation and customer
            _spikeLatencyDeployment = _runtime.CompileDeploy(
                "every alert=" + typeof(OperationMeasurement).FullName +
                "(" + filter + ", latency>" + limit.LatencyThreshold + ")");
            _spikeLatencyAlert         = _spikeLatencyDeployment.Statements[0];
            _spikeLatencyAlert.Events += LogLatencyEvent;

            // Stop pattern when the threshold changes
            var eventName   = typeof(LatencyLimit).FullName;
            var stopPattern = _runtime.DeployStatement(eventName + "(" + filter + ")");

            stopPattern.Events += ((newEvents, oldEvents) => _runtime
                                   .DeploymentService.Undeploy(_spikeLatencyAlert.DeploymentId));
        }