8000 [OPIK-1853] Workspace daily metrics endpoint by BorisTkachenko · Pull Request #2505 · comet-ml/opik · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[OPIK-1853] Workspace daily metrics endpoint #2505

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

BorisTkachenko
Copy link
Contributor

Details

Workspace daily metrics endpoint

Testing

Integration tests

Documentation

https://www.notion.so/cometml/Home-Page-Tech-HLD-2097124010a380d098cfc0b378819713#20d7124010a380918a83ddb12a2494ad

@BorisTkachenko BorisTkachenko self-assigned this Jun 18, 2025
@BorisTkachenko BorisTkachenko requested a review from a team as a code owner June 18, 2025 09:29
Copy link
8000 Contributor
github-actions bot commented Jun 18, 2025

Backend Tests Results

  175 files  + 3    175 suites  +3   18m 0s ⏱️ + 1m 33s
3 833 tests +12  3 830 ✅ +15  3 💤 ±0  0 ❌ ±0 
3 825 runs  + 7  3 822 ✅ + 7  3 💤 ±0  0 ❌ ±0 

Results for commit 0783275. ± Comparison against base commit 86e4ae3.

This pull request removes 7 and adds 19 tests. Note that renamed tests count towards both.
com.comet.opik.api.resources.v1.priv.FeedbackDefinitionResourceTest ‑ Unknown test
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ emptyData(boolean)[1]
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ emptyData(boolean)[2]
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ happyPath(boolean)[1]
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ happyPath(boolean)[2]
com.comet.opik.infrastructure.bi.DailyUsageReportJobTest$CredentialsEnabledScenario ‑ Unknown test
com.comet.opik.infrastructure.http.cors.CorsDisabledE2ETest ‑ Unknown test
com.comet.opik.api.resources.v1.jobs.TraceThreadsClosingJobTest$TraceThreadsClosingJob ‑ shouldCloseTraceThreadsForProject(TraceThreadService)
com.comet.opik.api.resources.v1.jobs.TraceThreadsClosingJobTest$TraceThreadsClosingJob ‑ shouldReopenTraceThreadsIfNewTracesAreAdded(TraceThreadService)
com.comet.opik.api.resources.v1.priv.TracesResourceTest$FindTraces ‑ getTracesByProject__whenSortingByValidFields__thenReturnTracesSorted(Comparator, SortingField)[23]
com.comet.opik.api.resources.v1.priv.TracesResourceTest$FindTraces ‑ getTracesByProject__whenSortingByValidFields__thenReturnTracesSorted(Comparator, SortingField)[24]
com.comet.opik.api.resources.v1.priv.TracesResourceTest$FindTraces ‑ getTracesByProject__whenSortingByValidFields__thenReturnTracesSorted(Comparator, SortingField)[25]
com.comet.opik.api.resources.v1.priv.TracesResourceTest$FindTraces ‑ getTracesByProject__whenSortingByValidFields__thenReturnTracesSorted(Comparator, SortingField)[26]
com.comet.opik.api.resources.v1.priv.TracesResourceTest$TraceThreadManualOpenClose ‑ manualCloseAndReopeningTraceThread(TraceThreadService)
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ metricsDaily_emptyData(boolean)[1]
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ metricsDaily_emptyData(boolean)[2]
com.comet.opik.api.resources.v1.priv.WorkspacesResourceTest$FeedbackScoresTest ‑ metricsDaily_happyPath(boolean)[1]
…

♻️ This comment has been updated with latest results.

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

SDK E2E Tests Results

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

Results for commit 58dcd25. ± Comparison against base commit 0cc62ca.

♻️ This comment has been updated with latest results.

@BorisTkachenko BorisTkachenko force-pushed the boryst/OPIK-1853-be-get-workspace-metrics-endpoint branch from 58dcd25 to d8a3833 Compare June 18, 2025 10:35
Copy link
Collaborator
@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

Let's use the ID for the range queries.

I will give a more proper review later as I wanted to publish this comment ASAP first.

@BorisTkachenko BorisTkachenko requested a review from andrescrz June 20, 2025 11:33
Copy link
Collaborator
@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

The approach generally LGTM. There are just some final details to polish, mostly related to the new library adoption, which is important to get right the first time.

Kudos for taking advantage of our UUID v7 for range filtering for the first time, as it's something that we should use heavily when needed.

@BorisTkachenko BorisTkachenko requested a review from andrescrz June 23, 2025 07:09

@Override
public UUID getTimeOrderedEpoch(long rawTimestamp) {
return generator.construct(rawTimestamp);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@BorisTkachenko have you tested this? I don't believe this is correct from the logical perspective:

A quick test of this:

    public static void main(String[] args) {
        var generator = Generators.timeBasedEpochGenerator();
        var now = Instant.now();
        for (int i = 0; i < 10; i++) {
            var id = generator.construct(now.toEpochMilli());
            System.out.println(id);
        }
    }

Results in:

01979bdc-da28-7d27-a410-e9945a5fa36f
01979bdc-da28-7d27-a410-e9945a5fa370
01979bdc-da28-7d27-a410-e9945a5fa371
01979bdc-da28-7d27-a410-e9945a5fa372
01979bdc-da28-7d27-a410-e9945a5fa373
01979bdc-da28-7d27-a410-e9945a5fa374
01979bdc-da28-7d27-a410-e9945a5fa375
01979bdc-da28-7d27-a410-e9945a5fa376
01979bdc-da28-7d27-a410-e9945a5fa377
01979bdc-da28-7d27-a410-e9945a5fa378

So basically you generate an UUID for the given timestamp for the 1st 48 bits (correct), but the the other 74 are random (incorrect):

What you actually want is the first (or last) UUID for a given timestamp, so you can search an ID in a range for a given time period.

With this implementation, you basically depend on luck/timing to get correct results.

Copy link
Collaborator
@andrescrz andrescrz Jun 23, 2025

Choose a reason for hiding this comment

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

We discussed that the first 32 bits give second precision, plus the next 12 provide millis precision. Then, depending on the random generator for the final 74, there can be even higher precision (micro or nano).

Given that this is uses lexicographically sorting combined with the BETWEEN clause for in the ClickHouse WHERE SQL statement, and given that aggregations are daily, in the case of any IDs not found, they would be completely neglectable.

They would be probably even neglectable with smaller aggregations, as millis or even less precision is very small.

So this is good to go as it is.

@BorisTkachenko BorisTkachenko merged commit f287992 into main Jun 23, 2025
12 checks passed
@BorisTkachenko BorisTkachenko deleted the boryst/OPIK-1853-be-get-workspace-metrics-endpoint branch June 23, 2025 11:38
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.

4 participants
0