<commit_before>/***************************************************************************
 * Copyright 2011 by
 *  + Christian-Albrechts-University of Kiel
 *    + Department of Computer Science
 *      + Software Engineering Group 
 *  and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ***************************************************************************/

package kieker.monitoring.probe.aspectJ.flow.operationCall;

import kieker.common.record.flow.CallOperationEvent;
import kieker.common.record.flow.Trace;
import kieker.monitoring.core.controller.IMonitoringController;
import kieker.monitoring.core.controller.MonitoringController;
import kieker.monitoring.core.registry.TraceRegistry;
import kieker.monitoring.probe.aspectJ.AbstractAspectJProbe;
import kieker.monitoring.timer.ITimeSource;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @author <NAME>
 */
@Aspect
public abstract class AbstractAspect extends AbstractAspectJProbe {
	private static final IMonitoringController CTRLINST = MonitoringController.getInstance();
	private static final ITimeSource TIME = AbstractAspect.CTRLINST.getTimeSource();
	private static final TraceRegistry TRACEREGISTRY = TraceRegistry.INSTANCE;

	@Pointcut
	public abstract void monitoredOperation();

	@Around("monitoredOperation() && notWithinKieker()")
	public Object operation(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
		// common fields
		Trace trace = AbstractAspect.TRACEREGISTRY.getTrace();
		final boolean newTrace = (trace == null);
		if (newTrace) {
			trace = AbstractAspect.TRACEREGISTRY.registerTrace();
			AbstractAspect.CTRLINST.newMonitoringRecord(trace);
		}
		final long traceId = trace.getTraceId();
		final String signature = thisJoinPoint.getSignature().toLongString();
		// measure before execution
		AbstractAspect.CTRLINST.newMonitoringRecord(new CallOperationEvent(AbstractAspect.TIME.getTime(), traceId, trace.getNextOrderId(), signature, signature));
		// execution of the called method
		final Object retval;
		try {
			retval = thisJoinPoint.proceed();
		} catch (final Throwable th) {
			throw th;
		} finally {
			if (newTrace) { // close the trace
				AbstractAspect.TRACEREGISTRY.unregisterTrace();
			}
		}
		return retval;
	}
}<commit_msg>Fixed caller detection in the probe for CallOperationEvent records<commit_after>/***************************************************************************
 * Copyright 2011 by
 *  + Christian-Albrechts-University of Kiel
 *    + Department of Computer Science
 *      + Software Engineering Group 
 *  and others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ***************************************************************************/

package kieker.monitoring.probe.aspectJ.flow.operationCall;

import kieker.common.record.flow.CallOperationEvent;
import kieker.common.record.flow.Trace;
import kieker.monitoring.core.controller.IMonitoringController;
import kieker.monitoring.core.controller.MonitoringController;
import kieker.monitoring.core.registry.TraceRegistry;
import kieker.monitoring.probe.aspectJ.AbstractAspectJProbe;
import kieker.monitoring.timer.ITimeSource;

import org.aspectj.lang.JoinPoint.EnclosingStaticPart;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @author <NAME>
 */
@Aspect
public abstract class AbstractAspect extends AbstractAspectJProbe {
	private static final IMonitoringController CTRLINST = MonitoringController.getInstance();
	private static final ITimeSource TIME = AbstractAspect.CTRLINST.getTimeSource();
	private static final TraceRegistry TRACEREGISTRY = TraceRegistry.INSTANCE;

	@Pointcut
	public abstract void monitoredOperation();

	@Around("monitoredOperation() && notWithinKieker()")
	public Object operation(final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable {
		// common fields
		Trace trace = AbstractAspect.TRACEREGISTRY.getTrace();
		final boolean newTrace = (trace == null);
		if (newTrace) {
			trace = AbstractAspect.TRACEREGISTRY.registerTrace();
			AbstractAspect.CTRLINST.newMonitoringRecord(trace);
		}
		final long traceId = trace.getTraceId();
		final String callee = thisJoinPoint.getSignature().toLongString();
		final String caller = thisEnclosingJoinPoint.getSignature().toLongString();
		// measure before call
		AbstractAspect.CTRLINST.newMonitoringRecord(new CallOperationEvent(AbstractAspect.TIME.getTime(), traceId, trace.getNextOrderId(), caller, callee));
		// call of the called method
		final Object retval;
		try {
			retval = thisJoinPoint.proceed();
		} catch (final Throwable th) {
			throw th;
		} finally {
			if (newTrace) { // close the trace
				AbstractAspect.TRACEREGISTRY.unregisterTrace();
			}
		}
		return retval;
	}
}
{'fraction_non_alphanumeric': 0.13406338145014104, 'fraction_numerical': 0.002654720424755268, 'mean_word_length': 5.272632674297607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4445609', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1621, 'n_words': 451}