Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Query: allowed null operation name in SessionRetryContext, retry metrics are reported without `operation.name` attribute
* Table: allowed null operation name in SessionRetryContext, retry metrics are reported without `operation.name` attribute

## 2.5.1 ##
* Core: added opt-in PRIMARY/PROMOTED Bridge pile preference with synchronized-pile fallback
* Core: added Meter histograms with explicit bucket boundaries, OpenTelemetryMeter uses OpenTelemetry database latency boundaries by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ public <T> CompletableFuture<Result<T>> supplyResult(Function<QuerySession, Comp
* Executes the function with retries as one logical operation.
*
* @param operationName name of the logical operation, used as the retry span name and reported as the
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics; if {@code null}, the attribute is not
* reported
* @param fn function to execute
* @param <T> type of the result value
* @return future with the result of the last attempt
*/
public <T> CompletableFuture<Result<T>> supplyResult(String operationName,
public <T> CompletableFuture<Result<T>> supplyResult(@Nullable String operationName,
Function<QuerySession, CompletableFuture<Result<T>>> fn) {
return execute(new RetryableResultTask<>(Objects.requireNonNull(operationName, "operationName is null"), fn));
return execute(new RetryableResultTask<>(operationName, fn));
}

public CompletableFuture<Status> supplyStatus(Function<QuerySession, CompletableFuture<Status>> fn) {
Expand All @@ -97,13 +98,14 @@ public CompletableFuture<Status> supplyStatus(Function<QuerySession, Completable
* Executes the function with retries as one logical operation.
*
* @param operationName name of the logical operation, used as the retry span name and reported as the
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics; if {@code null}, the attribute is not
* reported
* @param fn function to execute
* @return future with the status of the last attempt
*/
public CompletableFuture<Status> supplyStatus(String operationName,
public CompletableFuture<Status> supplyStatus(@Nullable String operationName,
Function<QuerySession, CompletableFuture<Status>> fn) {
return execute(new RetryableStatusTask(Objects.requireNonNull(operationName, "operationName is null"), fn));
return execute(new RetryableStatusTask(operationName, fn));
}

private static <R> CompletableFuture<R> execute(BaseRetryableTask<R> task) {
Expand Down
16 changes: 8 additions & 8 deletions table/src/main/java/tech/ydb/table/SessionRetryContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ public CompletableFuture<Status> supplyStatus(SessionRetryHandler h,
* Executes the function with retries as one logical operation.
*
* @param operationName name of the logical operation, used as the retry span name and reported as the
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics; if {@code null}, the attribute is not
* reported
* @param fn function to execute
* @param <T> type of the result value
* @return future with the result of the last attempt
*/
public <T> CompletableFuture<Result<T>> supplyResult(String operationName,
public <T> CompletableFuture<Result<T>> supplyResult(@Nullable String operationName,
Function<Session, CompletableFuture<Result<T>>> fn) {
return supplyResult(operationName, SessionRetryHandler.DEFAULT, fn);
}
Expand All @@ -106,24 +107,23 @@ public <T> CompletableFuture<Result<T>> supplyResult(String operationName,
* Executes the function with retries as one logical operation.
*
* @param operationName name of the logical operation, used as the retry span name and reported as the
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics
* {@code operation.name} attribute of {@code ydb.client.retry.*} metrics; if {@code null}, the attribute is not
* reported
* @param fn function to execute
* @return future with the status of the last attempt
*/
public CompletableFuture<Status> supplyStatus(String operationName,
public CompletableFuture<Status> supplyStatus(@Nullable String operationName,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion · Проверить явную передачу null в тестах Query и Table

Существующие тесты проверяют имя span и обе метрики через supplyStatus(fn). Они продолжат проходить, даже если в перегрузки с именем операции вернуть requireNonNull. Стоит добавить в обоих модулях вызовы supplyStatus(operationName, fn) и supplyResult(operationName, fn) с String operationName = null и проверить, что span получает имя ydb.RunWithRetry, а обе гистограммы записываются без operation.name.

В Table тип String также позволяет компилятору выбрать перегрузку: для литерала null подходит и вариант с SessionRetryHandler. Тест Query · Тест Table

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не стоит, методы без operationName передают null, тесты это проверяют

Function<Session, CompletableFuture<Status>> fn) {
return supplyStatus(operationName, SessionRetryHandler.DEFAULT, fn);
}

public <T> CompletableFuture<Result<T>> supplyResult(String operationName, SessionRetryHandler h,
public <T> CompletableFuture<Result<T>> supplyResult(@Nullable String operationName, SessionRetryHandler h,
Function<Session, CompletableFuture<Result<T>>> fn) {
Objects.requireNonNull(operationName, "operationName is null");
return execute(new RetryableResultTask<>(operationName, h, fn));
}

public CompletableFuture<Status> supplyStatus(String operationName, SessionRetryHandler h,
public CompletableFuture<Status> supplyStatus(@Nullable String operationName, SessionRetryHandler h,
Function<Session, CompletableFuture<Status>> fn) {
Objects.requireNonNull(operationName, "operationName is null");
return execute(new RetryableStatusTask(operationName, h, fn));
}

Expand Down