@Before("unlock() && args(lock) && notWithinKieker()") public final void monitorExit(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorExit if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorExitEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } } }
@Before("lock() && args(lock) && notWithinKieker()") public final void beforeMonitorEntry(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorRequest if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorRequestEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } }
@Before("lock() && args(lock) && notWithinKieker()") public final void beforeMonitorEntry(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorRequest if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorRequestEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } }
/** * After a request creation with a RestTemplate, we get the current traceId * and orderIndex and add them to the Http header of our message. Also, we * create a new BeforeSentEvent, which we pass to the MonitoringController. */ @AfterReturning(pointcut = "requestCreation()", returning = "request") public void doAfterRequestCreation(final ClientHttpRequest request) { final long traceId = TRACEREGISTRY.getTrace().getTraceId(); final int orderIndex = TRACEREGISTRY.getTrace().getNextOrderId(); final HttpHeaders headers = request.getHeaders(); headers.add(KIEKER_TRACE_ID_HEADER, Long.toString(traceId)); headers.add(KIEKER_ORDER_INDEX_HEADER, Integer.toString(orderIndex)); CTRLINST.newMonitoringRecord(new BeforeSentRemoteEvent(TIME.getTime(), traceId, orderIndex, TECHNOLOGY)); }
@Before("unlock() && args(lock) && notWithinKieker()") public final void monitorExit(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorExit if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorExitEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } } }
/** * {@inheritDoc} */ @Override public int hashCode() { int code = 0; code += ((int)this.getTraceId()); code += ((int)this.getThreadId()); code += this.getSessionId().hashCode(); code += this.getHostname().hashCode(); code += ((int)this.getParentTraceId()); code += ((int)this.getParentOrderId()); code += ((int)this.getNextOrderId()); return code; }
@After("lock() && args(lock) && notWithinKieker()") public final void afterMonitorEntry(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorEntry if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorEntryEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } }
/** * {@inheritDoc} */ @Override public boolean equals(final Object obj) { if (obj == null) return false; if (obj == this) return true; if (obj.getClass() != this.getClass()) return false; final TraceMetadata castedRecord = (TraceMetadata) obj; if (this.getLoggingTimestamp() != castedRecord.getLoggingTimestamp()) return false; if (this.getTraceId() != castedRecord.getTraceId()) return false; if (this.getThreadId() != castedRecord.getThreadId()) return false; if (!this.getSessionId().equals(castedRecord.getSessionId())) return false; if (!this.getHostname().equals(castedRecord.getHostname())) return false; if (this.getParentTraceId() != castedRecord.getParentTraceId()) return false; if (this.getParentOrderId() != castedRecord.getParentOrderId()) return false; if (this.getNextOrderId() != castedRecord.getNextOrderId()) return false; return true; }
@After("lock() && args(lock) && notWithinKieker()") public final void afterMonitorEntry(final Object lock) { if (!CTRLINST.isMonitoringEnabled()) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); if (trace != null) { // ignore monitorEntry if not inside of a trace! final long traceId = trace.getTraceId(); final int orderId = trace.getNextOrderId(); CTRLINST.newMonitoringRecord(new MonitorEntryEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock))); } }
@AfterThrowing(marker = BodyMarker.class, scope = "") public static void onMethodException(final MethodStaticContext msc, final DynamicContext dc) { if (!CTRLINST.isMonitoringEnabled() || !CTRLINST.isProbeActivated(signature)) { return; } if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(TIME.getTime(), traceId, trace.getNextOrderId(), signature, clazz, dc.getException().toString())); } }
@AfterThrowing(marker = BodyMarker.class, scope = "") public static void onMethodException(final MethodStaticContext msc, final DynamicContext dc) { if (!CTRLINST.isMonitoringEnabled() || !CTRLINST.isProbeActivated(signature)) { return; } if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } // measure after failed execution CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(TIME.getTime(), traceId, trace.getNextOrderId(), signature, clazz, dc.getException().toString())); } }
@AfterThrowing(pointcut = "monitoredOperation() && notWithinKieker()", throwing = "th") public void afterThrowing(final JoinPoint joinPoint, final Throwable th) { if (!AbstractAspect.CTRLINST.isMonitoringEnabled()) { return; } final String classSignature = this.getJoinPointClassName(joinPoint); if (!AbstractAspect.CTRLINST.isProbeActivated(classSignature)) { return; } final TraceMetadata trace = AbstractAspect.TRACEREGISTRY.getTrace(); AbstractAspect.CTRLINST.newMonitoringRecord(new DatabaseFailedEvent(AbstractAspect.TIME.getTime(), classSignature, trace.getTraceId(), trace.getNextOrderId(), th.toString())); }
@AfterReturning(marker = BodyMarker.class, scope = "") public static void onMethodExit(final MethodStaticContext msc) { if (!CTRLINST.isMonitoringEnabled() || !CTRLINST.isProbeActivated(signature)) { return; } if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), signature, clazz)); }
@AfterReturning(marker = BodyMarker.class, scope = "") public static void onMethodExit(final MethodStaticContext msc) { if (!CTRLINST.isMonitoringEnabled() || !CTRLINST.isProbeActivated(signature)) { return; } if (newTrace) { // close the trace TRACEREGISTRY.unregisterTrace(); } // measure after successful execution CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), signature, clazz)); }
@Before(marker = BodyMarker.class, scope = "") public static void onMethodEntry(final MethodStaticContext msc, final DynamicContext dc) { if (!CTRLINST.isMonitoringEnabled()) { return; } signature = msc.thisMethodFullName(); if (!CTRLINST.isProbeActivated(signature)) { return; } // common fields trace = TRACEREGISTRY.getTrace(); newTrace = trace == null; if (newTrace) { trace = TRACEREGISTRY.registerTrace(); CTRLINST.newMonitoringRecord(trace); } traceId = trace.getTraceId(); clazz = dc.getThis().getClass().toString(); // measure before execution CTRLINST.newMonitoringRecord(new BeforeOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), signature, clazz)); }
@AfterThrowing(pointcut = "monitoredOperation() && notWithinKieker()", throwing = "th") public void afterThrowing(final StaticPart jpStaticPart, final Throwable th) { if (!CTRLINST.isMonitoringEnabled()) { return; } final String operationSignature = this.signatureToLongString(jpStaticPart.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); final String typeName = jpStaticPart.getSignature().getDeclaringTypeName(); CTRLINST.newMonitoringRecord( new AfterOperationFailedEvent(TIME.getTime(), trace.getTraceId(), trace.getNextOrderId(), operationSignature, typeName, th.toString())); }
@AfterThrowing(pointcut = "monitoredOperation() && notWithinKieker()", throwing = "th") public void afterThrowing(final StaticPart jpStaticPart, final Throwable th) { if (!CTRLINST.isMonitoringEnabled()) { return; } final String operationSignature = this.signatureToLongString(jpStaticPart.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); final String typeName = jpStaticPart.getSignature().getDeclaringTypeName(); CTRLINST.newMonitoringRecord( new AfterOperationFailedEvent(TIME.getTime(), trace.getTraceId(), trace.getNextOrderId(), operationSignature, typeName, th.toString())); }
@AfterReturning(pointcut = "monitoredOperation() && notWithinKieker()", returning = "returningObject") public void afterReturningOperation(final JoinPoint joinPoint, final Object returningObject) { if (!AbstractAspect.CTRLINST.isMonitoringEnabled()) { return; } final String classSignature = this.getJoinPointClassName(joinPoint); if (!AbstractAspect.CTRLINST.isProbeActivated(classSignature)) { return; } final TraceMetadata trace = AbstractAspect.TRACEREGISTRY.getTrace(); final String operationReturnType = this.getJoinPointReturnType(classSignature); final String returnedValue = this.getReturnedValue(returningObject, operationReturnType); AbstractAspect.CTRLINST.newMonitoringRecord(new AfterDatabaseEvent(AbstractAspect.TIME.getTime(), classSignature, trace.getTraceId(), trace.getNextOrderId(), operationReturnType, returnedValue)); }
@AfterReturning("monitoredOperation() && notWithinKieker()") public void afterReturningOperation(final StaticPart jpStaticPart) { if (!CTRLINST.isMonitoringEnabled()) { return; } final String operationSignature = this.signatureToLongString(jpStaticPart.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); final String typeName = jpStaticPart.getSignature().getDeclaringTypeName(); CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), trace.getTraceId(), trace.getNextOrderId(), operationSignature, typeName)); }
@AfterReturning("monitoredOperation() && notWithinKieker()") public void afterReturningOperation(final StaticPart jpStaticPart) { if (!CTRLINST.isMonitoringEnabled()) { return; } final String operationSignature = this.signatureToLongString(jpStaticPart.getSignature()); if (!CTRLINST.isProbeActivated(operationSignature)) { return; } final TraceMetadata trace = TRACEREGISTRY.getTrace(); final String typeName = jpStaticPart.getSignature().getDeclaringTypeName(); CTRLINST.newMonitoringRecord(new AfterOperationEvent(TIME.getTime(), trace.getTraceId(), trace.getNextOrderId(), operationSignature, typeName)); }