<commit_before>/*
 * Copyright 2008-2012 Zuse Institute Berlin (ZIB)
 * 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 de.zib.gndms.GORFX.service.util;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

/**
 * @date: 30.03.12
 * @time: 07:48
 * @author: <NAME>
 * @email: <EMAIL>
 */
@Aspect
public class GORFXAspects {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Pointcut( "execution(* de.zib.gndms.GORFX.service.TaskServiceImpl.*(..))" )
    public void inTaskServiceImpl() {}

    @Pointcut( "execution(* de.zib.gndms.GORFX.service.TaskFlowServiceImpl.*(..))" )
    public void inTaskFlowServiceImpl() {}

    @Around( value = "inTaskServiceImpl() && args( taskId, .., String )" )
    public void logTaskId( ProceedingJoinPoint pjp, final String taskId ) throws Throwable {
        MDC.put( "TaskID", taskId );

        pjp.proceed();

        MDC.remove( "TaskID" );
    }

    @Around( value = "inTaskFlowServiceImpl() && args( type, taskFlowId, .., dn, wID )" )
    public void logTaskFlowId( ProceedingJoinPoint pjp,
                               final String type,
                               final String taskFlowId,
                               final String dn,
                               final String wID ) throws Throwable {
        MDC.put( "TaskFlowType", type ) ;
        MDC.put( "TaskFlowID", taskFlowId ) ;
        MDC.put( "WorkFlowID", wID ) ;

        pjp.proceed();

        MDC.remove( "TaskFlowType" );
        MDC.remove( "TaskFlowID" );
        MDC.remove( "WorkFlowID" );
    }
}<commit_msg>Also log service calls (+ new UUID per gorfx call)<commit_after>/*
 * Copyright 2008-2012 Zuse Institute Berlin (ZIB)
 * 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 de.zib.gndms.GORFX.service.util;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.util.UUID;

/**
 * @date: 30.03.12
 * @time: 07:48
 * @author: <NAME>
 * @email: <EMAIL>
 */
@Aspect
public class GORFXAspects {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Pointcut( "execution(* de.zib.gndms.GORFX.service.TaskServiceImpl.*(..))" )
    public void inTaskServiceImpl() {}

    @Pointcut( "execution(* de.zib.gndms.GORFX.service.TaskFlowServiceImpl.*(..))" )
    public void inTaskFlowServiceImpl() {}

    @Pointcut( "execution(* de.zib.gndms.GORFX.service.GORFXServiceImpl.*(..))" )
    public void inGORFXServiceImpl() {}

    @Around( value = "inTaskServiceImpl() && args( taskId, .., String )" )
    public void logTaskId( ProceedingJoinPoint pjp, final String taskId ) throws Throwable {
        MDC.put("TaskID", taskId);
        MDC.put( "ServiceCall", pjp.getSignature().toLongString() );

        pjp.proceed();

        MDC.remove( "TaskID" );
        MDC.remove( "ServiceCall" );
    }

    @Around( value = "inTaskFlowServiceImpl() && args( type, taskFlowId, .., dn, wID )" )
    public void logTaskFlowId( ProceedingJoinPoint pjp,
                               final String type,
                               final String taskFlowId,
                               final String dn,
                               final String wID ) throws Throwable {
        MDC.put( "TaskFlowType", type ) ;
        MDC.put( "TaskFlowID", taskFlowId ) ;
        MDC.put( "WorkFlowID", wID ) ;
        MDC.put( "ServiceCall", pjp.getSignature().toLongString() );

        pjp.proceed();

        MDC.remove( "TaskFlowType" );
        MDC.remove( "TaskFlowID" );
        MDC.remove( "WorkFlowID" );
        MDC.remove( "ServiceCall" );
    }

    @Around( value = "inGORFXServiceImpl()" )
    public void logGORFXWithNewUUID( ProceedingJoinPoint pjp ) throws Throwable {
        MDC.put( "ServiceCall", pjp.getSignature().toLongString() );
        MDC.put( "GORFXCall", UUID.randomUUID().toString() );

        pjp.proceed();

        MDC.remove( "ServiceCall" );
        MDC.remove( "GORFXCall" );
    }
}
{'fraction_non_alphanumeric': 0.12324668038152235, 'fraction_numerical': 0.009351037965214139, 'mean_word_length': 2.82, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6813984', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1656, 'n_words': 436}