You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -143,7 +143,7 @@ Rather than regular *javac* the BTrace compiler is used - causing the script to
143
143
This is the main purpose of BTrace - inject a custom code to custom locations to give the insights about the internal state and dynamics of the application.
144
144
145
145
1. Getting just the information that any method is being executed
146
-
```
146
+
```java
147
147
packagehelloworld;
148
148
import...;
149
149
@@ -157,7 +157,7 @@ public class HelloWorldTrace {
157
157
```
158
158
159
159
2. Get the method names
160
-
```
160
+
```java
161
161
packagehelloworld;
162
162
import...;
163
163
@@ -171,7 +171,7 @@ public class HelloWorldTrace {
171
171
```
172
172
173
173
3. Intercept only a particular method
174
-
```
174
+
```java
175
175
packagehelloworld;
176
176
import...;
177
177
@@ -185,7 +185,7 @@ public class HelloWorldTrace {
185
185
```
186
186
187
187
4. Intercept only a particular method with name matching the handler name
188
-
```
188
+
```java
189
189
packagehelloworld;
190
190
import...;
191
191
@@ -201,7 +201,7 @@ public class HelloWorldTrace {
201
201
5. Intercept methods with names matching certain patterns
202
202
__Note:__ you can use pattern matching for the class names, too
203
203
204
-
```
204
+
```java
205
205
packagehelloworld;
206
206
import...;
207
207
@@ -216,7 +216,7 @@ public class HelloWorldTrace {
216
216
217
217
6. Intercept methods with names matching certain patterns and inspect their parameters
218
218
219
-
```
219
+
```java
220
220
packagehelloworld;
221
221
import...;
222
222
@@ -232,7 +232,7 @@ public class HelloWorldTrace {
232
232
```
233
233
234
234
7. Intercept method with names matching certain patterns and discover their signatures
235
-
```
235
+
```java
236
236
packagehelloworld;
237
237
import...;
238
238
@@ -249,7 +249,7 @@ public class HelloWorldTrace {
249
249
250
250
__Note:__ 'extra.HelloWorldBase.callD()' doesn't show up - it is defined in the superclass of 'extra.HelloWorld' and therefore not intercepted.
251
251
252
-
```
252
+
```java
253
253
packagehelloworld;
254
254
import...;
255
255
@@ -266,7 +266,7 @@ public class HelloWorldTrace {
266
266
267
267
__Note:__ The order of the un-annotated parameters must correspond to the order of the traced method parameters. Annotated parameters may be placed anywhere.
268
268
269
-
```
269
+
```java
270
270
packagehelloworld;
271
271
import...;
272
272
@@ -286,7 +286,7 @@ Eg. having the VM method signature in form of (Ljava/lang/String;I)V will transl
286
286
287
287
__Note:__ We are using overloaded method here and specifying the signature helps BTrace determine which method should be instrumented
288
288
289
-
```
289
+
```java
290
290
packagehelloworld;
291
291
import...;
292
292
@@ -302,7 +302,7 @@ public class HelloWorldTrace {
302
302
11. Intercept method with a particular name and capture its return value
303
303
`location=@Location(Kind.RETURN)` sets up the instrumentation to be inserted just before the method exits
304
304
305
-
```
305
+
```java
306
306
packagehelloworld;
307
307
import...;
308
308
@@ -317,7 +317,7 @@ public class HelloWorldTrace {
317
317
318
318
12. Inspect the content of an instance variable in the method declaring class
319
319
320
-
```
320
+
```java
321
321
packagehelloworld;
322
322
import...;
323
323
@@ -333,7 +333,7 @@ public class HelloWorldTrace {
333
333
334
334
Or retrieve the `java.lang.Field` instance first and perform a check before trying to retrieve the field value.
335
335
336
-
```
336
+
```java
337
337
packagehelloworld;
338
338
importjava.lang.Class;
339
339
importjava.lang.reflect.Field;
@@ -357,7 +357,7 @@ public class HelloWorldTrace {
357
357
358
358
__Note:__ Need to use @Location(Kind.RETURN) to be able to capture the execution duration
359
359
360
-
```
360
+
```java
361
361
packagehelloworld;
362
362
import...;
363
363
@@ -377,7 +377,7 @@ __Note:__ 'class', 'method' etc. directly in the @OnMethod annotation will deter
377
377
__Note:__@ProbeMethodName and @ProbeClassName refer to the context method and class; @TargetMethodOrField refers to the traced method invocation
378
378
__Note:__ You can use the 'type' annotation parameter in @OnMethod annotation to restrict the context methods and in @Location to restrict the traced method invocations
379
379
380
-
```
380
+
```java
381
381
packagehelloworld;
382
382
import...;
383
383
@@ -399,7 +399,7 @@ public class HelloWorldTrace {
399
399
400
400
15. Measuring the duration of methods invoked from inside a particular method
401
401
402
-
```
402
+
```java
403
403
packagehelloworld;
404
404
import...;
405
405
@@ -424,7 +424,7 @@ public class HelloWorldTrace {
424
424
__Note:__ The captured parameters pertain to the invoked method rather than the context method
425
425
__Note:__ The @Self annotated parameter captures the context instance and @TargetInstance annotated parameter captures the instance the method is invoked on
426
426
427
-
```
427
+
```java
428
428
packagehelloworld;
429
429
import...;
430
430
@@ -457,7 +457,7 @@ Called when the traced application is about to exit. Allows to capture the exit
457
457
458
458
__Note:__ The signature of the handler method __MUST__ be 'void (int)'
459
459
460
-
```
460
+
```java
461
461
packagehelloworld;
462
462
import...;
463
463
@@ -476,7 +476,7 @@ Called whenever an exception is thrown from anywhere in the BTrace handlers.
476
476
477
477
__Note:__ The signature of the handler method __MUST__ be 'void (java.lang.Throwable)'
478
478
479
-
```
479
+
```java
480
480
packagehelloworld;
481
481
import...;
482
482
@@ -496,7 +496,7 @@ Allows to register a handler to be invoked periodically at defined intervals.
496
496
__Note:__ The annotation parameter takes the interval value in milliseconds
497
497
__Note:__ The signature of the handler method __MUST__ be 'void ()'
498
498
499
-
```
499
+
```java
500
500
packagehelloworld;
501
501
import...;
502
502
@@ -513,7 +513,7 @@ public class HelloWorldTrace {
513
513
514
514
Used to raise events from external clients (eg. the command line client). The annotation takes a String parameter which is the event name. When not provided the event is considered to be 'unnamed'.
515
515
516
-
```
516
+
```java
517
517
packagehelloworld;
518
518
import...;
519
519
@@ -527,7 +527,7 @@ public class HelloWorldTrace {
527
527
```
528
528
or
529
529
530
-
```
530
+
```java
531
531
packagehelloworld;
532
532
import...;
533
533
@@ -552,7 +552,7 @@ The sampling implementation in BTrace guarantees that at least one invocation of
552
552
553
553
__Note:__ Even though the 'callD' method is executed 100 times we will get only ~10 hits - as dictated by the 'mean' parameter.
554
554
555
-
```
555
+
```java
556
556
packagehelloworld;
557
557
import...;
558
558
@@ -573,7 +573,7 @@ __Note:__ In this case the 'mean' parameter actually specify the lowest number o
573
573
__Note:__ Because the adaptive sampling needs to collect timestamps in order to maintain the overhead target the lowest value for the 'mean' parameter is 180 (cca. 60ns for gettint start/stop timestamp pair multiplied by the safety margin of 3)
574
574
__Note:__ The 'callD' method is very short and the number of iteration is rather limited - we will most probably get only one hit here
0 commit comments