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

feat(subscriptions): Use RPC in subscriptions pipeline #6499

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

shruthilayaj
Copy link
Member

@shruthilayaj shruthilayaj commented Nov 4, 2024

Updates the subscription pipeline to support RPCSubscriptionData.

Copy link

codecov bot commented Nov 4, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2535 1 2534 5
View the top 1 failed tests by shortest run time
tests.subscriptions.test_subscription.TestEAPSpansRPCSubscriptionCreator::test[EAP spans RPC subscription]
Stack Traces | 0.184s run time
Traceback (most recent call last):
  File ".../tests/subscriptions/test_subscription.py", line 397, in test
    identifier = creator.create(subscription, self.timer)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../snuba/subscriptions/subscription.py", line 36, in create
    data.validate()
  File ".../snuba/subscriptions/data.py", line 189, in validate
    raise InvalidSubscriptionError("Multiple project IDs not supported.")
snuba.datasets.entity_subscriptions.validators.InvalidSubscriptionError: Multiple project IDs not supported.

To view more test analytics, go to the Test Analytics Dashboard
Got feedback? Let us know on Github

Comment on lines 370 to 373
rounded_ts = (
int(timestamp.replace(tzinfo=UTC).timestamp() / self.time_window_sec)
* self.time_window_sec
)
Copy link
Member Author

@shruthilayaj shruthilayaj Nov 8, 2024

Choose a reason for hiding this comment

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

hack for now, we want to round this to the lowest available granularity (15s) more context here

Comment on lines 348 to 353
if (self.request_name, self.request_version) not in REQUEST_TYPE_ALLOWLIST:
raise InvalidSubscriptionError(
f"{self.request_name} {self.request_version} not supported."
)

# TODO: Validate no group by, having, order by etc
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add more validation in a follow up so it's easier to review

@shruthilayaj shruthilayaj marked this pull request as ready for review November 8, 2024 21:29
@shruthilayaj shruthilayaj requested review from a team as code owners November 8, 2024 21:29
Copy link
Member

@volokluev volokluev left a comment

Choose a reason for hiding this comment

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

Why can the create subscription RPC call not be its own PR?

@shruthilayaj
Copy link
Member Author

shruthilayaj commented Nov 8, 2024

Why can the create subscription RPC call not be its own PR?

@volokluev Creating a subscription requires validation, so I needed to build and run the request before storing it. That introduces the RPCSubscriptionData class. And basically once I introduced it in one place, I kinda had to follow all the typing issues and handle it everywhere.

@shruthilayaj shruthilayaj changed the base branch from master to shruthi/feat/create-rpc-subscriptions November 18, 2024 16:56
@shruthilayaj shruthilayaj changed the title feat(subscriptions): Add create subscriptions RPC feat(subscriptions): Use RPC in subscriptions pipeline Nov 18, 2024
Base automatically changed from shruthi/feat/create-rpc-subscriptions to master November 20, 2024 18:43
@@ -95,7 +104,7 @@ def from_string(cls, value: str) -> SubscriptionIdentifier:


@dataclass(frozen=True, kw_only=True)
class SubscriptionData(ABC):
class _SubscriptionData(ABC, Generic[TRequest]):
Copy link
Member Author

Choose a reason for hiding this comment

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

build_request returns generic type TRequest and run_query accepts TRequest.
So for SnQLSubscriptionData, build_request returns Request and run_query accepts Request
and for RPCSubscriptionData, build_request returns TimeSeriesRequest and run_query accepts TimeSeriesRequest

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