Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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>][,bebug=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)
Activate a listener that show instrumentation events and errors

### Examples

Record calls using the default (binary) format:
Expand Down
10 changes: 8 additions & 2 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,14 @@ 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());
// === debug section ===

// 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