예제 #1
0
        private async Task Initialize()
        {
            var metricClient = new MetricsQueryClient(_testEnvironment.MetricsEndpoint, _testEnvironment.Credential);

            var senderClient = new MetricsSenderClient(
                _testEnvironment.Location,
                _testEnvironment.MetricsIngestionEndpoint,
                _testEnvironment.MetricsResource,
                _testEnvironment.Credential,
                new SenderClientOptions()
            {
                Diagnostics = { IsLoggingContentEnabled = true }
            });

            do
            {
                // Stop sending when we are past the allowed threshold
                if (DateTimeOffset.UtcNow - StartTime < AllowedMetricAge)
                {
                    await SendData(senderClient);
                }

                await Task.Delay(TimeSpan.FromSeconds(5));
            } while (!await MetricsPropagated(metricClient));
        }
        private async Task SendData()
        {
            var senderClient = new MetricsSenderClient(
                _testEnvironment.Location,
                _testEnvironment.MetricsIngestionEndpoint,
                _testEnvironment.MetricsResource,
                _testEnvironment.Credential,
                new SenderClientOptions()
            {
                Diagnostics = { IsLoggingContentEnabled = true }
            });

            var names = new[] { Name1, Name2 };

            foreach (var name in names)
            {
                for (int i = 0; i < Duration.Minutes; i++)
                {
                    await senderClient.SendAsync(new MetricDataDocument(StartTime.AddMinutes(i), new(new(
                                                                                                         MetricName,
                                                                                                         MetricNamespace,
                                                                                                         new[] { "Name" },
                                                                                                         new SeriesValue[]
                    {
                        new(new[] { name }, 5 * i, 20 * i, 30 * i, 1 + i)
                    }))));
예제 #3
0
        private async Task SendData(MetricsSenderClient senderClient)
        {
            var names = new[] { Name1, Name2 };

            foreach (var name in names)
            {
                for (int i = 0; i < Duration.Minutes; i++)
                {
                    await senderClient.SendAsync(new MetricDataDocument(StartTime.AddMinutes(i), new(new(
                                                                                                         MetricName,
                                                                                                         MetricNamespace,
                                                                                                         new[] { "Name" },
                                                                                                         new SeriesValue[]
                    {
                        new(new[] { name }, 5 * i, 20 * i, 30 * i, 1 + i)
                    }))));