Skip to content

Commit

Permalink
fix statusName
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov committed Aug 15, 2024
1 parent 3798d85 commit c92bd28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion slo/src/AdoNet/SloContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SloContext : SloContext<YdbDataSource>
context["RetryCount"] = retryCount;
var errorsGauge = (Gauge)context["errorsGauge"];
errorsGauge?.WithLabels(((YdbException)e).Code.ToString(), "retried").Inc();
errorsGauge?.WithLabels(((YdbException)e).Code.StatusName(), "retried").Inc();
});

protected override string Job => "workload-ado-net";
Expand Down
13 changes: 11 additions & 2 deletions slo/src/Internal/SloContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ Task ShootingTask(RateLimiter rateLimitPolicy, string jobName,
var errorsGauge = metricFactory.CreateGauge("errors", "amount of errors", new[] { "class", "in" });
foreach (var statusCode in Enum.GetValues<StatusCode>())
{
errorsGauge.WithLabels(statusCode.ToString(), "retried").IncTo(0);
errorsGauge.WithLabels(statusCode.ToString(), "finally").IncTo(0);
errorsGauge.WithLabels(statusCode.StatusName(), "retried").IncTo(0);
errorsGauge.WithLabels(statusCode.StatusName(), "finally").IncTo(0);
}

// ReSharper disable once MethodSupportsCancellation
Expand Down Expand Up @@ -264,4 +264,13 @@ private async Task MetricReset(string promPgwEndpoint)
using var httpClient = new HttpClient();
await httpClient.DeleteAsync(deleteUri);
}
}

public static class StatusCodeExtension
{
public static string StatusName(this StatusCode statusCode)
{
var prefix = statusCode >= StatusCode.ClientTransportResourceExhausted ? "GRPC" : "YDB";
return $"{prefix}_{statusCode}";
}
}
2 changes: 1 addition & 1 deletion slo/src/TableService/SloContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override async Task Create(TableClient client, string createTableSql,
return response;
}
errorsGauge?.WithLabels(response.Status.StatusCode.ToString(), "retried").Inc();
errorsGauge?.WithLabels(response.Status.StatusCode.StatusName(), "retried").Inc();
return response;
});
Expand Down

0 comments on commit c92bd28

Please sign in to comment.