diennea / carapaceproxy

A Distributed Java Reverse Proxy
Apache License 2.0
23 stars 9 forks source link

Improve debugging experience #448

Open NiccoMlt opened 6 months ago

NiccoMlt commented 6 months ago

We should add io.projectreactor:reactor-tools to improve debugging experience on modern IDEs like Intellij IDEA.

Project Reactor comes with a separate Java Agent that instruments the code and adds debugging info without paying a cost for capturing the stacktrace on every operator call like it happens with tracebacks in Debug mode and thus without the runtime performance overhead; see https://projectreactor.io/docs/core/release/reference/#reactor-tools-debug.

This could be very useful in some situations.

From documentation, there seem to be three possible ways to attach the instrumentation code.

Attaching it directly

Running ReactorDebugAgent as a Java Agent

We could add -javaagent reactor-tools.jar to the VM options, by adding it to the JAVA_OPTS environment variable in setenv.sh file.

Running ReactorDebugAgent at build time

We could add it with the Byte Buddy Maven Plugin:

<dependencies>
  <dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-tools</artifactId>
    <classifier>original</classifier> 
    <scope>runtime</scope>
  </dependency>
</dependencies>

<build>
  <plugins>
    <plugin>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy-maven-plugin</artifactId>
      <configuration>
        <transformations>
          <transformation>
            <plugin>reactor.tools.agent.ReactorDebugByteBuddyPlugin</plugin>
          </transformation>
        </transformations>
      </configuration>
    </plugin>
  </plugins>
</build>