How to Generate a Denylist From an AMF File

  • Updated

Problem

In some situations, it may be beneficial to not analyze certain classes at agent startup. This can help address some performance issues or if the class belongs to another profiler or agent that may interfere with startup. 

How To Create a Denylist

A denylist is a text file that lists one full class name per line:

org.glowroot.agent.api.Glowroot
org.glowroot.agent.api.Instrumentation
org.glowroot.agent.api.Instrumentation.AlreadyInTransactionBehavior
org.glowroot.agent.api.Instrumentation.Timer
org.glowroot.agent.api.Instrumentation.TraceEntry
org.glowroot.agent.api.Instrumentation.Transaction

One way to generate a denylist from an existing agent DEBUG log is to create an Action Message Format (.amf) file by analyzing the log with 
java -jar contrast.jar analyze-log /path/to/contrast-debug.log amf

The resulting file, javaaagent-XXXXX.amf, can be unzipped with unzip -d t javaagent-XXXXX.amf.

The target folder should contain the file ./t/timeline.json, which can be used to extract classes that were analyzed but can be ignored. The following shows a JQ query to get the required data:

jq -r '.data[] 
| select(.category=="ClassLoad")
| {class: .subcategory, result: .supportingData.result[0]}
| select(.result=="ANALYZED_IGNORED")
| .class' t/timeline.json
| sort
| uniq

Alternatively, there is an online version of JQ that does not require installation:

1.pngThe result can be saved to a plain text file.

How to Add a Denylist to the Agent Configuration

Once a Denylist has been created, it can be added to the agent configuration, such as the contrast_security.yaml via

agent:
blacklist: /path/to/denlylist.txt

Note:  You can get more info on this setting by running

           java -jar contrast.jar properties | grep -B 2 -A 10 denylisty.yaml. 

This does require an agent restart.

Alternate Option

Another option to add a denylist is to use the agent.java.package_denylist setting:

agent:
java:
package_denylist: /path/to/denlylist.txt

The package_denylist can be used to ignore an entire packages instead of individual classes by providing a denylist file that lists one package name per line: 

org/glowroot/agent/api

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request