Home > glowroot, Java > Glowroot and Axis

Glowroot and Axis

Unfortunately by default Glowroot does not support logging Axis’ service calls and their response time. You have to write a plugin for this, which is actually very easy once you grasp how the plugins work.


package org.glowroot.agent.plugin.axis.v.one;

import javax.xml.namespace.QName;

import org.glowroot.agent.plugin.api.Agent;
import org.glowroot.agent.plugin.api.MessageSupplier;
import org.glowroot.agent.plugin.api.ThreadContext;
import org.glowroot.agent.plugin.api.ThreadContext.Priority;
import org.glowroot.agent.plugin.api.Timer;
import org.glowroot.agent.plugin.api.TimerName;
import org.glowroot.agent.plugin.api.TraceEntry;
import org.glowroot.agent.plugin.api.checker.Nullable;
import org.glowroot.agent.plugin.api.weaving.BindReceiver;
import org.glowroot.agent.plugin.api.weaving.BindThrowable;
import org.glowroot.agent.plugin.api.weaving.BindTraveler;
import org.glowroot.agent.plugin.api.weaving.OnBefore;
import org.glowroot.agent.plugin.api.weaving.OnReturn;
import org.glowroot.agent.plugin.api.weaving.OnThrow;
import org.glowroot.agent.plugin.api.weaving.Pointcut;
import org.glowroot.agent.plugin.api.weaving.Shim;

public class AxisAspect {

  public interface Call {
    String getTargetEndpointAddress();
    QName getOperationName();

  private static class TraceEntryOrTimer {

    private final @Nullable TraceEntry traceEntry;
    private final @Nullable Timer timer;

    private TraceEntryOrTimer(final TraceEntry traceEntry) {
      this.traceEntry = traceEntry;
      timer = null;

    private TraceEntryOrTimer(final Timer timer) {
      this.timer = timer;
      traceEntry = null;

    private void onReturn() {
      if (traceEntry != null) {
      } else if (timer != null) {

    private void onThrow(final Throwable t) {
      if (traceEntry != null) {
      } else if (timer != null) {

  @Pointcut(className = "org.apache.axis.client.Call", methodName = "invoke", methodParameterTypes = {}, timerName = "axis service")
  public static class ResourceAdvice {

    private static final TimerName timerName = Agent.getTimerName(ResourceAdvice.class);

    public static @Nullable TraceEntryOrTimer onBefore(final ThreadContext context, @BindReceiver final Call call) {
      String transactionName = call.getTargetEndpointAddress() + "#" + call.getOperationName().getLocalPart();
      context.setTransactionName(transactionName, Priority.CORE_PLUGIN);
      TraceEntry traceEntry = context.startServiceCallEntry("HTTP", transactionName, MessageSupplier.create("axis service: {}.{}()",
      call.getTargetEndpointAddress(), call.getOperationName().getLocalPart()), timerName);
      return new TraceEntryOrTimer(traceEntry);

    public static void onReturn(@BindTraveler @Nullable final TraceEntryOrTimer entryOrTimer) {

    public static void onThrow(@BindThrowable final Throwable t, @BindTraveler @Nullable final TraceEntryOrTimer entryOrTimer) {



and the corresponding glowroot.plugin.json

“name” : “Axis 1.4 Plugin”,
“id” : “axis”,
“aspects” : [“org.glowroot.agent.plugin.axis.v.one.AxisAspect”]

Categories: glowroot, Java Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: