/// <summary>
    /// OnAsyncMethodEnd callback
    /// </summary>
    /// <typeparam name="TTarget">Type of the target</typeparam>
    /// <typeparam name="TExecutionResult">Type of the execution result value</typeparam>
    /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
    /// <param name="executionResult">ExecutionResult instance</param>
    /// <param name="exception">Exception instance in case the original code threw an exception.</param>
    /// <param name="state">Calltarget state value</param>
    /// <returns>A response value, in an async scenario will be T of Task of T</returns>
    public static TExecutionResult OnAsyncMethodEnd <TTarget, TExecutionResult>(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state)
    {
        Activity activity = state.Activity;

        if (activity is null)
        {
            return(executionResult);
        }

        try
        {
            if (exception != null)
            {
                activity?.SetException(exception);
            }
            else if (state.State is IExecutionContext context)
            {
                GraphQLCommon.RecordExecutionErrorsIfPresent(activity, ErrorType, context.Errors);
            }
        }
        finally
        {
            activity.Dispose();
        }

        return(executionResult);
    }
    /// <summary>
    /// OnMethodEnd callback
    /// </summary>
    /// <typeparam name="TTarget">Type of the target</typeparam>
    /// <typeparam name="TValidationResult">Type of the validation result value</typeparam>
    /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
    /// <param name="validationResult">IValidationResult instance</param>
    /// <param name="exception">Exception instance in case the original code threw an exception.</param>
    /// <param name="state">Calltarget state value</param>
    /// <returns>A response value, in an async scenario will be T of Task of T</returns>
    public static CallTargetReturn <TValidationResult> OnMethodEnd <TTarget, TValidationResult>(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state)
        where TValidationResult : IValidationResult
    {
        Activity activity = state.Activity;

        if (activity is null)
        {
            return(new CallTargetReturn <TValidationResult>(validationResult));
        }

        try
        {
            if (exception != null)
            {
                activity.SetException(exception);
            }
            else
            {
                GraphQLCommon.RecordExecutionErrorsIfPresent(activity, ErrorType, validationResult.Errors);
            }
        }
        finally
        {
            activity.Dispose();
        }

        return(new CallTargetReturn <TValidationResult>(validationResult));
    }