How do I capture request attributes based on Java method arguments?

To create a request attribute based on a Java method argument:

Go to Settings > Server-side monitoring > Request attributes.

Click the Create new request attribute button.

Provide a unique Request attribute name. You can rename an attribute at any point in the future.

Click the Add new data source button.

Optionally, define the scope of the request attribute.

From the Request attribute source drop list, select Java method parameter(s).

Click the Select method sources button to open the Java class wizard. Here you can select the Java class of the method upon whose argument you want to set an attribute.

Select the process group that contains the classes or interfaces you’re interested in and click Continue.

Search for the Java class that includes the method you’re interested in. Begin typing the Java class name and click the Search button. The list may take a few seconds to populate.

Pick a class from the displayed list. If the list doesn’t contain the class you’re looking for, refine the search string.

request attributes Java

Finally, pick one or more methods that you want to capture parameters from and click Finish.

The methods you selected are listed in the method argument capture rule (see below). For each method, from the list box under Capture, select the argument or return value of the method you want to capture.

request attributes Java


  1. In addition to arguments and return values of any method, you can also capture the number of occurrences. While arguments and return values should be clear, occurrences can be a bit tricky. You should only use a single method rule when capturing occurrences. Dynatrace will count the number of calls of this method within a single request.
  2. You can capture non-primitive and non-string objects. This can, however, result in increased performance overhead. Some objects may inadvertently change their state based on the method called, so use this option with caution.

You can always extend the list or remove methods later. Once saved, either restart the processes that you want this rule to apply to or go to Settings > Server-side service monitoring > Custom service detection and ensure that the Enable real-time updates to Java services setting is enabled.

What's next?

Once your services begin calling the respective methods, you should see the request attribute appear on the service’s overview page, on the Request attributes tab.

request attributes Java

You can now use your request attribute to filter your data. In the PurePath example below, note the new request attribute in the header and within the respective service call’s summary section.

request attributes Java

Finally, notice that the code-level tree view also contains these methods. This view will be used later to display the argument values in case the method is called multiple times with different values.

request attributes Java

Optional post processing

In many cases, a captured value will contain what it is you’re looking for. However, you may not want an entire value, or even every value. In such cases, expand the Optionally restrict or process the captured parameter(s) further option to enable post processing through the included optional fields. This option becomes visible once you choose a value from the drop lists at the bottom, for example if you choose a value from the Request attribute source drop list.

Once you expand this option, you will be presented with 5 steps of post processing. Note that each step is optional, which means that it can be skipped. Also, steps are executed in the order presented and therefore each is applied onto the values rendered from the previous step.

post processing

The first step enables you to simply extract something from the resulting string. Extraction can be performed either before, after, or between values. The extraction happens in your application and is based on string searches. For example, if your value is <value>value1</value>, you can use the following to extract value1.

request attributes

If the combination can’t be found in the captured value, then nothing will be captured. If the extraction is successful then only the extracted value will be captured.

In step 2, you can provide a text separator to split the captured value.

In step 4, you can select the option of pruning whitespaces.

Step 4 enables further filtering through the options provided in the drop list. You can define the captured values to be further filtered by considering a value for example only if it begins with a specific character.

For complex use cases, you can apply at step 5 a regular expression to the captured values.