List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:kieker.monitoring.probe.aspectj.flow.operationCallObject.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && !this(java.lang.Object) && target(targetObject) && notWithinKieker()") public Object static2memberOperation(final Object targetObject, final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }// w w w . j a v a 2 s . co m final String callee = this.signatureToLongString(thisJoinPoint.getSignature()); if (!CTRLINST.isProbeActivated(callee)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); // caller final Signature callerSig = thisEnclosingJoinPoint.getSignature(); final String caller = this.signatureToLongString(callerSig); final String callerClazz = callerSig.getDeclaringTypeName(); // callee final String calleeClazz = targetObject.getClass().getName(); final int calleeObject = System.identityHashCode(targetObject); // measure before call CTRLINST.newMonitoringRecord(new CallOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller, callerClazz, callee, calleeClazz, 0, calleeObject)); // call of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationCallObject.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && this(thisObject) && !target(java.lang.Object) && notWithinKieker()") public Object member2staticOperation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }/*from ww w . j a v a 2 s. c o m*/ final Signature calleeSig = thisJoinPoint.getSignature(); final String callee = this.signatureToLongString(calleeSig); if (!CTRLINST.isProbeActivated(callee)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); // caller final String caller = this.signatureToLongString(thisEnclosingJoinPoint.getSignature()); final String callerClazz = thisObject.getClass().getName(); final int callerObject = System.identityHashCode(thisObject); // callee final String calleeClazz = calleeSig.getDeclaringTypeName(); // measure before call CTRLINST.newMonitoringRecord(new CallOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller, callerClazz, callee, calleeClazz, callerObject, 0)); // call of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationCallObject.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && !this(java.lang.Object) && !target(java.lang.Object) && notWithinKieker()") public Object static2staticOperation(final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }//from w w w .j a va 2s . c om final Signature calleeSig = thisJoinPoint.getSignature(); final String callee = this.signatureToLongString(calleeSig); if (!CTRLINST.isProbeActivated(callee)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); // caller final Signature callerSig = thisEnclosingJoinPoint.getSignature(); final String caller = this.signatureToLongString(callerSig); final String callerClazz = callerSig.getDeclaringTypeName(); // callee final String calleeClazz = calleeSig.getDeclaringTypeName(); // measure before call CTRLINST.newMonitoringRecord(new CallOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller, callerClazz, callee, calleeClazz, 0, 0)); // call of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecution.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && this(thisObject) && notWithinKieker()") public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }/*w ww .j a v a2 s . c o m*/ final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = thisObject.getClass().getName(); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz)); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString())); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz)); return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecution.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && !this(java.lang.Object) && notWithinKieker()") public Object staticOperation(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }/* w w w . ja v a 2 s.c o m*/ final Signature sig = thisJoinPoint.getSignature(); final String operationSignature = this.signatureToLongString(sig); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = sig.getDeclaringTypeName(); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz)); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString())); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz)); return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecutionObject.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && this(thisObject) && notWithinKieker()") public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }/*from ww w. j av a 2 s .c om*/ final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = thisObject.getClass().getName(); final int objectId = System.identityHashCode(thisObject); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, objectId)); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString(), objectId)); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, objectId)); return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecutionObject.AbstractAspect.java
License:Apache License
/** * This advice is used around static operations. * * @param thisJoinPoint//from www. j a v a2 s. c o m * The joint point of the advice. * * @return The return value of the joint point's {@code proceed} method. * * @throws Throwable */ @Around("monitoredOperation() && !this(java.lang.Object) && notWithinKieker()") public Object staticOperation(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); } final Signature sig = thisJoinPoint.getSignature(); final String operationSignature = this.signatureToLongString(sig); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = sig.getDeclaringTypeName(); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, 0)); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString(), 0)); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, 0)); return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecutionObjectInterface.AbstractAspect.java
License:Apache License
@Around("monitoredOperation() && this(thisObject) && notWithinKieker()") public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); }// w ww .j a v a2s . com final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = thisObject.getClass().getName(); final int objectId = System.identityHashCode(thisObject); // measure before execution CTRLINST.newMonitoringRecord( new BeforeOperationObjectInterfaceEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, objectId, AbstractAspect.getInterface(thisJoinPoint))); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString(), objectId)); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, objectId)); return retval; }
From source file:kieker.monitoring.probe.aspectj.flow.operationExecutionObjectInterface.AbstractAspect.java
License:Apache License
/** * This advice is used around static operations. * * @param thisJoinPoint//from w w w. j a v a 2 s . c o m * The joint point of the advice. * * @return The return value of the joint point's {@code proceed} method. * * @throws Throwable */ @Around("monitoredOperation() && !this(java.lang.Object) && notWithinKieker()") public Object staticOperation(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); } final Signature sig = thisJoinPoint.getSignature(); final String operationSignature = this.signatureToLongString(sig); if (!CTRLINST.isProbeActivated(operationSignature)) { return thisJoinPoint.proceed(); } // common fields TraceMetadata trace = TRACEREGISTRY.getTrace(); final boolean newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } final long traceId = trace.getTraceId(); final String clazz = sig.getDeclaringTypeName(); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationObjectInterfaceEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, 0, AbstractAspect.getInterface(thisJoinPoint))); // execution of the called method final Object retval; try { retval = thisJoinPoint.proceed(); } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here) // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString(), 0)); throw th; } finally { if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, 0)); return retval; }
From source file:kieker.monitoring.probe.aspectj.jersey.OperationExecutionJerseyClientInterceptor.java
License:Apache License
/** * Method to intercept outgoing request and incoming response. * * @return value of the intercepted method *///from w w w. j a va 2 s.c o m @Around("execution(public com.sun.jersey.api.client.ClientResponse com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(com.sun.jersey.api.client.ClientRequest))") public Object operation(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable) if (!CTRLINST.isMonitoringEnabled()) { return thisJoinPoint.proceed(); } final String signature = this.signatureToLongString(thisJoinPoint.getSignature()); if (!CTRLINST.isProbeActivated(signature)) { return thisJoinPoint.proceed(); } boolean entrypoint = true; final String hostname = VMNAME; final String sessionId = SESSION_REGISTRY.recallThreadLocalSessionId(); final int eoi; // this is executionOrderIndex-th execution in this trace final int ess; // this is the height in the dynamic call tree of this execution final int nextESS; long traceId = CF_REGISTRY.recallThreadLocalTraceId(); // traceId, -1 if entry point if (traceId == -1) { entrypoint = true; traceId = CF_REGISTRY.getAndStoreUniqueThreadLocalTraceId(); CF_REGISTRY.storeThreadLocalEOI(0); CF_REGISTRY.storeThreadLocalESS(1); // next operation is ess + 1 eoi = 0; ess = 0; nextESS = 1; } else { entrypoint = false; eoi = CF_REGISTRY.incrementAndRecallThreadLocalEOI(); ess = CF_REGISTRY.recallAndIncrementThreadLocalESS(); nextESS = ess + 1; if ((eoi == -1) || (ess == -1)) { LOG.error("eoi and/or ess have invalid values:" + " eoi == " + eoi + " ess == " + ess); CTRLINST.terminateMonitoring(); } } // Get request header final Object[] args = thisJoinPoint.getArgs(); final ClientRequest request = (ClientRequest) args[0]; final URI uri = request.getURI(); // LOG.info("URI = " + uri.toString()); // This is a hack to put all values in the header MultivaluedMap<String, Object> requestHeader = request.getHeaders(); if (requestHeader == null) { requestHeader = new MultivaluedHashMap<String, Object>(); } final List<Object> requestHeaderList = new ArrayList<Object>(4); requestHeaderList.add(Long.toString(traceId) + "," + sessionId + "," + Integer.toString(eoi) + "," + Integer.toString(nextESS)); requestHeader.put(JerseyHeaderConstants.OPERATION_EXECUTION_JERSEY_HEADER, requestHeaderList); if (LOG.isDebugEnabled()) { LOG.debug("Sending request to " + uri.toString() + " with header = " + requestHeader.toString()); } // measure before final long tin = TIME.getTime(); // execution of the called method Object retval = null; try { retval = thisJoinPoint.proceed(args); } finally { // measure after final long tout = TIME.getTime(); // Process response if (retval instanceof ClientResponse) { final ClientResponse response = (ClientResponse) retval; final MultivaluedMap<String, String> responseHeader = response.getHeaders(); if (responseHeader != null) { final List<String> responseHeaderList = responseHeader .get(JerseyHeaderConstants.OPERATION_EXECUTION_JERSEY_HEADER); if (responseHeaderList != null) { if (LOG.isDebugEnabled()) { LOG.debug("Received response from " + uri.toString() + " with header = " + responseHeader.toString()); } final String[] responseHeaderArray = responseHeaderList.get(0).split(","); // Extract trace id final String retTraceIdStr = responseHeaderArray[0]; Long retTraceId = -1L; if (!"null".equals(retTraceIdStr)) { try { retTraceId = Long.parseLong(retTraceIdStr); } catch (final NumberFormatException exc) { LOG.warn("Invalid tradeId"); } } if (traceId != retTraceId) { LOG.error("TraceId in response header (" + retTraceId + ") is different from that in request header (" + traceId + ")"); } // Extract session id String retSessionId = responseHeaderArray[1]; if ("null".equals(retSessionId)) { retSessionId = OperationExecutionRecord.NO_SESSION_ID; } // Extract eoi int retEOI = -1; final String retEOIStr = responseHeaderArray[2]; if (!"null".equals(retEOIStr)) { try { retEOI = Integer.parseInt(retEOIStr); CF_REGISTRY.storeThreadLocalEOI(retEOI); } catch (final NumberFormatException exc) { LOG.warn("Invalid eoi", exc); } } } else { if (LOG.isDebugEnabled()) { LOG.debug("No monitoring data found in the response header from " + uri.toString() + ". Is it instrumented?"); } } } else { if (LOG.isDebugEnabled()) { LOG.debug("Response header from " + uri.toString() + " is null. Is it instrumented?"); } } } CTRLINST.newMonitoringRecord( new OperationExecutionRecord(signature, sessionId, traceId, tin, tout, hostname, eoi, ess)); // cleanup if (entrypoint) { CF_REGISTRY.unsetThreadLocalTraceId(); CF_REGISTRY.unsetThreadLocalEOI(); CF_REGISTRY.unsetThreadLocalESS(); SESSION_REGISTRY.unsetThreadLocalSessionId(); } else { CF_REGISTRY.storeThreadLocalESS(ess); // next operation is ess } } return retval; }