Oracle® Solaris 11.2 Dynamic Tracing Guide

Exit Print View

Updated: July 2014
 
 

Defining Providers and Probes

You define DTrace probes in a .d source file which is then used when compiling and linking your application. First, select an appropriate name for your user application provider. The provider name you choose will be appended with the process identifier for each process that is executing your application code. For example, if you chose the provider name myserv for a web server that was executing as process ID 1203, the DTrace provider name corresponding to this process would be myserv1203. In your .d source file, add a provider definition similar to the following example:

provider myserv {
        ...
};

Next, add a definition for each probe and the corresponding arguments. The following example defines the two probes discussed in Choosing the Probe Points. The first probe has two arguments, both of type string, and the second probe has no arguments. The D compiler converts two consecutive underscores (--) in any probe name to a hyphen (-).

provider myserv {
        probe query__receive(string, string);
        probe query__respond();
};

You should add stability attributes to your provider definition so that consumers of your probes understand the likelihood of change in future versions of your application. See Chapter 18, Stability for more information on the DTrace stability attributes. Stability attributes are defined as shown in the following example:

Example 13-1  myserv.d: Statically Defined Application Probes
#pragma D attributes Evolving/Evolving/Common provider myserv provider
#pragma D attributes Private/Private/Unknown provider myserv module
#pragma D attributes Private/Private/Unknown provider myserv function
#pragma D attributes Evolving/Evolving/Common provider myserv name
#pragma D attributes Evolving/Evolving/Common provider myserv args

provider myserv {
        probe query__receive(string, string);
        probe query__respond();
};