@Override public TraceMetadata create(final IValueDeserializer deserializer) { return new TraceMetadata(deserializer); }
/** * {@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; }
@Override protected long getRecordSpecificTimestamp(final TraceMetadata record) { return record.getLoggingTimestamp(); }
public void handleMetadataRecord(final TraceMetadata metadata) { final String hostname = metadata.getHostname(); final long traceId = metadata.getTraceId(); this.hostnameRepository.addEntry(traceId, hostname); }
/** * {@inheritDoc} */ @Override public void registerStrings(final IRegistry<String> stringRegistry) { // NOPMD (generated code) stringRegistry.get(this.getSessionId()); stringRegistry.get(this.getHostname()); } /**
@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))); } }
/** * Tests the constructor and writeBytes(..) methods of {@link TraceMetadata}. */ @Test public void testSerializeDeserializeBinaryEquals() { final TraceMetadata trace1 = new TraceMetadata(TRACE_ID, THREAD_ID, SESSION_ID, HOSTNAME, PARENT_TRACE_ID, PARENT_ORDER_ID); Assert.assertEquals("Unexpected trace ID", TRACE_ID, trace1.getTraceId()); Assert.assertEquals("Unexpected thread ID", THREAD_ID, trace1.getThreadId()); Assert.assertEquals("Unexpected session ID", SESSION_ID, trace1.getSessionId()); Assert.assertEquals("Unexpected hostname", HOSTNAME, trace1.getHostname()); Assert.assertEquals("Unexpected parent trace ID", PARENT_TRACE_ID, trace1.getParentTraceId()); Assert.assertEquals("Unexpected parent order ID", PARENT_ORDER_ID, trace1.getParentOrderId()); final WriterListener receiver = new WriterListener(); final IWriterRegistry<String> stringRegistry = new WriterRegistry(receiver); final ByteBuffer buffer = ByteBuffer.allocate(trace1.getSize()); trace1.serialize(BinaryValueSerializer.create(buffer, stringRegistry)); buffer.flip(); final TraceMetadata trace2 = new TraceMetadata(BinaryValueDeserializer.create(buffer, receiver.getReaderRegistry())); Assert.assertEquals(trace1, trace2); Assert.assertEquals(0, trace1.compareTo(trace2)); } }
((CallOperationEvent) currentEvent).getCalleeOperationSignature(), ((CallOperationEvent) currentEvent).getCalleeClassSignature(), this.trace.getTraceId(), this.trace.getSessionId(), this.trace.getHostname(), executionInformation.getEoi(), executionInformation.getEss(),
@Override protected long getRecordsTraceId(final TraceMetadata record) { return record.getTraceId(); }
final int parentOrderId; if (tp != null) { // we have a known split point if ((enclosingTrace != null) && (enclosingTrace.getTraceId() != tp.traceId)) { LOG.error("Enclosing trace does not match split point. Found: " + enclosingTrace.getTraceId() + " expected: " + tp.traceId); parentTraceId = enclosingTrace.getTraceId(); parentOrderId = -1; // we could instead get the last orderId ... But this would make it harder to distinguish from known split points } else { // we create a new trace without a parent final TraceMetadata trace = new TraceMetadata(traceId, thread.getId(), sessionId, this.hostname, parentTraceId, parentOrderId); this.traceStorage.set(trace); return trace;
return; final long traceId = trace.getTraceId(); final ExecutionTrace executionTrace = new ExecutionTrace(traceId, trace.getSessionId()); final TraceEventRecordHandler traceEventRecordHandler = new TraceEventRecordHandler(trace, executionTrace, this.getSystemEntityFactory(), this.enhanceJavaConstructors, this.enhanceCallDetection, this.ignoreAssumedCalls);
private MonitoredTrace getOrCreateMonitoredThread(final long beforeEventLoggingTimestamp, final long threadId) { final MonitoredTrace monitoredTrace; if (!this.monitoredTraces.containsKey(threadId)) { final int uniqueTraceId = this.currentTraceId++; // generates a unique trace id monitoredTrace = new MonitoredTrace(uniqueTraceId); monitoredTrace.currentStackSize = 0; this.monitoredTraces.put(threadId, monitoredTrace); // The synthesize logging timestamp for the trace meta data must smaller than the first before event. // Hence, we subtract 1 from the before event. final long synthesizedLoggingTimestamp = beforeEventLoggingTimestamp - 1; final String hostName = this.hostNames.get(threadId); final TraceMetadata traceMetadata = new TraceMetadata(monitoredTrace.identifier, threadId, "<NO SESSION>", hostName, -1, -1); traceMetadata.setLoggingTimestamp(synthesizedLoggingTimestamp); super.deliver(OUTPUT_PORT_NAME_DEFAULT, traceMetadata); } else { monitoredTrace = this.monitoredTraces.get(threadId); } monitoredTrace.currentStackSize++; return monitoredTrace; }
public void setTrace(final TraceMetadata trace) { final long myTraceId = trace.getTraceId(); synchronized (this) { if (this.traceId == -1) { this.traceId = myTraceId; } else if (this.traceId != myTraceId) { LOG.error("Invalid traceId! Expected: " + this.traceId + " but found: " + myTraceId + " in trace " + trace.toString()); this.damaged = true; } if (this.trace == null) { this.trace = trace; } else { LOG.error("Duplicate Trace entry for traceId " + myTraceId); this.damaged = true; } } }
final int cmpHostnames = t1.getTraceMetadata().getHostname().compareTo(t2.getTraceMetadata().getHostname()); if (cmpHostnames != 0) { return cmpHostnames;
@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())); } }
@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))); } } }
currentCallEvent.getCalleeOperationSignature(), currentCallEvent.getCalleeClassSignature(), this.trace.getTraceId(), this.trace.getSessionId(), this.trace.getHostname(), executionInformation.getEoi(), executionInformation.getEss(),
public void setTrace(final TraceMetadata trace) { final long myTraceId = trace.getTraceId(); synchronized (this) { if (this.traceId == -1) { this.traceId = myTraceId; } else if (this.traceId != myTraceId) { LOGGER.error("Invalid traceId! Expected: {} but found: {} in trace {}", this.traceId, myTraceId, trace.toString()); this.damaged = true; } if (this.trace == null) { this.trace = trace; } else { LOGGER.error("Duplicate Trace entry for traceId {}", myTraceId); this.damaged = true; } } }
return; final long traceId = trace.getTraceId(); final ExecutionTrace executionTrace = new ExecutionTrace(traceId, trace.getSessionId()); final TraceEventRecordHandler traceEventRecordHandler = new TraceEventRecordHandler(trace, executionTrace, this.getSystemEntityFactory(), this.enhanceJavaConstructors, this.enhanceCallDetection, this.ignoreAssumedCalls);
private MonitoredTrace getOrCreateMonitoredThread(final long beforeEventLoggingTimestamp, final long threadId) { final MonitoredTrace monitoredTrace; if (!this.monitoredTraces.containsKey(threadId)) { final int uniqueTraceId = this.currentTraceId++; // generates a unique trace id monitoredTrace = new MonitoredTrace(uniqueTraceId); monitoredTrace.currentStackSize = 0; this.monitoredTraces.put(threadId, monitoredTrace); // The synthesize logging timestamp for the trace meta data must smaller than the first before event. // Hence, we subtract 1 from the before event. final long synthesizedLoggingTimestamp = beforeEventLoggingTimestamp - 1; final String hostName = this.hostNames.get(threadId); final TraceMetadata traceMetadata = new TraceMetadata(monitoredTrace.identifier, threadId, "<NO SESSION>", hostName, -1, -1); traceMetadata.setLoggingTimestamp(synthesizedLoggingTimestamp); super.deliver(OUTPUT_PORT_NAME_DEFAULT, traceMetadata); } else { monitoredTrace = this.monitoredTraces.get(threadId); } monitoredTrace.currentStackSize++; return monitoredTrace; }