Azure Table Implementation of Activity Metrics
The TECHIS.Cloud.ActivityMetrics.AzureTable package is the Microsoft Azure implementation of the Activity Metrics System - AMS. See Activity Metrics for more details.
The activities are stored in the Activities table for which the developer provides the table name.
Use in Your Code
1) Add or Delete Activities
To add an occurrence or activity, you need to create an instance of the ActivityTracker, this you can do through the factory.
var activityTracker = (new ActivityTrackerFactory<TableEntity>()).Create(tableName);
To insert an activity, call the insert function:
await activityTracker.InsertAsync(tableEntity);
To delete, call the delete function:
await activityTracker.DeleteAsync(new Identifier (rowKey, partitionKey));
2) Generate Metrics
To generate metrics, you need an instance of IMetricsGenerator which you can get from the metrics generator factory:
var metricGeneratorFactory = new MetricsGeneratorFactory<long, EntityProperty, Configuration>();
The Create function of a MetricsGenerator, takes an instance of a calculator. Read more about Calculators in Activity Metrics.
var generator = metricGeneratorFactory.Create(calculator, sourceTable, metricsTable);
var results = await generator.GenerateAsync(batch);
3) Query for Metrics
To read and display results use an instance of the IMetricsQueryable interface type.
You can retrieve an instance of IMetricsQueryable through the factory:
var query = new MetricQueryableFactory<DynamicTableEntity>().Create((string)null);
var rows = await query.GetAsync(tableName, new QueryFilter("PartitionKey", [value]));