|
Trend MonitoringIntroduction NDepend lets us create trend charts. Trend charts are made of trend metrics values logged over time at analysis time. More than 50 trend metrics are available per default and it is easy to create your own trend metrics. Trend charts are displayed on the NDepend dashboard. Some trend charts are available per default to show:
![]() For all trending related operations, a trend menu is available. ▲▲ Go to Top ▲▲ Trend Metrics To list the default trend metrics, look at the Queries and Rules Explorer panel and select the group named Trend Metrics. If trend metrics are listed in the code queries panel, it is because a trend metric is a CQLinq code query. It is a particular code query:
Since a trend metric is a code query, it is easy to create your own trend metrics or modify existing ones. For example here is a code query that counts the numbers of types implementing the interface System.IDisposable: There are six default trend metrics that are not code queries. They relate to the number of code rules violated and the number of code rules violations: Finally notice that when defining a Quality Gate thresholds, the keyword value must be replaced with the keyword count if the LINQ query is returning some rows instead of returning a scalar. This facility is useful to make Trend metrics are logged at analysis time as explained in the section Logging Trend Metrics. ▲▲ Go to Top ▲▲ Trend Charts The Create or Edit trend charts dialog lets us define all trend charts properties. The list of trend metrics series is available and checking a series lets us visualize it on the trend chart. A series appearance can be customized, this includes:
▲▲ Go to Top ▲▲ Reporting Trend Charts In the picture above we can see a tick box labelled: Show this trend chart in report. Trend charts can indeed be displayed in a report. Here you can see an example of Trend Charts in a report, made on the NDepend code base itself. For that the tick box NDepend Project Properties panel > Report tab > Use standard report ticked > Trend Charts must be ticked. ▲▲ Go to Top ▲▲ Logging Trend Metrics Trend metrics values are logged at analysis time. By running analysis every days, a list of trend metric dated values is built. Settings related to log of trend metrics values are available, both in the NDepend Options > Trend section, and in the NDepend Project Properties > Analysis > Trend Metrics Log section. If settings in Project Properties are set, they override the global settings defined in the Options. Trend metrics log settings includes:
Note that no matter what trend metrics log settings are used, the NDepend.Console.exe command line parameter /LogTrendMetrics will force logging of trend metrics during the analysis. ▲▲ Go to Top ▲▲ NDepend.API and Trending The namespace NDepend.Trend contains types and methods to load, save and remove trend metric values in the trend store. These operations are processed through an object that implements the interface NDepend.Trend.IStore. The interface NDepend.Project.IProjectTrend lets us read an modify project trend settings. The extension method LogTrendMetrics() forces the log of trend metrics on a IAnalysisResult object. In the OSS Power Tools, you'll find a tool named List stored Trend Values that demonstrates how to use the NDepend.API to read trend metrics values from a trend store. ▲▲ Go to Top ▲▲ |
