public virtual async Task <Response <IReadOnlyList <MetricNamespace> > > GetMetricNamespacesAsync(string resource, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsClient)}.{nameof(GetMetricNamespaces)}"); scope.Start(); try { var response = await _namespacesRestClient.ListAsync(resource, cancellationToken : cancellationToken).ConfigureAwait(false); return(Response.FromValue(response.Value.Value, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Gets metric namespaces for a particular resource. /// </summary> /// <param name="resourceId">The resource name.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param> /// <returns>A pageable collection of metric namespaces.</returns> public virtual AsyncPageable <MetricNamespace> GetMetricNamespacesAsync(string resourceId, CancellationToken cancellationToken = default) { return(PageResponseEnumerator.CreateAsyncEnumerable(async _ => { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsQueryClient)}.{nameof(GetMetricNamespaces)}"); scope.Start(); try { var response = await _namespacesRestClient.ListAsync(resourceId, cancellationToken: cancellationToken).ConfigureAwait(false); return Page <MetricNamespace> .FromValues(response.Value.Value, null, response.GetRawResponse()); } catch (Exception e) { scope.Failed(e); throw; } })); }