private IMetricSeriesAggregator GetOrCreatePersistentAggregator()
        {
            IMetricSeriesAggregator aggregator = _aggregatorPersistent;

            if (aggregator == null)
            {
                aggregator = _configuration.CreateNewAggregator(this, CycleKind.Default);
                IMetricSeriesAggregator prevAggregator = Interlocked.CompareExchange(ref _aggregatorPersistent, aggregator, null);

                if (prevAggregator == null)
                {
                    bool added = _aggregationManager.AddAggregator(aggregator, CycleKind.Default);
                    if (added == false)
                    {
                        throw new InvalidOperationException("Internal SDK gub. Please report!"
                                                            + " Info: _aggregationManager.AddAggregator reports false for a PERSISTENT aggregator."
                                                            + " This should never happen.");
                    }
                }
                else
                {
                    aggregator = prevAggregator;
                }
            }

            return(aggregator);
        }
        private IMetricSeriesAggregator GetOrCreatePersistentAggregator()
        {
            IMetricSeriesAggregator aggregator = _aggregatorPersistent;

            if (aggregator == null)
            {
                aggregator = _configuration.CreateNewAggregator(this, CycleKind.Default);
                IMetricSeriesAggregator prevAggregator = Interlocked.CompareExchange(ref _aggregatorPersistent, aggregator, null);

                if (prevAggregator == null)
                {
                    bool added = _aggregationManager.AddAggregator(aggregator, CycleKind.Default);
                    if (added == false)
                    {
                        return(GetOrCreatePersistentAggregator());
                    }
                }
                else
                {
                    aggregator = prevAggregator;
                }
            }

            return(aggregator);
        }