/// <summary>
        /// Writes statistics to the database
        /// </summary>
        /// <param name="statsCounters">Statistics counters to write</param>
        /// <returns>Task for database opearation</returns>
        public async Task ReportStats(List <ICounter> statsCounters)
        {
            var siloOrClientName = (isSilo) ? siloName : clientId;
            var id = (isSilo) ? siloAddress.ToLongString() : string.Format("{0}:{1}", siloOrClientName, generation);

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace("ReportStats called with {0} counters, name: {1}, id: {2}", statsCounters.Count, siloOrClientName, id);
            }
            var insertTasks = new List <Task>();

            try
            {
                //This batching is done for two reasons:
                //1) For not to introduce a query large enough to be rejected.
                //2) Performance, though using a fixed constants likely will not give the optimal performance in every situation.
                const int maxBatchSizeInclusive = 200;
                var       counterBatches        = BatchCounters(statsCounters, maxBatchSizeInclusive);
                foreach (var counterBatch in counterBatches)
                {
                    //The query template from which to retrieve the set of columns that are being inserted.
                    insertTasks.Add(orleansQueries.InsertStatisticsCountersAsync(deploymentId, hostName, siloOrClientName, id, counterBatch));
                }

                await Task.WhenAll(insertTasks);
            }
            catch (Exception ex)
            {
                if (logger.IsEnabled(LogLevel.Debug))
                {
                    logger.Debug("ReportStats faulted: {0}", ex.ToString());
                }
                foreach (var faultedTask in insertTasks.Where(t => t.IsFaulted))
                {
                    if (logger.IsEnabled(LogLevel.Debug))
                    {
                        logger.Debug("Faulted task exception: {0}", faultedTask.ToString());
                    }
                }

                throw;
            }

            if (logger.IsEnabled(LogLevel.Debug))
            {
                logger.Debug("ReportStats SUCCESS");
            }
        }