APM Java agent - Servlet 2.5 - JBoss 4.2.3 support with custom plugin

Hi,

I need to instrument a legacy software deployed in JBoss 4.2.3 GA, running on JDK 8 and using Servlet 2.5. It is not possible to upgrade the legacy software to use updated versions of Servlets, JBoss, etc.., but, anyway, we need to put it under APM monitoring.

I understand that Servlet older than 3.0 are not supported (Supported technologies | APM Java Agent Reference [1.x] | Elastic).
I found a warning in the method ServletVersionInstrumentation.logServletVersion(...).
In fatc, in the logs I found this warning:
Unsupported servlet version detected: 2.5, no Servlet transaction will be created. Servlet container info = JBossWeb/2.0.1.GA

I also found another warning about classes listed below:
"uses an unsupported class file version (pre Java 4)) and can't be instrumented. Consider updating to a newer version of that library."

org.apache.log4j.Category
org.apache.log4j.WriterAppender
org.hsqldb.jdbc.jdbcConnection
org.hsqldb.jdbc.jdbcStatement
org.hsqldb.jdbc.jdbcPreparedStatement
org.slf4j.Logger
org.slf4j.impl.Log4jLoggerAdapter
org.slf4j.spi.LocationAwareLogger
org.slf4j.helpers.NamedLoggerBase

I would like to write a custom plugin to support Servlets 2.5, starting from the existing apm-servlet-plugin. Any hint how to proceed? Is it even possible to instrument servlets 2.5 writing a custom plugin? In fact, I did not find any method that specifically excludes servlets 2.5.

Thanks

Hi @luiru72 , welcome to our forum !

One of the reasons that we don't support Servlet 2.x is that some of the methods that we rely on are only available in Servlet 3.x, for example capturing the response HTTP status code javax.servlet.http.HttpServletResponse#getStatus is only available in version 3.x.

As a result, without modifying the application, there are a few alternatives that you might be able to use here:

  • creating a custom plugin to capture transactions for your application: this article is a very good start
  • using OpenTelemetry Java agent that seems to have support for this, apm server is able to ingest OTLP intake.

If you can modify a bit the application, there is an easier option available that involves manually creating the transaction in a Servlet Filter through one of the agent Tracing APIs.

Regarding the classes that are using a bytecode version before Java 4 (which should be read as Java 1.4), it means the agent will not be able to instrument those classes and thus that some instrumentation will not be applied. For example from the class names we can guess that log correlation and tracing of JDBC requests might not work, but in practice it could also work fine if the JDBC connection pool is properly instrumented (here only the low-level hsqldb database driver seems impacted, not the JDBC connection pool.