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: probe_query_receive and probe query__respond. The first probe has two arguments, both of type string, and the second probe has no arguments. For more information about the probes in this example, see Choosing the Probe Points. 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. For more information about the DTrace stability attributes, see DTrace Stability Mechanisms. Stability attributes are defined as shown in the following example:

Example 13-1 Using Statically Defined Application Probes With myserv.d

#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();
};