utilization

package
v0.0.0-...-804a087 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewLoaderContext

func NewLoaderContext(ctx context.Context, client ResourceUsageClient) context.Context

func WorkloadResourceLimit

func WorkloadResourceLimit(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (*float64, error)

func WorkloadResourceRequest

func WorkloadResourceRequest(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (float64, error)

func WorkloadResourceUsage

func WorkloadResourceUsage(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType) (float64, error)

Types

type ApplicationInstanceUtilization

type ApplicationInstanceUtilization struct {
	// Get the current usage for the requested resource type.
	Current float64 `json:"current"`
}

func ForInstance

func ForInstance(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, instanceName string, resourceType UtilizationResourceType) (*ApplicationInstanceUtilization, error)

type ResourceUsageClient

type ResourceUsageClient interface {
	Query(ctx context.Context, environment string, query string, opts ...promclient.QueryOption) (prom.Vector, error)
	QueryAll(ctx context.Context, query string, opts ...promclient.QueryOption) (map[string]prom.Vector, error)
	QueryRange(ctx context.Context, environment string, query string, promRange promv1.Range) (prom.Value, promv1.Warnings, error)
}

type TeamServiceUtilization

type TeamServiceUtilization struct {
	TeamSlug slug.Slug `json:"-"`
}

type TeamUtilization

type TeamUtilization struct {
	TeamSlug slug.Slug `json:"-"`
}

type TeamUtilizationData

type TeamUtilizationData struct {
	Requested       float64   `json:"requested"`
	Used            float64   `json:"used"`
	EnvironmentName string    `json:"-"`
	TeamSlug        slug.Slug `json:"-"`
}

func ForTeams

func ForTeams(ctx context.Context, resourceType UtilizationResourceType) ([]*TeamUtilizationData, error)

type UtilizationResourceType

type UtilizationResourceType string

Resource type.

const (
	UtilizationResourceTypeCPU    UtilizationResourceType = "CPU"
	UtilizationResourceTypeMemory UtilizationResourceType = "MEMORY"
)

func (UtilizationResourceType) IsValid

func (e UtilizationResourceType) IsValid() bool

func (UtilizationResourceType) MarshalGQL

func (e UtilizationResourceType) MarshalGQL(w io.Writer)

func (UtilizationResourceType) String

func (e UtilizationResourceType) String() string

func (*UtilizationResourceType) UnmarshalGQL

func (e *UtilizationResourceType) UnmarshalGQL(v interface{}) error

type UtilizationSample

type UtilizationSample struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
	Instance  string    `json:"instance"`
}

func WorkloadResourceLimitRange

func WorkloadResourceLimitRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

func WorkloadResourceRequestRange

func WorkloadResourceRequestRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

func WorkloadResourceUsageRange

func WorkloadResourceUsageRange(ctx context.Context, env string, teamSlug slug.Slug, workloadName string, resourceType UtilizationResourceType, start time.Time, end time.Time, step int) ([]*UtilizationSample, error)

type WorkloadType

type WorkloadType int
const (
	WorkloadTypeApplication WorkloadType = iota
	WorkloadTypeJob
)

type WorkloadUtilization

type WorkloadUtilization struct {
	EnvironmentName string       `json:"-"`
	WorkloadName    string       `json:"-"`
	TeamSlug        slug.Slug    `json:"-"`
	WorkloadType    WorkloadType `json:"-"`
}

type WorkloadUtilizationData

type WorkloadUtilizationData struct {
	Requested float64 `json:"requested"`
	Used      float64 `json:"used"`

	TeamSlug        slug.Slug `json:"-"`
	EnvironmentName string    `json:"-"`
	WorkloadName    string    `json:"-"`
}

func ForTeam

func ForTeam(ctx context.Context, teamSlug slug.Slug, resourceType UtilizationResourceType) ([]*WorkloadUtilizationData, error)

type WorkloadUtilizationRecommendations

type WorkloadUtilizationRecommendations struct {
	CPURequestCores    float64 `json:"cpuRequest"`
	MemoryRequestBytes int64   `json:"memoryRequest"`
	MemoryLimitBytes   int64   `json:"memoryLimit"`
}

func WorkloadResourceRecommendations

func WorkloadResourceRecommendations(ctx context.Context, env string, teamSlug slug.Slug, workloadName string) (*WorkloadUtilizationRecommendations, error)

type WorkloadUtilizationSeriesInput

type WorkloadUtilizationSeriesInput struct {
	Start        time.Time               `json:"start"`
	End          time.Time               `json:"end"`
	ResourceType UtilizationResourceType `json:"resourceType"`
}

func (*WorkloadUtilizationSeriesInput) Step

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL