public virtual Response <IReadOnlyList <MetricDefinition> > GetMetrics(string resource, string metricsNamespace, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsClient)}.{nameof(GetMetrics)}"); scope.Start(); try { var response = _metricDefinitionsClient.List(resource, metricsNamespace, cancellationToken); return(Response.FromValue(response.Value.Value, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Gets metric definitions for a particular resource and metric namespace. /// </summary> /// <param name="resourceId">The resource name. /// For example: /// <c>/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource></c>,<br/> /// <c>/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Storage/storageAccounts/mystorage</c>,<br/> /// <c>/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachines/myvm</c><br/> /// </param> /// <param name="metricsNamespace">The metric namespace. /// For example: <c>Microsoft.OperationalInsights/workspaces</c>.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param> /// <returns>A pageable collection of metric definitions.</returns> public virtual Pageable <MetricDefinition> GetMetricDefinitions(string resourceId, string metricsNamespace, CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateEnumerable(_ => { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsQueryClient)}.{nameof(GetMetricDefinitions)}"); scope.Start(); try { var response = _metricDefinitionsClient.List(resourceId, metricsNamespace, cancellationToken); return Page <MetricDefinition> .FromValues(response.Value.Value, null, response.GetRawResponse()); } catch (Exception e) { scope.Failed(e); throw; } })); }