Skip to content

Commit

Permalink
[OPIK-416] Add logs to understand issue (#823)
Browse files Browse the repository at this point in the history
* [OPIK-416] Add logs to understand issue

* Keep 500 error
  • Loading branch information
thiagohora authored Dec 5, 2024
1 parent 2aa215b commit d6237a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,16 @@ public Response createSpans(
}
});

String workspaceId = requestContext.get().getWorkspaceId();

log.info("Creating spans batch with size '{}' on workspaceId '{}'", spans.spans().size(), workspaceId);

spanService.create(spans)
.contextWrite(ctx -> setRequestContext(ctx, requestContext))
.block();

log.info("Created spans batch with size '{}' on workspaceId '{}'", spans.spans().size(), workspaceId);

return Response.noContent().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private List<UUID> sortByLastTrace(
}

@Override
public List<Project> findByNames(String workspaceId, List<String> names) {
public List<Project> findByNames(@NonNull String workspaceId, @NonNull List<String> names) {

if (names.isEmpty()) {
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,12 @@ public Mono<Long> create(@NonNull SpanBatch batch) {
.distinct()
.toList();

log.info("Creating batch of spans for projects '{}'", projectNames);

Mono<List<Span>> resolveProjects = Flux.fromIterable(projectNames)
.flatMap(this::getOrCreateProject)
.collectList()
.map(projects -> bindSpanToProjectAndId(batch, projects))
.subscribeOn(Schedulers.boundedElastic());
.map(projects -> bindSpanToProjectAndId(batch, projects));

return resolveProjects
.flatMap(spanDAO::batchInsert);
Expand All @@ -290,6 +291,11 @@ private List<Span> bindSpanToProjectAndId(SpanBatch batch, List<Project> project
String projectName = WorkspaceUtils.getProjectName(span.projectName());
Project project = projectPerName.get(projectName);

if (project == null) {
log.warn("Project not found for span project '{}' and default '{}'", span.projectName(), projectName);
throw new IllegalStateException("Project not found: %s".formatted(span.projectName()));
}

UUID id = span.id() == null ? idGenerator.generateId() : span.id();
IdGenerator.validateVersion(id, SPAN_KEY);

Expand Down

0 comments on commit d6237a2

Please sign in to comment.