Skip to content

Commit 9f7f325

Browse files
committed
[DOC] Update readme based on the new features
1 parent 3662ba6 commit 9f7f325

File tree

1 file changed

+52
-54
lines changed

1 file changed

+52
-54
lines changed

Diff for: readme.md

+52-54
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ java [OPTIONS] -jar <program commands>
4141
java [OPTIONS] -javaagent:path/to/the/jib.jar=<config=configuration.yaml> -jar <program commands>
4242
```
4343

44-
Thank you for providing the YAML example. I'll complete the "Agent Configuration" section based on the information you've given. Here's a draft of the content:
45-
4644
### Agent Configuration
4745

4846
The agent configuration is specified in a YAML file. This file allows you to customize various aspects of the agent's behavior. Below are the available configuration options:
@@ -52,28 +50,33 @@ The agent configuration is specified in a YAML file. This file allows you to cus
5250
The `logging` section controls how the agent generates log files:
5351

5452
- `file`: Specifies the path to the log file where the agent will write its output.
55-
- Example: `path/to/file.log`
53+
- Default: `app.log`
5654

5755
- `addTimestampToFileNames`: When set to `true`, adds a timestamp to the log file name.
5856
- Default: `false`
5957

6058
- `useHash`: If `true`, the agent uses hashing for method signatures in the log file. This is useful for reducing the size of the log file when there are a large number of method logs with long signatures. The mapping of the hashes will be stored in a separate JSON file.
6159
- Default: `false`
6260

61+
- `optimizeTimestamp`: When set to `true`, optimizes timestamp handling for improved performance. Basically, it removes the first 4 digits of the timestamp to reduce the log file size.
62+
- Default: `false`
63+
6364
#### Instrumentation
6465

6566
The `instrumentation` section defines which parts of your code the agent will instrument:
6667

67-
- `targetPackage`: Specifies which package to instrument. If not set, all classes will be instrumented (both within and outside of the program).
68-
- Example: `com.example`
69-
- Default: empty (all classes are instrumented)
68+
- `targetPackage`: Specifies which package to instrument.
69+
- Default: `*` (all packages)
7070

7171
- `onlyCheckVisited`: When set to `true`, the agent only instruments the entry of each function once. This is useful for checking code coverage.
7272
- Default: `false`
7373

7474
- `instrumentMainMethod`: If `true`, the agent will instrument the main method of the main class.
7575
- Default: `false`
7676

77+
- `maxNumberOfInstrumentations`: Sets a limit on the number of instrumentations to perform. Use -1 for unlimited.
78+
- Default: `-1`
79+
7780
- `targetMethods`: Allows you to specify which methods to instrument or ignore. This section has two sub-sections:
7881
- `instrument`: A list of methods to instrument. If specified, only these methods will be instrumented.
7982
- Example:
@@ -88,64 +91,67 @@ The `instrumentation` section defines which parts of your code the agent will in
8891
- protected java.lang.String com.example.MainClass.ignoredMethodName(float a)
8992
```
9093

91-
##### Method Structure
94+
#### Misc
9295

93-
When specifying methods in the `instrument` or `ignore` lists, use the following format:
96+
The `misc` section contains additional configuration options:
9497

95-
```
96-
[visibility] [static] return-type [declaring-class.]method-name(args)
97-
```
98+
- `convertToJson`: When set to `true`, converts the output logs to JSON format. This format is supported by visualization tools like Eclipse Trace Compass.
99+
- Default: `false`
98100

99-
Where:
100-
- `[visibility]` is one of (required):
101-
- `public`
102-
- `protected`
103-
- `private`
104-
- (empty for package-protected)
105-
- `[static]` is one of (required):
106-
- `static`
107-
- (empty for non-static)
108-
- `return-type` is the method's return type
109-
- it should be the fully qualified class name (e.g., `java.lang.String` or `void`) (required)
110-
- `[declaring-class]` is the fully qualified class name where the method is declared (optional)
111-
- `method-name` is the name of the method (required)
112-
- `(args)` are the method's parameters (required)
113-
114-
Examples:
115-
```java
116-
private static void com.example.MainClass.methodName(int a, java.lang.String b)
117-
protected java.lang.String ignoredMethodName(float a)
118-
public java.util.List<java.lang.String> getNames()
119-
void processData(byte[] data)
120-
```
121-
Note: You can specify either `instrument` or `ignore`, but not both since it doesn't make sense to instrument and ignore methods at the same time.
101+
##### Method Structure
102+
103+
When specifying methods in the `instrument` or `ignore` lists, use the following format:
104+
105+
```
106+
[visibility] [static] return-type [declaring-class.]method-name(args)
107+
```
108+
109+
Where:
110+
- `[visibility]` is one of (required):
111+
- `public`
112+
- `protected`
113+
- `private`
114+
- (empty for package-protected)
115+
- `[static]` is one of (required):
116+
- `static`
117+
- (empty for non-static)
118+
- `return-type` is the method's return type
119+
- it should be the fully qualified class name (e.g., `java.lang.String` or `void`) (required)
120+
- `[declaring-class]` is the fully qualified class name where the method is declared (optional)
121+
- `method-name` is the name of the method (required)
122+
- `(args)` are the method's parameters (required)
123+
124+
Examples:
125+
```java
126+
private static void com.example.MainClass.methodName(int a, java.lang.String b)
127+
protected java.lang.String ignoredMethodName(float a)
128+
public java.util.List<java.lang.String> getNames()
129+
void processData(byte[] data)
130+
```
131+
Note: You can specify either `instrument` or `ignore`, but not both since it doesn't make sense to instrument and ignore methods at the same time.
122132

123133
Here's an example of a complete configuration file:
124134

125135
```yaml
126136
logging:
127137
file: app.log
128-
addTimestampToFileNames: false
129-
useHash: false
138+
addTimestampToFileNames: true
139+
useHash: true
140+
optimizeTimestamp: true
130141
131142
instrumentation:
132143
targetPackage: com.example
133144
onlyCheckVisited: false
134145
instrumentMainMethod: true
146+
maxNumberOfInstrumentations: 1000
135147
targetMethods:
136148
instrument:
137149
- private static void com.example.MainClass.methodName(int a, java.lang.String b)
138-
```
139-
140-
To use this configuration, save it to a file (e.g., `configuration.yaml`) and specify it when attaching the agent to your Java application:
141150
142-
```console
143-
java [OPTIONS] -javaagent:path/to/the/jib.jar=config=configuration.yaml -jar <program commands>
151+
misc:
152+
convertToJson: true
144153
```
145154

146-
This configuration allows you to fine-tune the agent's behavior to suit your specific needs, whether you're focusing on particular packages, methods, or adjusting logging options.
147-
148-
149155
## Example
150156

151157
Let's consider a simple Java program with the following structure:
@@ -307,17 +313,9 @@ There are several ways to analyze the logs generated by the agent. One common ap
307313
### Analysis with Trace Compass
308314
*Background: [Eclipse Trace Compass™](https://eclipse.dev/tracecompass) is an open source application to solve performance and reliability issues by reading and analyzing logs or traces of a system. Its goal is to provide views, graphs, metrics, and more to help extract useful information from traces, in a way that is more user-friendly and informative than huge text dumps.*
309315

310-
If you want to import the collected instrumentation logs in Trace Compass, you can use the `trace_formatter.py` script to re-format the log files, and generate a Trace Compass readable json file.
316+
If you want to import the collected instrumentation logs in Trace Compass, you can use the `convertToJson` option in the configuration file to convert the output logs to JSON format.
311317

312-
**Structure:**
313-
```console
314-
python trace_formatter.py [-h] [--batch_size BATCH_SIZE] input output
315-
```
316-
**Example:**
317-
```console
318-
python trace_formatter.py app.log app.json
319-
```
320-
**Output:**
318+
**JSON Output Example:**
321319
```json
322320
[
323321
{

0 commit comments

Comments
 (0)