> # Diagnostic Support

> The data provider delivers advanced diagnostic capability:

> - Ability to trace method calls
> - PerfMon counters that let you tune connection information for your application

> ### Tracing Method Calls

> Tracing capability can be enabled either through environment variables or the provider-specific SequeLinkTrace class. The data provider traces the input arguments to all of its public method calls, as well as the outputs and returns from those methods (anything that a user could potentially call). Each call contains trace entries for entering and exiting the method.

> During debugging, sensitive data can be read, even if it is stored as a private or internal variable and access is limited to the same assembly. To maintain security, trace logs show passwords as five asterisks (*****).

> Note, however, that if the Persist Security Info connection string option is set to true, the password will be displayed in clear text. See "Using Connection Pooling" for more information about connection strings.

> #### Using Environment Variables

> Using environment variables to enable tracing means that you do not have to modify your application. If you change the value of an environment variable, you must restart the application for the new value to take effect.

> To enable and control tracing, set the following environment variables:

> DDTek_Trace_File | Specifies the path and name of the trace file. The initial default is \SequeLinkTrace.txt.
> DDTek_Recreate_Trace | When set to 1, re-creates the trace file each time the application restarts. When set to 0 (the initial default), the trace file is appended.
> DDTek_Enable_Trace | When set to 1 or higher, enables tracing. When set to 0 (the initial default), tracing is disabled.

> #### Using Static Methods

> Some users may find that using static methods on the data provider's Trace class to be a more convenient way to enable tracing. The following C# code fragment uses static methods on the .NET Trace object to create a SequeLinkTrace class with a trace file named MyTrace.txt. The values set override the values set in the environmental variables. All subsequent calls to the data provider will be traced to MyTrace.txt.

>     SequeLinkTrace.TraceFile="C:\\MyTrace.txt";
>     SequeLinkTrace.RecreateTrace = 1;
>     SequeLinkTrace.EnableTrace = 1;

> The trace output has the following format:

>     <Correlation#> <Timestamp> <CurrentThreadName>
>        <Object Address> <ObjectName.MethodName> ENTER (or EXIT)
>           Argument #1 : <Argument#1 Value>
>           Argument #2 : <Argument#2 Value>
>           ...
>           RETURN:  <Method ReturnValue>  // This line only exists for
>     EXIT

> where:

> Correlation# is a unique number that can be used to match up ENTER and EXIT entries for the same method call in an application.

> Value is the hash code of an object appropriate to the individual function calls.

> ### PerfMon Support

> The Performance Monitor (PerfMon) utility in the Windows operating system allows you to record application parameters and review the results as a report or graph. You can also use Performance Monitor to identify the number and frequency of CLR exceptions in your applications.

> The SequeLink for .NET data provider installs a set of PerfMon counters that let you tune and debug applications that use the data provider. The data provider's counters are located in the Performance Monitor under a category name, for example, SequeLink .NET Data Provider.

> Table 10-10 describes the counters that you can use to tune connections for your application.

> Table 10-10. PerfMon Counters
> Counter | Description
> --- | ---
> Current # of Connection Pools | Returns the current number of pools associated with the process.
> Current # of Pooled Connections | Returns the current number of connections in all pools associated with the process.
> Current # of Pooled and Non-Pooled Connections | Returns the current number of pooled and non-pooled connections.
> Peak # of Pooled Connections | Returns the highest number of connections in all connection pools since the process started.
> Total # of Failed Connects | Returns the total number of attempts to open a connection that failed for any reason since the process started.
> Total # of Failed Commands | Returns the total number of command executions that failed for any reason since the process started.

> For information on using PerfMon and performance counters, refer to the Microsoft documentation library.