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

fix(warehouse): added support for filtering on the uploads and calculating aborted events for task_run_id #2975

Merged
merged 3 commits into from
Mar 13, 2023

Conversation

abhimanyubabbar
Copy link
Contributor

@abhimanyubabbar abhimanyubabbar commented Feb 14, 2023

Description

The PR augments the capability of repo to count over wh_uploads using generic filters which gets used in the pending events API when calculating pending events and aborted events.

Notion Ticket

https://www.notion.so/rudderstacks/Fix-the-Pending-Events-API-to-return-always-if-the-events-have-been-aborted-in-a-boolean-flag-e251b60a20484513ad802fe4ed50d790

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@abhimanyubabbar abhimanyubabbar changed the title added support for filtering on the uploads and calculating aborted ev… fix(warehouse): added support for filtering on the uploads and calculating aborted events for task_run_id Feb 14, 2023
Comment on lines 1200 to 1201
if sourceID == "" || taskRunID == "" {
pkgLogger.Errorf("[WH]: pending-events: Empty source_id or task_run_id ")
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'll make sure we have task_run_id coming always in pending events api

@abhimanyubabbar abhimanyubabbar marked this pull request as ready for review February 14, 2023 19:51

var count int64
if err := uploads.db.QueryRowContext(ctx, query, args...).Scan(&count); err != nil {
return 0, fmt.Errorf("scanning count into local variable: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return 0, fmt.Errorf("scanning count into local variable: %w", err)
return 0, fmt.Errorf("count uploads: %w", err)

The error seems to be misleading w.r.t. local variable. Can we update it?

if sourceID == "" {
pkgLogger.Errorf("[WH]: pending-events: Empty source id")
if sourceID == "" || taskRunID == "" {
pkgLogger.Errorf("[WH]: pending-events: Empty source_id or task_run_id ")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it a structured log? Also, should we make this warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why a warning and not error ?

Copy link
Member

Choose a reason for hiding this comment

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

Since the error is not causing our application to be in trouble or involving us in the investigation immediately. Also, since these APIs are being polled continuously by the extract, we might see too much noise as well.
I thought it was okay to mark them as a warning.


if err != nil {
err := fmt.Errorf("getting pending uploads count: %v", err)
pkgLogger.Errorf("[WH]: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it a structured log? Also, should we make this warning?

if err != nil {
err := fmt.Errorf("error getting pending uploads : %v", err)
err := fmt.Errorf("getting aborted uploads count : %v", err)
pkgLogger.Errorf("[WH]: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it a structured log? Also, should we make this warning?

@codecov
Copy link

codecov bot commented Feb 14, 2023

Codecov Report

Patch coverage: 29.16% and project coverage change: -0.69 ⚠️

Comparison is base (f2e99c7) 53.62% compared to head (6e5e3c0) 52.93%.

❗ Current head 6e5e3c0 differs from pull request most recent head 7a0e740. Consider uploading reports for the commit 7a0e740 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2975      +/-   ##
==========================================
- Coverage   53.62%   52.93%   -0.69%     
==========================================
  Files         347      334      -13     
  Lines       53806    51879    -1927     
==========================================
- Hits        28853    27464    -1389     
+ Misses      23320    22808     -512     
+ Partials     1633     1607      -26     
Impacted Files Coverage Δ
warehouse/utils/utils.go 70.07% <ø> (-2.97%) ⬇️
warehouse/warehouse.go 11.64% <0.00%> (-0.14%) ⬇️
warehouse/internal/repo/upload.go 82.36% <82.35%> (-1.04%) ⬇️

... and 92 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

if pendingEventsReq.TaskRunID != "" {
filterBy = append(filterBy, warehouseutils.FilterBy{Key: "metadata->>'source_task_run_id'", Value: pendingEventsReq.TaskRunID})
filters := []repo.FilterBy{
{Key: "source_id", Value: sourceID},
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we defined the table columns as constants? Maybe it would be safer to use constants.

@abhimanyubabbar abhimanyubabbar force-pushed the fix.pending-events-aborted-boolean branch from b9f1b56 to 6e5e3c0 Compare February 23, 2023 06:37
@abhimanyubabbar abhimanyubabbar force-pushed the fix.pending-events-aborted-boolean branch from e04bd7d to 757edf4 Compare March 13, 2023 12:58
@abhimanyubabbar abhimanyubabbar merged commit 8ab58b8 into master Mar 13, 2023
@github-actions github-actions bot deleted the fix.pending-events-aborted-boolean branch May 14, 2023 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants