Share via


The InstrumentationProvider Class

The configuration file for a DCS service can specify a set of Boolean flags in the <appSettings> section that control the way in which the DCS runtime generates trace formation and instrumentation events for an application. The following example shows the <appSettings> section of the configuration file for a DCS service.

<?xml version="1.0" encoding="utf=8"?>
<configuration>
    ...
    <appSettings>
        <add key "performanceCountersEnabled" value="false"/>
        <add key "eventLoggingEnabled" value="false"/>
        <add key "wmiEnabled" value="false"/>
        <add key "traceEnabled" value="false"/>
        <add key "debugEnabled" value="false"/>
    </appSettings>
    ...
</configuration>

When a DCS service runs, the DCS runtime queries these flags. The Microsoft.ConnectedIndustry.ProcessExecution.Common.Instrumentation.InstrumentationProvider class contains a set of static properties that reflect the values of each of the flags (the properties are read-only). You can examine the properties in the code for your services and then set them to provide custom trace information.

The table below summarizes the flags available in the <appSettings> section of a configuration file for a DCS service, and how these flags can be used by the DCS runtime and your services.

Flag

InstrumentationProvider Property

Behavior

performanceCountersEnabled

PerformanceCountersEnabled

Enables or disables the DCS performance counters. For more information, see Enabling the DCS Performance Counters.

eventLoggingEnabled

EventLoggingEnabled

Enables or disables DCS event logging. If enabled, events are recorded for the DCS service in the Windows Application event log. For more information, see Configuring Event Logging for a DCS Service.

wmiEnabled

WmiEnabled

Enables or disables Windows Management Instrumentation (WMI) events for the DCS service. For more information, see The DCS Instrumentation Facility.

traceEnabled

TracingEnabled

Enables or disables the trace flag. This flag does not enable or disable DCS tracing. You can use this flag to set the static TracingEnabled property of the InstrumentationProvider class. You can then query this property in the code for your service, and if it is enabled you can trace any additional information that your service implements. To generate output data for a trace listener configured by using the <system.diagnostics> section in the configuration file, use the static methods of the Microsoft.ConnectedIndustry.ServiceModel.Common.Tracer class. For more information about using the Tracer class, see Using a Custom Trace Source.

debugEnabled

DebuggingEnabled

Enables or disables the debug flag. This flag does not enable or disable debugging. You can use this flag to set the static DebuggingEnabled property of the InstrumentationProvider class. You can then query this property in the code for your service, and if it is enabled you can generate trace data for any additional debugging information that your service implements.

The following code sample shows how to query the DebuggingEnabled property of the InstrumentationProvider class. The Debug method of the InstrumentationProvider class writes the specified string to any configured trace listeners. For more information, see Configuring Tracing in DCS Services and Client Applications.

using Microsoft.ConnectedIndustry.ProcessExecution.Common.Instrumentation;
...
if (InstrumentationProvider.DebuggingEnabled)
{
    InstrumentationProvider.Debug("Debug message");
}

See Also