feat(billing): Add BillingService base class and service method decorator#109376
Merged
feat(billing): Add BillingService base class and service method decorator#109376
Conversation
…ator Implement core primitives for the new billing platform. This establishes the foundation for service-oriented architecture where billing services communicate through well-defined protobuf interfaces. Key components: - BillingService: Base class for all billing services with uniform construction (no __init__ arguments) - @service_method: Decorator providing observability, type validation, and structured logging for service methods - Comprehensive tests demonstrating usage patterns The implementation follows principles from INTENTION.md: - Services have no __init__ arguments for uniformity - All interfaces use protobuf messages for strong typing - Service methods automatically log start/success/error with timing - Services will eventually delegate to external RPC endpoints Co-Authored-By: Claude <noreply@anthropic.com>
volokluev
commented
Feb 25, 2026
volokluev
commented
Feb 25, 2026
| @@ -0,0 +1,3 @@ | |||
| from .service import BillingService, service_method | |||
volokluev
commented
Feb 25, 2026
- Add metrics tracking for service method calls, success, errors, and duration - Fix relative imports in __init__.py to use absolute imports - Simplify tests from 15 to 6, removing redundant test cases while maintaining full coverage of essential behavior Co-Authored-By: Claude <noreply@anthropic.com>
Consolidated three READMEs to eliminate repeated information: - platform/README.md: High-level overview and quick start - core/README.md: Focus on @service_method decorator features - services/README.md: Service boundaries and structure guidelines Removed duplicate examples, testing info, and future direction sections. Co-Authored-By: Claude <noreply@anthropic.com>
Add type: ignore comments to tests that intentionally pass invalid types to verify runtime validation. These are expected TypeErrors that mypy should not flag. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
noahsmartin
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Stuff
This code was generated using the file in
src/sentry/billing/platform/INTENTION.md. This is meant as a starting point for us to build from. No existing logic is modified, the services do not exist yet.I checked over the implementation of the base class and tests and it seems sane to me.
Reviewer task
If yes, click approve
Robot Stuff
Implement core primitives for the new billing platform to establish the foundation for service-oriented architecture where billing services communicate through well-defined protobuf interfaces.
What's included
This PR adds:
BillingServicebase class: Foundation for all billing services with uniform construction (no__init__arguments)@service_methoddecorator: Provides observability, type validation, and structured logging for service methodsWhy these changes
The existing billing code in
getsentry/services/billinghas grown into a spaghetti codebase. This PR starts the rewrite by establishing well-defined service boundaries and interfaces.Following the principles in
INTENTION.md:__init__arguments)Architecture
The folder structure enforces separation:
core/- Contains core primitives, no application logicservices/- Each service in its own directory, no cross-service importsServices communicate exclusively through the
BillingServiceabstraction, making it straightforward to later move implementations to external services.Next steps
Future PRs will: