Partilhar via


LoadTestRunClient.GetMetricDefinitionsAsync Método

Definição

Liste as definições de métrica para uma execução de teste de carga.

public virtual System.Threading.Tasks.Task<Azure.Response> GetMetricDefinitionsAsync (string testRunId, string metricNamespace, Azure.RequestContext context = default);
abstract member GetMetricDefinitionsAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetMetricDefinitionsAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetMetricDefinitionsAsync (testRunId As String, metricNamespace As String, Optional context As RequestContext = Nothing) As Task(Of Response)

Parâmetros

testRunId
String

O nome exclusivo para a execução do teste de carga deve conter apenas caracteres alfabéticos, numéricos, sublinhados ou hifens de minúsculas.

metricNamespace
String

Namespace de métrica para o qual consultar definições de métrica.

context
RequestContext

O contexto de solicitação, que pode substituir os comportamentos padrão do pipeline do cliente por chamada.

Retornos

A resposta retornada do serviço. Os detalhes do esquema do corpo da resposta estão na seção Comentários abaixo.

Exceções

testRunId ou metricNamespace é nulo.

testRunId é uma cadeia de caracteres vazia e esperava-se que não estivesse vazia.

O serviço retornou um código de status sem êxito.

Exemplos

Este exemplo mostra como chamar GetMetricDefinitionsAsync com os parâmetros necessários e analisar o resultado.

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);

Response response = await client.GetMetricDefinitionsAsync("<testRunId>", "<metricNamespace>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].GetProperty("dimensions")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("dimensions")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("namespace").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("primaryAggregationType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("supportedAggregationTypes")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("metricAvailabilities")[0].GetProperty("timeGrain").ToString());

Comentários

Abaixo está o esquema JSON para o conteúdo da resposta.

Corpo da resposta:

Esquema para MetricDefinitionCollection:

{
  value: [
    {
      dimensions: [
        {
          description: string, # Optional. The description
          name: string, # Optional. The name
        }
      ], # Optional. List of dimensions
      description: string, # Optional. The metric description
      name: string, # Optional. The metric name
      namespace: string, # Optional. The namespace the metric belongs to.
      primaryAggregationType: "Average" | "Count" | "None" | "Total" | "Percentile90" | "Percentile95" | "Percentile99", # Optional. The primary aggregation type value defining how to use the values for display.
      supportedAggregationTypes: [string], # Optional. The collection of what all aggregation types are supported.
      unit: "NotSpecified" | "Percent" | "Count" | "Seconds" | "Milliseconds" | "Bytes" | "BytesPerSecond" | "CountPerSecond", # Optional. The unit of the metric.
      metricAvailabilities: [
        {
          timeGrain: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H", # Optional. The time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'PT1H', etc.
        }
      ], # Optional. Metric availability specifies the time grain (aggregation interval or frequency).
    }
  ], # Required. the values for the metric definitions.
}

Aplica-se a