I’d like to introduce Byte Buddy to my company and I’ve prepared a demo for my colleagues. We use Spring a lot, so I thought the best example would be instrumentation of Spring Boot application. For the purpose of demonstration, I have added logs to RestController methods using Java Agent. The instrumented application is a Spring Boot’s Hello World example enhanced with one additional method for printing user agent information:

At first, I’ve written an agent that uses method delegation to interceptor class and then executes original method implementation:

Interceptor logs method execution and its parameters:


Jakub Hałun

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store