Exemple #1
0
 public TransactionAgent(IClock clock, ILogger <TransactionAgent> logger, TransactionAgentStatistics statistics, ITransactionOverloadDetector overloadDetector)
 {
     this.clock            = new CausalClock(clock);
     this.logger           = logger;
     this.statistics       = statistics;
     this.overloadDetector = overloadDetector;
 }
 public TransactionOverloadDetector(ITransactionAgentStatistics statistics, IOptions <TransactionRateLoadSheddingOptions> options)
 {
     this.statistics     = statistics;
     this.options        = options.Value;
     this.monitor        = new PeriodicAction(MetricsCheck, this.RecordStatistics);
     this.lastStatistics = TransactionAgentStatistics.Copy(statistics);
     this.lastCheckTime  = DateTime.UtcNow;
 }
Exemple #3
0
 public TransactionAgentStatisticsReporter(ITransactionAgentStatistics statistics, ITelemetryProducer telemetryProducer, IOptions <StatisticsOptions> options)
 {
     this.statistics        = statistics ?? throw new ArgumentNullException(nameof(statistics));
     this.telemetryProducer = telemetryProducer ?? throw new ArgumentNullException(nameof(statistics));
     this.statisticsOptions = options.Value;
     this.lastReported      = TransactionAgentStatistics.Copy(statistics);
     this.lastReportTime    = DateTime.UtcNow;
 }
        private void RecordStatistics()
        {
            ITransactionAgentStatistics current = TransactionAgentStatistics.Copy(this.statistics);
            DateTime now = DateTime.UtcNow;

            this.transactionStartedPerSecond = CalculateTps(this.lastStatistics.TransactionsStarted, this.lastCheckTime, current.TransactionsStarted, now);
            this.lastStatistics = current;
            this.lastCheckTime  = now;
        }
Exemple #5
0
        private void ReportMetrics(object ignore)
        {
            ITransactionAgentStatistics currentReported = TransactionAgentStatistics.Copy(statistics);
            var      now          = DateTime.UtcNow;
            TimeSpan reportPeriod = now - this.lastReportTime;

            this.telemetryProducer.TrackMetric(TransactionsStartedTotalMetric, currentReported.TransactionsStarted);
            this.telemetryProducer.TrackMetric(TransactionsStartedPerSecondMetric, PerSecond(this.lastReported.TransactionsStarted, currentReported.TransactionsStarted, reportPeriod));

            this.telemetryProducer.TrackMetric(SuccessfulTransactionsTotalMetric, currentReported.TransactionsSucceeded);
            this.telemetryProducer.TrackMetric(SuccessfulTransactionsPerSecondMetric, PerSecond(this.lastReported.TransactionsSucceeded, currentReported.TransactionsSucceeded, reportPeriod));

            this.telemetryProducer.TrackMetric(FailedTransactionsTotalMetric, currentReported.TransactionsFailed);
            this.telemetryProducer.TrackMetric(FailedTransactionsPerSecondMetric, PerSecond(this.lastReported.TransactionsFailed, currentReported.TransactionsFailed, reportPeriod));

            this.telemetryProducer.TrackMetric(ThrottledTransactionsTotalMetric, currentReported.TransactionsThrottled);
            this.telemetryProducer.TrackMetric(ThrottledTransactionsPerSecondMetric, PerSecond(this.lastReported.TransactionsThrottled, currentReported.TransactionsThrottled, reportPeriod));

            this.lastReportTime = now;
            this.lastReported   = currentReported;
        }