Skip to content

2. Data Collection, Querying and Retrieval: TelemetryStore

RRO edited this page Mar 23, 2018 · 9 revisions

The TelemetryCollector is responsible for collecting, querying and storing the data received from Azure Application Insights. It consists of the following parts:

  • DataCollection: Where data is collected from Application Insights
  • Model: The data model used to store the data
  • Store: The logic used to store the data
  • Filter: Where data can be queried by the user
  • Persistance: A persistance module to temporarily store the collected data on disk

Data Collection

Data Collection is designed to work with the Azure Application Insights (AAI) External REST API interface. It allows a user to query telemetry data of a certain AAI instance. It consists of a ITelemetryCollector interface that has to be implemented by any new added data collection method. The used data collection method is defined in TelemetryCollectorRegistry, it is also possible to use multiple sources at a time. The arriving data is stored in an object called RecordedMethodTelemetry, in the Azure REST API case a data container that stores all relevant data. It contains conversion methods to return Store Objects that can actually be stored (a CollectedDataEntity cannot be stored, it has to be converted).

Model

The Model is used to store and distribute that data. It therefore contains two different kinds of elements: RecordedMethodTelemetry, of which an instance is created for every incoming data telemetry element, as well as MethodPerformanceData, which summarizes RecordedMethodTelemetry elements on a method level. RecordedMethodTelemetry elements can be filtered on their properties. All stores therefore consists of a collection of AveragedMethod elements, one per method, and a collection of RecordedMethodTelemetry elements per method and per store. MethodPerformanceData has to be subclassed to create a new kind of store.

TelemetryCollectorRegistry

The logic for locally storing the actual data resides here. ITelemetryCollector is type generic, the structure of the data to be stored is provided by the model. New stores are instantiated in the TelemetryCollectorRegistry class that contains logic to fill new data into the stores, as well as generating summary objects (MethodPerformanceData). A store contains lists of all telemetry elements (in our case: RecordedMethodTelemetry).

The TelemetryCollector contains the logic necessary to bring the stores, the data model as well as the data collection together. Data Collection is done in an asynchronous way after a specified amount of time. If updates occurred since the last collection of data, the stores are updated asynchronously. The MethodPerformanceData instance is stored here and contains summarized information of all used stores.

Filter

Filter are applied on a store level basis and are also type generic. Detection of properties that can be filtered is done automatically by reflection. When a new FilterController is instantiated, it also receives the type generics of the data and provides the ability to create filters based on all properties available in the provided type. These properties can be retrieved by an interface in VS and used to create new filters. Currently, filters are implemented for the data types IComparable (ComparableFilter) and String (StringFilter)