Skip to content

Add GetExecutionStats endpoint to count executions from the last 7 days with status breakdowns #229

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

Merged
merged 6 commits into from
May 12, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented May 11, 2025

Add GetExecutionStats Endpoint

This PR adds a new endpoint to count executions from the last 7 days with status breakdowns and average execution time.

Changes

  • Added new GetExecutionStats RPC method to the Aggregator service
  • Implemented request and response messages for the new endpoint
  • Added server-side handler in the Engine struct to filter executions by date and count by status
  • Added average execution time calculation for executions within the specified time range
  • Updated RPC server to expose the new endpoint with API key authentication

How to Call the Endpoint

First, create an API key with admin role:

docker exec -it base-aggregator-1 /ava create-api-key --role="admin" --subject=apikey

Then use the API key in your client code:

// Client-side code example
client := avsproto.NewAggregatorClient(conn)
// Set up authentication with the API key
ctx := metadata.AppendToOutgoingContext(context.Background(), "authkey", "YOUR_API_KEY")

resp, err := client.GetExecutionStats(ctx, &avsproto.GetExecutionStatsReq{
    WorkflowIds: []string{}, // Empty array to count all executions for the entire program
    Days: 7, // Number of days to look back (default: 7)
})
if err != nil {
    log.Fatalf("Error calling GetExecutionStats: %v", err)
}
fmt.Printf("Total executions: %d\n", resp.Total)
fmt.Printf("Successful executions: %d\n", resp.Succeeded)
fmt.Printf("Failed executions: %d\n", resp.Failed)
fmt.Printf("Average execution time: %.2f ms\n", resp.AvgExecutionTime)

Testing

The implementation follows the existing patterns in the codebase and should pass all linting checks.

Link to Devin run: https://app.devin.ai/sessions/a73bc9315323484b8daf567302a18099
Requested by: Chris Li (chris@avaprotocol.org)

…ys with status breakdowns

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates a new GetExecutionStats endpoint into the Aggregator service to provide execution statistics (total, succeeded, failed counts, and average execution time) from the last 7 days. It includes updates in the protobuf definitions and generated files, the Engine implementation, and the RPC server routing for the new endpoint.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
protobuf/node_grpc.pb.go Updated the reference to use wrappers instead of wrapperspb for the Ack method.
protobuf/node.proto Modified the source and import paths within the proto file.
protobuf/node.pb.go Updated timestamp and wrapper types as per the updated proto definitions.
protobuf/avs_grpc.pb.go Updated wrapper references and introduced the new GetExecutionStats RPC method.
protobuf/avs.proto Added definitions for GetExecutionStatsReq and GetExecutionStatsResp messages and method.
core/taskengine/engine.go Added GetExecutionStats method to calculate execution stats from recent executions.
aggregator/rpc_server.go Added the GetExecutionStats endpoint handler with authentication and logging support.

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>
@chrisli30 chrisli30 merged commit 7b0cb48 into staging May 12, 2025
27 checks passed
@chrisli30 chrisli30 deleted the devin/1747006114-execution-stats branch May 12, 2025 04:45
chrisli30 added a commit that referenced this pull request May 14, 2025
…ys with status breakdowns (#229)

* Add GetExecutionStats endpoint to count executions from the last 7 days with status breakdowns

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* Add average execution time to GetExecutionStats endpoint

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* style: Automated gofmt

Formatted Go code using gofmt.

* chore: Regenerate protobuf code for GetExecutionStats endpoint

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* fix: Update node.proto import path and regenerate protobuf code

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* refactor: Replace magic number with TaskIDLength constant

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Chris Li <chris.li.2046@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
chrisli30 added a commit that referenced this pull request May 21, 2025
…ys with status breakdowns (#229)

* Add GetExecutionStats endpoint to count executions from the last 7 days with status breakdowns

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* Add average execution time to GetExecutionStats endpoint

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* style: Automated gofmt

Formatted Go code using gofmt.

* chore: Regenerate protobuf code for GetExecutionStats endpoint

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* fix: Update node.proto import path and regenerate protobuf code

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

* refactor: Replace magic number with TaskIDLength constant

Co-Authored-By: Chris Li <chris.li.2046@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Chris Li <chris.li.2046@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

1 participant