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

Add InstanceUtilization type and resolver for application instances u… #114

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

rbjornstad
Copy link
Contributor

…tilization

@rbjornstad rbjornstad requested a review from a team as a code owner March 18, 2025 10:44
@rbjornstad rbjornstad requested a review from Copilot March 18, 2025 10:44
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 adds support for querying instance utilization for application instances by introducing a new InstanceUtilization type and resolver.

  • Added ApplicationInstanceResolver interface and its implementation in the auto‐generated GraphQL resolver file.
  • Extended GraphQL schema definitions for ApplicationInstance and InstanceUtilization types.
  • Added or updated query functions and resolvers to calculate CPU/memory usage for instances.

Reviewed Changes

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

Show a summary per file
File Description
internal/graph/gengql/generated.go Added ApplicationInstanceResolver interface, new complexity functions, and field contexts.
internal/utilization/model.go Introduced the InstanceUtilization model with a Current field.
internal/graph/utilization.resolvers.go Added the InstanceUtilization resolver for application instances.
internal/graph/applications.resolvers.go Registered the new ApplicationInstance resolver.
internal/utilization/queries.go Updated query functions and constants to support instance CPU/memory utilization.
Comments suppressed due to low confidence (2)

internal/utilization/queries.go:49

  • [nitpick] Verify that the order of arguments (teamSlug, workloadName, instanceName) correctly matches the expected placeholders (namespace, container, pod) in the usage query string for clarity.
current, err := c.query(ctx, env, fmt.Sprintf(usageQ, teamSlug, workloadName, instanceName))

internal/graph/gengql/generated.go:2400

  • [nitpick] Consider adding tests for the new ApplicationInstance.InstanceUtilization resolver to ensure correct behavior and error handling across various scenarios.
}

Comment on lines +3212 to +3213
return e.complexity.ApplicationInstance.InstanceUtilization(childComplexity, args["resourceType"].(utilization.UtilizationResourceType)), true

Copy link
Preview

Copilot AI Mar 18, 2025

Choose a reason for hiding this comment

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

Consider adding a type check or error handling before the type assertion on args["resourceType"] to prevent a potential panic if the argument value is not of the expected type.

Suggested change
return e.complexity.ApplicationInstance.InstanceUtilization(childComplexity, args["resourceType"].(utilization.UtilizationResourceType)), true
resourceType, ok := args["resourceType"].(utilization.UtilizationResourceType)
if !ok {
return 0, false
}
return e.complexity.ApplicationInstance.InstanceUtilization(childComplexity, resourceType), true

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
…ity and consistency in utilization queries and resolvers
@rbjornstad rbjornstad requested a review from thokra-nav March 18, 2025 12:02
@rbjornstad rbjornstad merged commit 4238557 into main Mar 18, 2025
2 checks passed
@rbjornstad rbjornstad deleted the instance_usage branch March 18, 2025 12:12
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