cost

package
v0.0.0-...-6be7acf Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OnDemandEC2CostKey               = bsonutil.MustHaveTag(Cost{}, "OnDemandEC2Cost")
	AdjustedEC2CostKey               = bsonutil.MustHaveTag(Cost{}, "AdjustedEC2Cost")
	OnDemandEBSThroughputCostKey     = bsonutil.MustHaveTag(Cost{}, "OnDemandEBSThroughputCost")
	AdjustedEBSThroughputCostKey     = bsonutil.MustHaveTag(Cost{}, "AdjustedEBSThroughputCost")
	OnDemandEBSStorageCostKey        = bsonutil.MustHaveTag(Cost{}, "OnDemandEBSStorageCost")
	AdjustedEBSStorageCostKey        = bsonutil.MustHaveTag(Cost{}, "AdjustedEBSStorageCost")
	OnDemandS3ArtifactPutCostKey     = bsonutil.MustHaveTag(Cost{}, "OnDemandS3ArtifactPutCost")
	AdjustedS3ArtifactPutCostKey     = bsonutil.MustHaveTag(Cost{}, "AdjustedS3ArtifactPutCost")
	OnDemandS3LogPutCostKey          = bsonutil.MustHaveTag(Cost{}, "OnDemandS3LogPutCost")
	AdjustedS3LogPutCostKey          = bsonutil.MustHaveTag(Cost{}, "AdjustedS3LogPutCost")
	OnDemandS3ArtifactStorageCostKey = bsonutil.MustHaveTag(Cost{}, "OnDemandS3ArtifactStorageCost")
	AdjustedS3ArtifactStorageCostKey = bsonutil.MustHaveTag(Cost{}, "AdjustedS3ArtifactStorageCost")
	OnDemandS3LogStorageCostKey      = bsonutil.MustHaveTag(Cost{}, "OnDemandS3LogStorageCost")
	AdjustedS3LogStorageCostKey      = bsonutil.MustHaveTag(Cost{}, "AdjustedS3LogStorageCost")
)

Functions

func RoundCost

func RoundCost(v float64) float64

RoundCost rounds v to 2 decimal places for values >= $0.10, or 2 significant figures below that threshold.

func SumPerChildVersionAdjustedTotals

func SumPerChildVersionAdjustedTotals(n int, childAt func(int) (actual, predicted *Cost)) (sumActual, sumPred float64)

SumPerChildVersionAdjustedTotals sums actual and predicted adjusted costs across n children.

Types

type Cost

type Cost struct {
	// Total is the sum of adjusted cost components.
	Total float64 `bson:"-" json:"total,omitempty"`
	// OnDemandEC2Cost is the cost calculated using only on-demand rates.
	OnDemandEC2Cost float64 `bson:"on_demand_ec2_cost,omitempty" json:"on_demand_ec2_cost,omitempty"`
	// AdjustedEC2Cost is the cost calculated using the finance formula with savings plan and on-demand components.
	AdjustedEC2Cost float64 `bson:"adjusted_ec2_cost,omitempty" json:"adjusted_ec2_cost,omitempty"`
	// OnDemandEBSThroughputCost is the cost of EBS GP3 throughput calculated using on-demand rates.
	OnDemandEBSThroughputCost float64 `bson:"on_demand_ebs_throughput_cost,omitempty" json:"-"`
	// AdjustedEBSThroughputCost is the adjusted cost of EBS GP3 throughput with discount applied.
	AdjustedEBSThroughputCost float64 `bson:"adjusted_ebs_throughput_cost,omitempty" json:"adjusted_ebs_throughput_cost"`
	// OnDemandEBSStorageCost is the cost of EBS storage calculated using on-demand rates.
	OnDemandEBSStorageCost float64 `bson:"on_demand_ebs_storage_cost,omitempty" json:"-"`
	// AdjustedEBSStorageCost is the adjusted cost of EBS storage (GP3/GP2) with discount applied.
	AdjustedEBSStorageCost float64 `bson:"adjusted_ebs_storage_cost,omitempty" json:"adjusted_ebs_storage_cost"`
	// OnDemandS3ArtifactPutCost is the standard (non-discounted) S3 PUT request cost for uploading user artifacts.
	OnDemandS3ArtifactPutCost float64 `bson:"on_demand_s3_artifact_put_cost,omitempty" json:"-"`
	// AdjustedS3ArtifactPutCost is the adjusted (discounted) S3 PUT request cost for uploading user artifacts.
	AdjustedS3ArtifactPutCost float64 `bson:"adjusted_s3_artifact_put_cost,omitempty" json:"adjusted_s3_artifact_put_cost,omitempty"`
	// OnDemandS3LogPutCost is the standard (non-discounted) S3 PUT request cost for uploading task log chunks.
	OnDemandS3LogPutCost float64 `bson:"on_demand_s3_log_put_cost,omitempty" json:"-"`
	// AdjustedS3LogPutCost is the adjusted (discounted) S3 PUT request cost for uploading task log chunks.
	AdjustedS3LogPutCost float64 `bson:"adjusted_s3_log_put_cost,omitempty" json:"adjusted_s3_log_put_cost,omitempty"`
	// OnDemandS3ArtifactStorageCost is the standard (non-discounted) S3 storage cost for artifact bytes over their retention period.
	OnDemandS3ArtifactStorageCost float64 `bson:"on_demand_s3_artifact_storage_cost,omitempty" json:"-"`
	// AdjustedS3ArtifactStorageCost is the adjusted (discounted) S3 storage cost for artifact bytes over their retention period.
	AdjustedS3ArtifactStorageCost float64 `bson:"adjusted_s3_artifact_storage_cost,omitempty" json:"adjusted_s3_artifact_storage_cost,omitempty"`
	// OnDemandS3LogStorageCost is the standard (non-discounted) S3 storage cost for log bytes over their retention period.
	OnDemandS3LogStorageCost float64 `bson:"on_demand_s3_log_storage_cost,omitempty" json:"-"`
	// AdjustedS3LogStorageCost is the adjusted (discounted) S3 storage cost for log bytes over their retention period.
	AdjustedS3LogStorageCost float64 `bson:"adjusted_s3_log_storage_cost,omitempty" json:"adjusted_s3_log_storage_cost,omitempty"`
	// ChildPatchesTotalCost is the total cost for child patches.
	ChildPatchesTotalCost float64 `bson:"-" json:"child_patches_total_cost,omitempty"`
}

Cost represents a cost breakdown for tasks and versions

func (Cost) AdjustedTotal

func (c Cost) AdjustedTotal() float64

AdjustedTotal returns the sum of the 7 base adjusted fields, excluding ChildPatchesTotalCost.

func (Cost) IsZero

func (c Cost) IsZero() bool

IsZero returns true if all cost components are zero.

func (Cost) RoundedBase

func (c Cost) RoundedBase() Cost

RoundedBase returns a new Cost with the 7 adjusted fields individually rounded.

Jump to

Keyboard shortcuts

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