Monitoring Spring applications

There is a dedicated script spring.bsh distributed with zorka agent. It provides monitoring of various Spring components:

  • Spring Web MVC - renderers, resolvers and controllers (trace attributes, statistics);

  • Spring Webflow - actions (trace attributes, statistics);

  • Spring Security - authentication (trace attributes, auditing, statistics);

  • Spring Remoting - client requests (trace attributes, statistics);

  • Spring HTTP client - requests (trace attributes, statistics);

Basic agent configuration

In order to enable Spring support add spring.bsh script to the list of scripts loaded at startup, eg:

scripts = jvm.bsh, zabbix.bsh, apache/tomcat.bsh, spring.bsh

This will enable statistics collection, tracing (if tracer is enabled), auditing (if auditing is enabled). Tracing will collect basic arguments of instrumented methods (ones that are cheap to collect) but there are additional attributes (argument lists, attribute maps etc. - depending on method instrumented) that are deemed more expensive in collecting thus not enabled by default. These attributes can be enabled individually using spring.fetch.** options or all at once using single spring.fetch.all option. These attributes are useful for debugging but for production purposes its impact has to be evaluated (tested) as each set of them takes few few microseconds and depending on estimated traffic, there can be a lot of them (and potentiall lot of data to be stored in collector).

Tracing Spring Applications

Tracing for Spring components is enabled automatically when tracer is enabled. For most of instrumented method it just adds some additional attributes, for speciic methods (eg. remoting and HTTP clients) it defines new traces (in addition to collecting attributes). Spring configuration script also excludes certain Spring classes with ‘hot’ methods in order to reduce footprint.

Sample trace with Spring-specific attributes

Configuration options for Spring

The following spring-related properties in can be set (along with default values):

  • spring.trace = ${tracer} - enables or disables tracing and basic trace attributes for instrumented methods from Spring library;

  • spring.trace.time = ${tracer.min.trace.time} - minimum execution time for traced spring methods to be submitted as separate trace;

  • spring.stats = yes - enables or disables statistics collection for Spring;

  • spring.stats.mbean = zorka:type=ZorkaStats,name=Spring - mbean name for Spring statistics generated by zorka agent (NOT changing its default value is strongly recommended);

  • spring.fetch.all = no - enables fetching of additional attributes for instrumented Spring methods;

  • spring.fetch.view.render.attrs = ${spring.fetch.all} - enables fetching of view rendering dynamic attributes;

  • spring.fetch.view.static.attrs = ${spring.fetch.all} - enables fetching of view rendering static attributes;

  • spring.fetch.remoting.args = ${spring.fetch.all} - enables fetching spring remote calls arguments;

  • spring.fetch.remoting.attrs = ${spring.fetch.all} - enables fetching spring remote calls context attributes;

  • spring.fetch.webmvc.modelmap = ${spring.fetch.all} - enables fetching of web MVC model maps;

  • spring.fetch.webflow.request.scope = ${spring.fetch.all} - enables fetching of webflow request scope variables;

  • spring.fetch.webflow.flash.scope = ${spring.fetch.all} - enables fetching of webflow flash scope variables;

  • spring.fetch.webflow.view.scope = ${spring.fetch.all} - enables fetching of webflow view scope variables;

  • spring.fetch.webflow.flow.scope = ${spring.fetch.all} - enables fetching of webflow flow scope variables;