J'utilise SFlow + Ganglions pour surveiller des paramètres de la JVM de Websphere Application Server (WAS). WAS est instrumenté en utilisant les aspects AspectJ. J'ai ajouté un aspect pour mesurer toutes les exécutions de méthode d'application. J'utilise Hsflowd en tant que collecteur de métriques JVM. Hsflowd utilise en interne le javaagent JMX-SflowAgent pour se connecter à la JVM afin de collecter des métriques à l'aide de MXBeans (RuntimeMXBean, GarbageCollectorMXBean, CompilationMXBean et ThreadMXBean).
Problème:
Quand je lance ÉTAIT sans crochet je peux tissage dans la programmation orientée aspect voir tous les paramètres (CPU, bureau, mémoire, processus, etc.) dans le Web de façon continue Ganglions. Mais quand aspectjweaver est ajouté aux arguments JVM et après le redémarrage du serveur, je peux voir les métriques pendant 10 minutes, mais après cela, il ne rapporte pas les métriques JVM dans Ganglia web.
Dans les journaux de tissage Aspectj, je peux voir qu'AspectJ tisse le code JMXsflowAgent. Même si elle est exclue via !call(* com.sflow.JMX.SFlowAgent(..))
.
Aspect:
package com.foo.main;
import java.io.*;
import java.lang.reflect.Method;
import java.security.Signature;
import java.util.*;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.osgi.service.application.ApplicationAdminPermission;
@Aspect
public class ResponseTimeAspect {
@Pointcut(
"execution(* com.foo.*(..)) && " +
"!within(com.foo.main.ResponseTimeAspect) && " +
"!within(ThreadLocal+) && " +
"!within(&& !within(*..*Aspect)) && " +
"!within(com.foo.main.AppInformationReader) && " +
"!within(@org.aspectj.lang.annotation.Aspect *) && " +
"!within(com.sflow.jmx.SFlowAgent) && " +
"!(call(* com.sflow.jmx.SFlowAgent(..)))"
)
public void loggingResponseTime() {}
private static ThreadLocal<String> uuidContainer = new ThreadLocal<String>() {
@Override
protected String initialValue(){
return UUID.randomUUID().toString();
}
};
AppInformationReader logWriter = AppInformationReader.getInstance();
@Around("loggingResponseTime()")
public Object tracing(ProceedingJoinPoint thisJoinPoint) throws Throwable {
Long startTime= System.currentTimeMillis();
Long startTotalMemory = Runtime.getRuntime().totalMemory();
Long startFreeMemory = Runtime.getRuntime().freeMemory();
Object ret = thisJoinPoint.proceed();
Long elapsedTime=System.currentTimeMillis() - startTime;
Long endTotalMemory = Runtime.getRuntime().totalMemory();
Long endFreeMemory = Runtime.getRuntime().freeMemory();
String methodSignature=thisJoinPoint.getSignature().toString();
String classname=methodSignature.split("\\.")[thisJoinPoint.getSignature().toString().split("\\.").length-1];
String methodName =thisJoinPoint.getSignature().getDeclaringType().getCanonicalName();
logWriter.writeLog(uuidContainer.get().toString(), startTime, System.currentTimeMillis(), elapsedTime, classname, methodName);
return ret;
}
}
Les paquets JMX sont sous com.sflow.jmx.SFlowAgent
.
Il est un peu difficile de dire quelque chose d'intelligent sur le code AspectJ ou Java que nous ne pouvons pas voir et sur les configurations que nous ne pouvons pas voir non plus. Peut-être que vous voulez envisager de fournir plus de détails que personne ici n'a un globe de cristal magique. – kriegaex
@ Kriegaex- configuration supplémentaire n'est pas nécessaire .. Je pense que JMX et AspectJ ne fonctionneront pas ensemble sur nos ordinateurs de bureau. –
Pourquoi pas eux? – kriegaex