Skip to content
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

api for uploading spans #302

Merged
merged 9 commits into from
Jan 8, 2025
Merged

api for uploading spans #302

merged 9 commits into from
Jan 8, 2025

Conversation

dinmukhamedm
Copy link
Member

@dinmukhamedm dinmukhamedm commented Jan 5, 2025

Important

Adds an API endpoint for uploading spans to a queue, updates server configuration, and modifies TypeScript route handling for optional fields.

  • API:
    • Adds push_to_queue function in queues.rs to handle POST requests to /queues/push.
    • Defines PushItem and PushToQueueRequest structs for deserializing request data.
    • Inserts spans into the database and pushes them to a labeling queue.
  • Server:
    • Registers push_to_queue service in main.rs under the /v1 scope.
  • TypeScript:
    • Updates remove/route.ts to handle optional action fields with null checks.

This description was created by Ellipsis for c0984e4. It will automatically update as commits are pushed.

app-server/src/api/v1/spans.rs Outdated Show resolved Hide resolved
@dinmukhamedm dinmukhamedm marked this pull request as ready for review January 6, 2025 12:33
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Reviewed everything up to 4db0162 in 54 seconds

More details
  • Looked at 195 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. app-server/src/api/v1/queues.rs:72
  • Draft comment:
    Using unwrap on serde_json::to_value can cause a panic if serialization fails. Consider handling this error gracefully.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    For TraceType::EVENT, this is an enum value which should always be serializable - there's no realistic way this serialization could fail. The unwrap() here is actually fine since we have strong guarantees about the input. While technically the comment is correct that unwrap() can panic, in this specific case the risk is theoretical rather than practical.
    I could be wrong about the enum serialization guarantees - there could be custom serialization implementations that could fail. Also, this establishes a pattern that could be problematic if copied elsewhere.
    Even with custom serialization, basic enum variants should always be serializable. The pattern concern is valid but should be raised as a broader architectural discussion rather than a PR comment.
    This comment should be removed as the unwrap() usage here is actually safe given the input is a simple enum variant that cannot fail to serialize.
2. app-server/src/api/v1/queues.rs:81
  • Draft comment:
    Using unwrap on serde_json::to_value can cause a panic if serialization fails. Consider handling this error gracefully.
  • Reason this comment was not posted:
    Marked as duplicate.
3. app-server/src/api/v1/queues.rs:104
  • Draft comment:
    span_id is of type Uuid which implements Copy, so clone() is unnecessary. You can use *span_id instead.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of clone on span_id in the map function is unnecessary since Uuid is Copy.
4. frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts:33
  • Draft comment:
    Good use of nonempty() to ensure addedLabels is not empty.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The nonempty() method ensures that the array is not empty, which is a good validation step.
5. frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts:73
  • Draft comment:
    Good use of optional chaining with action?.resultId to safely access resultId.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The optional chaining operator is used correctly to safely access properties of action.
6. frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts:122
  • Draft comment:
    Good use of optional chaining with action?.datasetId to safely access datasetId.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The optional chaining operator is used correctly to safely access properties of action.

Workflow ID: wflow_y21Plam4uXedb3YU


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

}

#[post("/queues/upload")]
async fn upload_to_queue(
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor nit, but I would say push is more fitting than upload

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on b5d08f7 in 38 seconds

More details
  • Looked at 52 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts:68
  • Draft comment:
    Consider using parameterized queries or a safer method for SQL string interpolation to prevent potential SQL injection vulnerabilities.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. frontend/app/api/projects/[projectId]/queues/[queueId]/remove/route.ts:75
  • Draft comment:
    Add null checks for action before accessing its properties to prevent potential runtime errors. This applies to other instances where action is accessed without checks.
  • Reason this comment was not posted:
    Comment was on unchanged code.
3. frontend/app/api/projects/[projectId]/queues/route.ts:15
  • Draft comment:
    Consider adding validation for the name field to ensure it is present and valid before proceeding with the database operation.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_SomIx4GX9J6Qci4Z


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@dinmukhamedm dinmukhamedm changed the title wip: api for uploading spans api for uploading spans Jan 7, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 10621ee in 14 seconds

More details
  • Looked at 29 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. app-server/src/api/v1/queues.rs:44
  • Draft comment:
    The endpoint has been changed from /queues/upload to /queues/push, but the PR description still mentions /queues/upload. Please update the description for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR changes the endpoint from /queues/upload to /queues/push, but the description still mentions /queues/upload. This inconsistency should be addressed.
2. app-server/src/main.rs:431
  • Draft comment:
    The function name has been changed from upload_to_queue to push_to_queue, but the PR description still mentions upload_to_queue. Please update the description for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR changes the function name from upload_to_queue to push_to_queue, but the description still mentions upload_to_queue. This inconsistency should be addressed.

Workflow ID: wflow_2JCzAcPFFH7f35BT


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.


#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct UploadItem {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should rename here and below too

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 2e20af5 in 18 seconds

More details
  • Looked at 32 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. app-server/src/api/v1/queues.rs:24
  • Draft comment:
    Renaming UploadItem to PushItem is consistent with the new endpoint name push_to_queue. This aligns with the intent of the PR.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The renaming of structs from UploadItem to PushItem and UploadToQueueRequest to PushToQueueRequest is consistent with the new endpoint name push_to_queue. This change is logical and aligns with the intent of the PR.
2. app-server/src/api/v1/queues.rs:40
  • Draft comment:
    Renaming UploadToQueueRequest to PushToQueueRequest is consistent with the new endpoint name push_to_queue. This aligns with the intent of the PR.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The renaming of structs from UploadItem to PushItem and UploadToQueueRequest to PushToQueueRequest is consistent with the new endpoint name push_to_queue. This change is logical and aligns with the intent of the PR.

Workflow ID: wflow_6w20SKJRlCoUnp60


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on c0984e4 in 1 minute and 17 seconds

More details
  • Looked at 41 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_0hngwbrtckcHuPC3


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@dinmukhamedm dinmukhamedm merged commit 859093d into dev Jan 8, 2025
3 checks passed
@dinmukhamedm dinmukhamedm deleted the spans-api branch January 8, 2025 11:20
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