Ejemplo n.º 1
0
        public void Flush()
        {
            if (siloAddress == null)
            {
                siloAddress = localSiloDetails.SiloAddress.ToParsableString();
            }

            var grain = grainFactory.GetGrain <ISiloGrain>(siloAddress);

            var size = metrics.Count + timespanMetrics.Count;

            if (size == 0)
            {
                return;
            }

            var counters      = new StatCounter[size];
            var countersIndex = 0;

            foreach (var(key, value) in metrics)
            {
                // In case new values have been added to metrics in another thread. It will be pushed the next time then.
                if (countersIndex == counters.Length)
                {
                    break;
                }

                counters[countersIndex] =
                    new StatCounter(
                        key,
                        value.Current.ToString(CultureInfo.InvariantCulture),
                        ComputeDelta(value));

                countersIndex++;
            }

            foreach (var(key, value) in timespanMetrics)
            {
                // In case new values have been added to metrics in timespanMetrics thread. It will be pushed the next time then.
                if (countersIndex == counters.Length)
                {
                    break;
                }

                counters[countersIndex] =
                    new StatCounter(
                        key,
                        value.Current.ToString("c", CultureInfo.InvariantCulture),
                        ComputeDelta(value));

                countersIndex++;
            }

            grain.ReportCounters(counters.AsImmutable());
        }
Ejemplo n.º 2
0
        public void Flush()
        {
            if (siloAddress == null)
            {
                siloAddress = localSiloDetails.SiloAddress.ToParsableString();
            }

            var grain = grainFactory.GetGrain <ISiloGrain>(siloAddress);

            var size = metrics.Count + timespanMetrics.Count;

            if (size == 0)
            {
                return;
            }

            var counters      = new StatCounter[size];
            var countersIndex = 0;

            foreach (var(key, value) in metrics)
            {
                counters[countersIndex] =
                    new StatCounter(key, value.Current.ToString(CultureInfo.InvariantCulture),
                                    ComputeDelta(value));

                countersIndex++;
            }

            foreach (var(key, value) in timespanMetrics)
            {
                counters[countersIndex] =
                    new StatCounter(key, value.Current.ToString("c", CultureInfo.InvariantCulture),
                                    ComputeDelta(value));

                countersIndex++;
            }

            grain.ReportCounters(counters.AsImmutable());
        }