-
Notifications
You must be signed in to change notification settings - Fork 731
feat(git-integration): add metrics to service executions #3517
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| -- Down migration: Remove metrics column and index from serviceExecutions table | ||
|
|
||
| -- Drop index first | ||
| DROP INDEX IF EXISTS git."idx_serviceExecutions_metrics"; | ||
|
|
||
| -- Drop column | ||
| ALTER TABLE git."serviceExecutions" | ||
| DROP COLUMN IF EXISTS metrics; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- Add metrics column to serviceExecutions table for storing service-specific execution metrics | ||
| -- Examples: ai_cost for maintainer service, total_commits/bad_commits/total_activities for commit service | ||
|
|
||
| ALTER TABLE git."serviceExecutions" | ||
| ADD COLUMN metrics JSONB DEFAULT '{}'::jsonb; | ||
|
|
||
| -- Create GIN index for efficient querying within JSONB data | ||
| CREATE INDEX IF NOT EXISTS "idx_serviceExecutions_metrics" | ||
| ON git."serviceExecutions" USING gin (metrics); | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -439,6 +439,8 @@ async def process_maintainers( | |||||||||||
| error_code = None | ||||||||||||
| error_message = None | ||||||||||||
| latest_maintainer_file = None | ||||||||||||
| ai_cost = 0.0 | ||||||||||||
| maintainers_found = 0 | ||||||||||||
|
|
||||||||||||
| try: | ||||||||||||
| owner, repo_name = parse_repo_url(batch_info.remote) | ||||||||||||
|
|
@@ -454,8 +456,10 @@ async def process_maintainers( | |||||||||||
| self.logger.info(f"Starting maintainers processing for repo: {batch_info.remote}") | ||||||||||||
| maintainers = await self.extract_maintainers(batch_info.repo_path, owner, repo_name) | ||||||||||||
| latest_maintainer_file = maintainers.maintainer_file | ||||||||||||
| ai_cost = maintainers.total_cost | ||||||||||||
| maintainers_found = len(maintainers.maintainer_info) | ||||||||||||
| self.logger.info( | ||||||||||||
| f"Extracted {len(maintainers.maintainer_info)} maintainers from {latest_maintainer_file} file" | ||||||||||||
| f"Extracted {maintainers_found} maintainers from {latest_maintainer_file} file" | ||||||||||||
| ) | ||||||||||||
| await self.save_maintainers( | ||||||||||||
| repository.id, | ||||||||||||
|
|
@@ -469,6 +473,9 @@ async def process_maintainers( | |||||||||||
| error_code = ( | ||||||||||||
| e.error_code.value if isinstance(e, CrowdGitError) else ErrorCode.UNKNOWN.value | ||||||||||||
| ) | ||||||||||||
| # Capture AI cost even on error if it's a CrowdGitError with ai_cost | ||||||||||||
| if isinstance(e, CrowdGitError) and hasattr(e, "ai_cost"): | ||||||||||||
|
Comment on lines
+476
to
+477
|
||||||||||||
| # Capture AI cost even on error if it's a CrowdGitError with ai_cost | |
| if isinstance(e, CrowdGitError) and hasattr(e, "ai_cost"): | |
| # Capture AI cost even on error if it's a CrowdGitError that implements the AICostCarrier protocol. | |
| # See: crowdgit.errors.AICostCarrier | |
| if isinstance(e, CrowdGitError) and isinstance(e, getattr(__import__("crowdgit.errors", fromlist=["AICostCarrier"]), "AICostCarrier", ())): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
orjson.dumps()call will return bytes, but PostgreSQL JSONB columns expect JSON text or can accept the dict directly. Since themetricsparameter in the INSERT query ($7) is passed as a string after.decode(), PostgreSQL will need to parse it. Consider passingself.metricsdirectly as a dict instead of serializing it, which allows the database driver to handle JSON serialization natively and is more efficient.