コード例 #1
0
        public AzureQueueMetric(AzureQueueMetricOptions options)
        {
            // Validate required options
            if (options.TelemetryClient == null)
            {
                throw new ArgumentNullException(nameof(options.TelemetryClient));
            }

            if (string.IsNullOrEmpty(options.MetricPrefix))
            {
                throw new ArgumentNullException(nameof(options.MetricPrefix));
            }

            if (string.IsNullOrEmpty(options.StorageConnectionString))
            {
                throw new ArgumentNullException(nameof(options.StorageConnectionString));
            }

            _metricPrefix    = options.MetricPrefix;
            _telemetryClient = options.TelemetryClient;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(options.StorageConnectionString);

            _queueClient = storageAccount.CreateCloudQueueClient();

            PushInterval = options.PushInterval ?? 60000;

            Queues = new List <string>();
            options.Queues.ForEach(x =>
            {
                Queues.Add(x);
                Queues.Add(x + "-poison");
            });

            Task.Run(MetricLoopAsync);
        }
コード例 #2
0
 public static AzureQueueMetric Use(AzureQueueMetricOptions options)
 {
     return(new AzureQueueMetric(options));
 }