public IUsageMetrics GetAndResetReadMetrics(DateTime dateStamp, string hostVersion) { UsageMetrics.Version = hostVersion; lock (UsageMetrics) { var clonedMetrics = UsageMetrics.Clone(); clonedMetrics.SetDatestamp(dateStamp); clonedMetrics.EndTimeStamp = dateStamp.ToJSONString(); clonedMetrics.StartTimeStamp = UsageMetrics.StartTimeStamp; clonedMetrics.Status = "Running"; clonedMetrics.Calculate(); UsageMetrics.Reset(clonedMetrics.EndTimeStamp); return(clonedMetrics); } }
public UsageMetrics GetAndResetMetrics(DateTime actualDataStamp, string hostVersion) { _pipelineMetrics.Version = hostVersion; //TODO: This __could__ be a bottle neck, not sure though. /* This needs to be VERY, VERY fast since it will block anyone elses access to writing metrics */ lock (_pipelineMetrics) { var clonedMetrics = _pipelineMetrics.Clone() as UsageMetrics; clonedMetrics.RowKey = actualDataStamp.ToInverseTicksRowKey(); clonedMetrics.PartitionKey = Id; clonedMetrics.EndTimeStamp = actualDataStamp.ToJSONString(); clonedMetrics.StartTimeStamp = _pipelineMetrics.StartTimeStamp; clonedMetrics.Status = this.Status.ToString(); clonedMetrics.Calculate(); _pipelineMetrics.Reset(clonedMetrics.EndTimeStamp); return(clonedMetrics); } }
public void UsageMetrics_Clone() { var metricToClone = new UsageMetrics(); metricToClone.Version = "1.2.3.4"; metricToClone.HostId = "hostid"; metricToClone.InstanceId = "instanceid"; metricToClone.PipelineModuleId = "piplinemoduleid"; metricToClone.BytesProcessed = 12345; metricToClone.DeadLetterCount = 25; metricToClone.ErrorCount = 5; metricToClone.WarningCount = 12; metricToClone.ProcessingMS = 1235; metricToClone.MessagesProcessed = 1235; metricToClone.ActiveCount = 19; var clonedMetric = (UsageMetrics)metricToClone.Clone(); Assert.IsTrue(String.IsNullOrEmpty(clonedMetric.PartitionKey)); Assert.IsTrue(String.IsNullOrEmpty(clonedMetric.RowKey)); Assert.IsTrue(String.IsNullOrEmpty(clonedMetric.StartTimeStamp)); Assert.IsTrue(String.IsNullOrEmpty(clonedMetric.EndTimeStamp)); Assert.AreEqual("1.2.3.4", clonedMetric.Version); Assert.AreEqual("hostid", clonedMetric.HostId); Assert.AreEqual("instanceid", clonedMetric.InstanceId); Assert.AreEqual("piplinemoduleid", clonedMetric.PipelineModuleId); /* Note we do not concat messages processed, since each pipeline module will report on it, we only want to report on one */ Assert.AreEqual(1235, clonedMetric.MessagesProcessed); Assert.AreEqual(5, clonedMetric.ErrorCount); Assert.AreEqual(12345, clonedMetric.BytesProcessed); Assert.AreEqual(12, clonedMetric.WarningCount); Assert.AreEqual(1235, clonedMetric.ProcessingMS); Assert.AreEqual(25, clonedMetric.DeadLetterCount); Assert.AreEqual(19, clonedMetric.ActiveCount); }