Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The jar is generated in `build/libs/`.
Attach the agent using the `-javaagent` option and provide arguments as comma-separated `key=value` pairs:

```sh
java -javaagent:path/to/flow-agent.jar=target=<prefix[+prefix...]>,out=<dir>[,format=binary|jsonl][,optimize=<dir>][,ids=<file>] \
java -javaagent:path/to/flow-agent.jar=target=<prefix[+prefix...]>,out=<dir>[,format=binary|jsonl][,optimize=<dir>][,ids=<file>][,debug=true] \
-jar your-application.jar
```

Expand All @@ -60,6 +60,9 @@ java -javaagent:path/to/flow-agent.jar=target=<prefix[+prefix...]>,out=<dir>[,fo
* **`ids`** (optional)
Path to an existing ID mapping file to reuse.

* **`debug`** (optional)
it enables debug mode, which adds debugging information to the agent logs.

### Examples

Record calls using the default (binary) format:
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/fr/bl/drit/flow/agent/AgentMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private static void init(String agentArgs, Instrumentation inst) {
final String outputPath = args.get("out");
final String format = args.getOrDefault("format", "binary");
final String optimizePath = args.get("optimize");
final boolean debug = args.getOrDefault("debug", "false").equalsIgnoreCase("true");
String mappingPath = args.get("ids"); // can be overwritten if optimize is used

if (target.isEmpty()) {
Expand Down Expand Up @@ -209,9 +210,11 @@ private static void init(String agentArgs, Instrumentation inst) {
(builder, typeDescription, classLoader, module, protectionDomain) ->
builder.visit(advice.on(methodMatcher)));

// agentBuilder =
// agentBuilder.with(AgentBuilder.Listener.StreamWriting.toSystemOut());

// add a listener to print instrumentation events if debug is enabled
if (debug) {
agentBuilder = agentBuilder.with(AgentBuilder.Listener.StreamWriting.toSystemOut());
}

agentBuilder.installOn(inst);
}

Expand Down