8000 OPIK-1764: Add endpoint to Open/Close threads manually by thiagohora · Pull Request #2501 · comet-ml/opik · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

OPIK-1764: Add endpoint to Open/Close threads manually #2501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

thiagohora
Copy link
Contributor
@thiagohora thiagohora commented Jun 17, 2025

Details

  • Add endpoint to Open/Close threads manually

Copy link
Contributor
github-actions bot commented Jun 17, 2025

Backend Tests Results

  175 files  + 1    175 suites  +1   18m 8s ⏱️ + 3m 17s
3 829 tests ± 0  3 826 ✅ + 1  3 💤 ±0  0 ❌ ±0 
3 829 runs  +15  3 826 ✅ +15  3 💤 ±0  0 ❌ ±0 

Results for commit 5eaf057. ± Comparison against base commit 1f53469.

This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.
com.comet.opik.infrastructure.bi.OpikGuiceyLifecycleEventListenerTest$FirstStartupTest ‑ Unknown test
com.comet.opik.api.resources.v1.priv.TracesResourceTest$TraceThreadManualOpenClose ‑ manualCloseAndReopeningTraceThread(TraceThreadService)

♻️ This comment has been updated with latest results.

Base automatically changed from thiagohora/OPIK-1765_improve_implementation_to_prevent_duplicated_messages_in_queue to main June 19, 2025 15:27
Copy link
Contributor

SDK E2E Tests Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 10c6f20.

Copy link
Contributor

SDK E2E Tests Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 10c6f20.

Copy link
Contributor
github-actions bot commented Jun 19, 2025

SDK E2E Tests Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 10c6f20.

♻️ This comment has been updated with latest results.

@thiagohora thiagohora force-pushed the thiagohora/OPIK-1764_add_endpoint_to_open_close_threads_manually branch from 10c6f20 to 77aaa6d Compare June 19, 2025 15:57
@thiagohora thiagohora marked this pull request as ready for review June 19, 2025 16:00
@thiagohora thiagohora requested a review from a team as a code owner June 19, 2025 16:00
.sortingFields(List.of())
.build();

Flux<Trace> items = service.search(request.limit(), searchCriteria)
Copy link
Contributor

Choose a reason for hiding this comment

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

service -> can be renamed to traceService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, we use context awareness; the controller is scoped to cover trace domain-related endpoints. Having this in mind, the service is assumed to be related to traces, so when it's not, a more descriptive name is used. Rename it would not add much context

Copy link
Contributor

Choose a reason for hiding this comment

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

i see that you mean, but try to think about a junior developer - would it be clear to him? :) along with that this resource have multiple services so just not to create a confusion - it will be more readable and less error prompt


log.info("Streaming traces search results by '{}', workspaceId '{}'", request, workspaceId);

var searchCriteria = TraceSearchCriteria.builder()
Copy link
Contributor

Choose a reason for hiding this comment

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

can this been pushed into the service layer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same, this is not business logic, it's a mapper from request DTO to criteria object, which belongs to the domain

Copy link
Contributor

Choose a reason for hiding this comment

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

the resources should not be aware to anything related to the searchCriteria or any other logic beside passing it to the service / facade layer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly, the responsibility of api/controller layer is mapping objects from domain to api and vice versa and validate it. you can see all endpoint follow this pattern

@QueryParam("filters") String filters) {

validateProjectNameAndProjectId(projectName, projectId);
var traceFilters = filtersFactory.newFilters(filters, TraceFilter.LIST_TYPE_REFERENCE);
Copy link
Contributor

Choose a reason for hiding this comment

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

same, logic should be part of the serivce layer to keep the resoueces clean as possible without logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is related to validation of the param receiced from the request, so they don't classify as business logic

Copy link
Contributor

Choose a reason for hiding this comment

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

same as above


validateProjectNameAndProjectId(projectName, projectId);
var traceFilters = filtersFactory.newFilters(filters, TraceFilter.LIST_TYPE_REFERENCE);
var searchCriteria = TraceSearchCriteria.builder()
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same


log.info("Find feedback score names by project_id '{}', on workspaceId '{}'",
projectId, workspaceId);
FeedbackScoreNames feedbackScoreNames = feedbackScoreService
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to return an object that contains the names + ids of the feedback score?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just moved, it's out of the scope of the PR

Comment on lines +12 to +15
public boolean isValid(TraceThreadIdentifier traceThreadIdentifier,
ConstraintValidatorContext constraintValidatorContext) {
return !(traceThreadIdentifier.projectName() == null && traceThreadIdentifier.projectId() == null);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

public boolean isValid(TraceThreadIdentifier traceThreadIdentifier,
ConstraintValidatorContext constraintValidatorContext) {
return traceThreadIdentifier != null &&
(traceThreadIdentifier.projectName() != null || traceThreadIdentifier.projectId() != null);
}

do we want to simplify it maybe to be more direct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see it as more verbose, but we can extract the condition to a variable to improve readability

import lombok.Builder;

import java.util.UUID;

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record TraceThreadIdentifier(@NotNull UUID projectId, @NotBlank String threadId) {
@TraceThreadIdentifierValidation
public record TraceThreadIdentifier(String projectName, UUID projectId, @NotBlank String threadId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i saw we removed the @NotNull - by defenition or mistake? as well dose the projectName can be blank?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intended since now we can use either projectName or projectId

@@ -38,7 +38,11 @@ Flux<ProjectWithPendingClosureTraceThreads> getProjectsWithPendingClosureThreads

Mono<Void> processProjectWithTraceThreadsPendingClosure(UUID projectId, Instant lastUpdatedUntil);

Mono<Boolean> addToPendingQueue(@NonNull UUID projectId);
Mono<Boolean> addToPendingQueue(UUID projectId);
Copy link
Contributor
@YarivHashaiComet YarivHashaiComet Jun 19, 2025

Choose a reason for hiding this comment

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

can this be null? (saw we remove the restriction)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but adding the Lombok annotation on interfaces has no effect. It has to be added to the implementation class

Copy link
Contributor
@YarivHashaiComet YarivHashaiComet left a comment

Choose a reason for hiding this comment

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

looks good - added some comments

@thiagohora thiagohora force-pushed the thiagohora/OPIK-1764_add_endpoint_to_open_close_threads_manually branch from 77aaa6d to 803ac15 Compare June 19, 2025 16:22
@thiagohora thiagohora force-pushed the thiagohora/OPIK-1764_add_endpoint_to_open_close_threads_manually branch from 803ac15 to 5eaf057 Compare June 19, 2025 16:23
@thiagohora thiagohora merged commit a14c54e into main Jun 19, 2025
12 checks passed
@thiagohora thiagohora deleted the thiagohora/OPIK-1764_add_endpoint_to_open_close_threads_manually branch June 19, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0