Data Access has been discontinued. Please refer to this page for more information.

How to: Configure Fluent Model For Monitoring

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This topic demonstrates how to configure Fluent Mapping model for online and offline profiling. When you use the Visual Designer, the entire configuration is done via the Model Settings Dialog as it is demonstrated in the online and offline topics. In your fluent mapping applications, where you don't have a Visual Designer, you have to add few lines of code in the context class to enable the online/offline monitoring.

To configure your fluent model for monitoring, you need to modify the BackendConfiguration object. You can do that when you create and initialize the BackendConfiguration object or in the constructor of the FluentModelContext class. For example:

public partial class FluentModelContext : OpenAccessContext
{
   public FluentModelContext()
       : base( DbConnection, backendConfiguration, metadataContainer )
   {
       // Configure your model for monitioring here.
   }
}
Partial Public Class FluentModelContext
 Inherits OpenAccessContext
 Public Sub New()
  MyBase.New(DbConnection, backendConfiguration, metadataContainer)
  ' Configure your model for monitioring here.
 End Sub
End Class

Offline Profiling

The following code snippet shows the minimal settings you need to consider and/or specify for offline monitoring:

public partial class FluentModelContext : OpenAccessContext
{
   public FluentModelContext()
       : base( DbConnection, backendConfiguration, metadataContainer )
   {
       backendConfiguration.Logging.LogEvents = LoggingLevel.Normal;
       backendConfiguration.Logging.StackTrace = true;
       backendConfiguration.Logging.EventStoreCapacity = 10000;
       backendConfiguration.Logging.MetricStoreCapacity = 3600;
       backendConfiguration.Logging.MetricStoreSnapshotInterval = 1000;
       backendConfiguration.Logging.Downloader.EventBinary = true;
       backendConfiguration.Logging.Downloader.MetricBinary = true;
       backendConfiguration.Logging.Downloader.Filename = "C:\\MyFileName";
       backendConfiguration.Logging.Downloader.MaxFileSizeKB = 1000;
       backendConfiguration.Logging.Downloader.NumberOfBackups = 3;
       backendConfiguration.Logging.Downloader.EventPollSeconds = 1;
       backendConfiguration.Logging.Downloader.MetricPollSeconds = 1;        
   }
}
Partial Public Class FluentModelContext
 Inherits OpenAccessContext
 Public Sub New()
  MyBase.New(DbConnection, backendConfiguration, metadataContainer)
  backendConfiguration.Logging.LogEvents = LoggingLevel.Normal
  backendConfiguration.Logging.StackTrace = True
  backendConfiguration.Logging.EventStoreCapacity = 10000
  backendConfiguration.Logging.MetricStoreCapacity = 3600
  backendConfiguration.Logging.MetricStoreSnapshotInterval = 1000
  backendConfiguration.Logging.Downloader.EventBinary = True
  backendConfiguration.Logging.Downloader.MetricBinary = True
  backendConfiguration.Logging.Downloader.Filename = "C:\MyFileName"
  backendConfiguration.Logging.Downloader.MaxFileSizeKB = 1000
  backendConfiguration.Logging.Downloader.NumberOfBackups = 3
  backendConfiguration.Logging.Downloader.EventPollSeconds = 1
  backendConfiguration.Logging.Downloader.MetricPollSeconds = 1
 End Sub
End Class
  • The LogEvents property specifies the amount of logging information to be generated. The event logging levels are as follows:
    • None - logs no events.
    • Errors - logs only serious errors (such as connections timing out). This is the default value.
    • Normal - logs the most useful events that do not reduce performance significantly (e.g. SQL executed).
    • Verbose - logs lots of events (this slows down the performance, could be used while debugging).
    • All - logs all possible events (this slows down the performance very significantly, could be used while debugging).
  • StackTrace - controls if the logging facilities append stack trace information. The default value for this option is False.
  • EventStoreCapacity - the size of the event store in the memory.
  • MetricStoreCapacity - the size of the metric store in the memory.

    Telerik Data Access produces two different kinds of data - metrics and events. Metrics are similar to the operating system counters. They produce snapshots of the system status like counting insert, update and delete statements per second. Log events contain the real operation information, including query parameters and stack traces. Compared to metrics, the production of log events is far more expensive and can slow down the application.

  • MetricStoreSnapshotInterval - controls the interval to perform metric snapshots in milliseconds.

  • EventBinary - specifies whether events should be logged in binary form or not.
  • MetricBinary - specifies whether metrics should be logged in binary form or not.
  • FileName - Telerik Data Access writes metrics and log events in different files. With the default settings, Telerik Data Access stores the log files in the application working directory (the \bin\debug directory). The default name for the log events file is openaccess_<ConnectionID>.oalog. The default name for the metrics file is openaccess_<ConnectionID>.oametrics. Where <ConnectionID> is the connection alias name that is used in the application, i.e. the name of the connection string in the app/web.config file. For example, if the name of the connection string is SofiaCarRentalDbConnection, then the names of the log files will be: openaccess_SofiaCarRentalDbConnection.oalog and openaccess_SofiaCarRentalDbConnection.oametrics. And these files will be stored in the application working directory. The above settings will produce the files MyFileName.oalog and MyFileName.oametrics in the C:\ directory.
  • MaxFileSizeKB and NumberOfBackups - the maximum file size and the maximum amount of historical files can be configured. To do that, you need to use the MaxFileSizeKB and the NumberOfBackups settings. By default the maximum size of the log files is 1000KB and the maximum amount of historical files is 3. If the log file reaches the configured maximum size, it is renamed to fileName.1. If a file with name fileName.1 already exists, then it is renamed to fileName.2. If the maximum number of files has been reached, the oldest file is deleted. The new data will be stored in a new file.
  • EventPollSeconds - controls the time in seconds between polls of the event ring buffer.
  • MetricPollSeconds - controls the time in seconds between polls of the metric snapshot ring buffer.

Real-Time Profiling

The following code snippet shows the minimal settings you need to consider and/or specify for real-time (online) monitoring:

public partial class FluentModelContext : OpenAccessContext
{
   public FluentModelContext()
       : base( DbConnection, backendConfiguration, metadataContainer )
   {
       backendConfiguration.Logging.LogEvents = LoggingLevel.Normal;
       backendConfiguration.Logging.StackTrace = true;
       backendConfiguration.Logging.EventStoreCapacity = 10000;
       backendConfiguration.Logging.MetricStoreCapacity = 3600;
       backendConfiguration.Logging.MetricStoreSnapshotInterval = 1000;
       backendConfiguration.Logging.Downloader.EventPollSeconds = 1;
       backendConfiguration.Logging.Downloader.MetricPollSeconds = 1;
   }
}
Partial Public Class FluentModelContext
 Inherits OpenAccessContext
 Public Sub New()
  MyBase.New(DbConnection, backendConfiguration, metadataContainer)
  backendConfiguration.Logging.LogEvents = LoggingLevel.Normal
  backendConfiguration.Logging.StackTrace = True
  backendConfiguration.Logging.EventStoreCapacity = 10000
  backendConfiguration.Logging.MetricStoreCapacity = 3600
  backendConfiguration.Logging.MetricStoreSnapshotInterval = 1000
  backendConfiguration.Logging.Downloader.EventPollSeconds = 1
  backendConfiguration.Logging.Downloader.MetricPollSeconds = 1
 End Sub
End Class

Additionally, you need to add a reference to the Telerik.OpenAccess.ServiceHost.dll assembly and the profiler service host from the application. For more information, see How to: Configure Telerik Data Access Project For Real-Time Monitoring.

Telerik.OpenAccess.ServiceHost.ServiceHostManager.StartProfilerService(15555);
Telerik.OpenAccess.ServiceHost.ServiceHostManager.StartProfilerService(15555)