Exemple #1
0
        public async Task ExceptionInSnapshot_IsHandled()
        {
            var exceptionThrown = new ManualResetEventSlim(false);
            var metricSet       = new FailureMetricSet(throwOnSnapshot: true);
            var collector       = new MetricsCollector(
                new MetricsCollectorOptions
            {
                Endpoints        = new[] { new MetricEndpoint("Local", new LocalMetricHandler()), },
                Sets             = new[] { metricSet },
                RetryInterval    = TimeSpan.Zero,
                SnapshotInterval = TimeSpan.FromMilliseconds(20),
                ExceptionHandler = ex => exceptionThrown.Set()
            }
                );

            Assert.True(exceptionThrown.Wait(TimeSpan.FromSeconds(1)), "Exception handler was not invoked");
        }
Exemple #2
0
        public void ExceptionInInitialize_Throws()
        {
            var metricSet = new FailureMetricSet(throwOnInitialize: true);

            Assert.Throws <Exception>(
                () =>
            {
                new MetricsCollector(
                    new MetricsCollectorOptions
                {
                    Endpoints        = new[] { new MetricEndpoint("Local", new LocalMetricHandler()), },
                    Sets             = new[] { metricSet },
                    RetryInterval    = TimeSpan.Zero,
                    SnapshotInterval = TimeSpan.FromMilliseconds(20),
                }
                    );
            }
                );
        }