From 5f81fa021231af6875da05b161d08356df49b763 Mon Sep 17 00:00:00 2001 From: Borys Tkachenko Date: Fri, 13 Dec 2024 15:21:31 +0100 Subject: [PATCH] fix comment --- .../src/main/java/com/comet/opik/api/ErrorInfo.java | 3 +++ .../src/main/java/com/comet/opik/domain/SpanDAO.java | 6 ++---- .../src/main/java/com/comet/opik/domain/TraceDAO.java | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/opik-backend/src/main/java/com/comet/opik/api/ErrorInfo.java b/apps/opik-backend/src/main/java/com/comet/opik/api/ErrorInfo.java index 05ca534a83..24cea61e35 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/api/ErrorInfo.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/api/ErrorInfo.java @@ -1,6 +1,7 @@ package com.comet.opik.api; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import jakarta.validation.constraints.NotBlank; @@ -13,4 +14,6 @@ public record ErrorInfo( @NotBlank String exceptionType, String message, @NotBlank String traceback) { + public static final TypeReference ERROR_INFO_TYPE = new TypeReference<>() { + }; } diff --git a/apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java b/apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java index 2b64212528..4ce83b2a69 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java @@ -1,6 +1,5 @@ package com.comet.opik.domain; -import com.comet.opik.api.ErrorInfo; import com.comet.opik.api.ProjectStats; import com.comet.opik.api.Span; import com.comet.opik.api.SpanSearchCriteria; @@ -11,7 +10,6 @@ import com.comet.opik.domain.stats.StatsMapper; import com.comet.opik.utils.JsonUtils; import com.comet.opik.utils.TemplateUtils; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Preconditions; import io.opentelemetry.instrumentation.annotations.WithSpan; @@ -43,6 +41,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.comet.opik.api.ErrorInfo.ERROR_INFO_TYPE; import static com.comet.opik.domain.AsyncContextUtils.bindUserNameAndWorkspaceContextToStream; import static com.comet.opik.domain.AsyncContextUtils.bindWorkspaceIdToFlux; import static com.comet.opik.domain.AsyncContextUtils.bindWorkspaceIdToMono; @@ -1089,8 +1088,7 @@ private Publisher mapToDto(Result result) { .usage(row.get("usage", Map.class)) .errorInfo(Optional.ofNullable(row.get("error_info", String.class)) .filter(str -> !str.isBlank()) - .map(errorInfo -> JsonUtils.readValue(errorInfo, new TypeReference() { - })) + .map(errorInfo -> JsonUtils.readValue(errorInfo, ERROR_INFO_TYPE)) .orElse(null)) .createdAt(row.get("created_at", Instant.class)) .lastUpdatedAt(row.get("last_updated_at", Instant.class)) diff --git a/apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java b/apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java index f20577b1ab..41557b8b08 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java @@ -1,7 +1,6 @@ package com.comet.opik.domain; import com.comet.opik.api.BiInformationResponse.BiInformation; -import com.comet.opik.api.ErrorInfo; import com.comet.opik.api.ProjectStats; import com.comet.opik.api.Trace; import com.comet.opik.api.TraceSearchCriteria; @@ -12,7 +11,6 @@ import com.comet.opik.infrastructure.db.TransactionTemplateAsync; import com.comet.opik.utils.JsonUtils; import com.comet.opik.utils.TemplateUtils; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Preconditions; import com.google.inject.ImplementedBy; @@ -42,6 +40,7 @@ import java.util.UUID; import java.util.stream.Collectors; +import static com.comet.opik.api.ErrorInfo.ERROR_INFO_TYPE; import static com.comet.opik.api.Trace.TracePage; import static com.comet.opik.api.TraceCountResponse.WorkspaceTraceCount; import static com.comet.opik.domain.AsyncContextUtils.bindUserNameAndWorkspaceContext; @@ -929,8 +928,7 @@ private Publisher mapToDto(Result result) { : row.get("total_estimated_cost", BigDecimal.class)) .errorInfo(Optional.ofNullable(row.get("error_info", String.class)) .filter(str -> !str.isBlank()) - .map(errorInfo -> JsonUtils.readValue(errorInfo, new TypeReference() { - })) + .map(errorInfo -> JsonUtils.readValue(errorInfo, ERROR_INFO_TYPE)) .orElse(null)) .createdAt(row.get("created_at", Instant.class)) .lastUpdatedAt(row.get("last_updated_at", Instant.class))