/// <summary> /// The List Metric operation lists the metric value sets for the /// resource metrics. /// </summary> /// <param name='operations'> /// Reference to the Microsoft.Azure.Insights.IMetricOperations. /// </param> /// <param name='resourceUri'> /// Required. The resource identifier of the target resource to get /// metrics for. /// </param> /// <param name='filterString'> /// Optional. An OData $filter expression that supports querying by the /// name, startTime, endTime and timeGrain of the metric value sets. /// For example, "(name.value eq 'Percentage CPU') and startTime eq /// 2014-07-02T01:00Z and endTime eq 2014-08-21T01:00:00Z and /// timeGrain eq duration'PT1H'". In the expression, startTime, /// endTime and timeGrain are required. Name is optional. /// </param> /// <returns> /// The List Metric values operation response. /// </returns> public static MetricListResponse GetMetrics(this IMetricOperations operations, string resourceUri, string filterString) { return(Task.Factory.StartNew((object s) => { return ((IMetricOperations)s).GetMetricsAsync(resourceUri, filterString); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Initializes a new instance of the InsightsClient class. /// </summary> /// <param name='httpClient'> /// The Http client /// </param> public InsightsClient(HttpClient httpClient) : base(httpClient) { this._metricDefinitionOperations = new MetricDefinitionOperations(this); this._metricOperations = new MetricOperations(this); this._apiVersion = "2014-04-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; this.HttpClient.Timeout = TimeSpan.FromSeconds(300); }
/// <summary> /// Initializes a new instance of the InsightsClient class. /// </summary> private InsightsClient() : base() { this._eventOperations = new EventOperations(this); this._metricDefinitionOperations = new MetricDefinitionOperations(this); this._metricOperations = new MetricOperations(this); this._usageMetricOperations = new UsageMetricsOperations(this); this._apiVersion = "2014-04-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; this.HttpClient.Timeout = TimeSpan.FromSeconds(300); }
/// <summary> /// Non-async version returns the MetricListResponse straight (consistent with overload for get metrics by name functions) /// </summary> /// <param name="operations">Reference to IMetricOperations</param> /// <param name="resourceUri">Resource Uri for the metrics</param> /// <param name="filterString">OData filter string (no name specifitations allowed in this one)</param> /// <param name="definitions">The MetricDefinitions</param> /// <returns>The requested Metrics</returns> public static MetricListResponse GetMetrics(this IMetricOperations operations, string resourceUri, string filterString, IEnumerable <MetricDefinition> definitions) { try { return(operations.GetMetricsAsync(resourceUri, filterString, definitions).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// Overload for get metrics by definitions that does not require cancellation token (consistent with overload for get metrics by name functions) /// </summary> /// <param name="operations">Reference to IMetricOperations</param> /// <param name="resourceUri">Resource Uri for the metrics</param> /// <param name="filterString">OData filter string (no name specifitations allowed in this one)</param> /// <param name="definitions">The MetricDefinitions</param> /// <returns>The requested Metrics</returns> public static Task <MetricListResponse> GetMetricsAsync(this IMetricOperations operations, string resourceUri, string filterString, IEnumerable <MetricDefinition> definitions) { return(operations.GetMetricsAsync(resourceUri, filterString, definitions, CancellationToken.None)); }