btrace equivalent of String replaceAll

60 Views Asked by At

I want to prefix each line of a stack trace with a string.

Is there a way to replace all patterns in a String with something else in btrace?

1

There are 1 best solutions below

0
On BEST ANSWER

This is indeed not supported in BTrace.

You have two possibilities - you can either turn on the unsafe mode with all of its consequences or you can extract your logic to an external service which can then be called to perform eg. string replacement.

Services are half-way between enjoying the BTrace sandbox making it nearly impossible to shoot your foot off with your scripts and going completely unsafe where you can happily take down the traced application or corrupt the data. You need to explicitly add the jars containing services when deploying a particular script and, what is really useful, you can thoroughly test them as standalone classes (this is not really possible to do with BTrace scripts only).