Documentation
¶
Overview ¶
Package cost provides comprehensive cost analysis testing utilities for AWS service usage validation.
Index ¶
- func RunCostAnalysis(t *testing.T, testCases []CostTestCase)
- func TestCostOptimization(t *testing.T, baseline, optimized func(*CostAnalyzer))
- type CostAnalyzer
- func (ca *CostAnalyzer) GetCostReport() *CostReport
- func (ca *CostAnalyzer) TrackAPIGatewayRequest(dataTransferBytes int64)
- func (ca *CostAnalyzer) TrackDynamoDBOperation(operation string, consumedRCU, consumedWCU float64)
- func (ca *CostAnalyzer) TrackLambdaInvocation(duration time.Duration, memoryMB int)
- func (ca *CostAnalyzer) TrackS3Operation(operation string, sizeBytes int64)
- type CostBudgetAlert
- type CostConfig
- type CostEfficiencyMetric
- type CostMetricsCollector
- type CostReport
- type CostScenario
- type CostTestCase
- type MonthlyProjection
- type ServiceCostBreakdown
- type ServiceMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunCostAnalysis ¶
func RunCostAnalysis(t *testing.T, testCases []CostTestCase)
RunCostAnalysis runs cost analysis tests
func TestCostOptimization ¶
func TestCostOptimization(t *testing.T, baseline, optimized func(*CostAnalyzer))
TestCostOptimization tests cost optimization strategies
Types ¶
type CostAnalyzer ¶
type CostAnalyzer struct {
// contains filtered or unexported fields
}
CostAnalyzer analyzes AWS service costs
func NewCostAnalyzer ¶
func NewCostAnalyzer(config *CostConfig) *CostAnalyzer
NewCostAnalyzer creates a new cost analyzer
func (*CostAnalyzer) GetCostReport ¶
func (ca *CostAnalyzer) GetCostReport() *CostReport
GetCostReport generates a cost report
func (*CostAnalyzer) TrackAPIGatewayRequest ¶
func (ca *CostAnalyzer) TrackAPIGatewayRequest(dataTransferBytes int64)
TrackAPIGatewayRequest tracks API Gateway request cost
func (*CostAnalyzer) TrackDynamoDBOperation ¶
func (ca *CostAnalyzer) TrackDynamoDBOperation(operation string, consumedRCU, consumedWCU float64)
TrackDynamoDBOperation tracks DynamoDB operation cost
func (*CostAnalyzer) TrackLambdaInvocation ¶
func (ca *CostAnalyzer) TrackLambdaInvocation(duration time.Duration, memoryMB int)
TrackLambdaInvocation tracks Lambda invocation cost
func (*CostAnalyzer) TrackS3Operation ¶
func (ca *CostAnalyzer) TrackS3Operation(operation string, sizeBytes int64)
TrackS3Operation tracks S3 operation cost
type CostBudgetAlert ¶
type CostBudgetAlert struct {
Service string
CurrentCost float64
BudgetLimit float64
PercentUsed float64
AlertLevel string // "warning", "critical"
}
CostBudgetAlert checks if costs exceed budget
func CheckBudgets ¶
func CheckBudgets(report *CostReport, budgets map[string]float64) []CostBudgetAlert
CheckBudgets checks costs against budgets
type CostConfig ¶
type CostConfig struct {
// Lambda pricing (per million requests and per GB-second)
LambdaRequestCost float64 // per million requests
LambdaGBSecondCost float64 // per GB-second
// DynamoDB pricing
DynamoDBReadCost float64 // per RCU per hour
DynamoDBWriteCost float64 // per WCU per hour
DynamoDBStorageCost float64 // per GB per month
DynamoDBStreamCost float64 // per million read requests
// S3 pricing
S3StorageCost float64 // per GB per month
S3RequestCost float64 // per 1000 requests
S3TransferCost float64 // per GB
// API Gateway pricing
APIGatewayRequestCost float64 // per million requests
APIGatewayDataTransfer float64 // per GB
// CloudWatch pricing
CloudWatchLogsCost float64 // per GB ingested
CloudWatchMetricsCost float64 // per metric per month
}
CostConfig defines AWS service pricing
func DefaultCostConfig ¶
func DefaultCostConfig() *CostConfig
DefaultCostConfig returns default AWS pricing (US East 1)
type CostEfficiencyMetric ¶
type CostEfficiencyMetric struct {
Name string
Value float64
Unit string
Benchmark float64
IsEfficient bool
}
CostEfficiencyMetric represents a cost efficiency metric
func CalculateCostEfficiency ¶
func CalculateCostEfficiency(report *CostReport, operations int64) []CostEfficiencyMetric
CalculateCostEfficiency calculates cost efficiency metrics
type CostMetricsCollector ¶
type CostMetricsCollector struct {
// contains filtered or unexported fields
}
CostMetricsCollector collects cost metrics
type CostReport ¶
type CostReport struct {
Services map[string]*ServiceCostBreakdown
TotalCost float64
GeneratedAt time.Time
}
CostReport represents a cost analysis report
func SimulateCost ¶
func SimulateCost(scenario CostScenario, config *CostConfig) *CostReport
SimulateCost simulates costs for a scenario
type CostScenario ¶
type CostScenario struct {
Name string
UserCount int
RequestsPerUser int
DataPerUser int64 // bytes
Duration time.Duration
}
CostScenario simulates costs for different scenarios
type CostTestCase ¶
type CostTestCase struct {
Name string
Scenario func(*CostAnalyzer)
ExpectedMaxCost float64
ValidateFunc func(*testing.T, *CostReport)
}
CostTestCase defines a cost analysis test case
type MonthlyProjection ¶
type MonthlyProjection struct {
Service string
DailyOperations int64
AverageSize int64
ProjectedCost float64
}
MonthlyProjection projects monthly costs
func ProjectMonthlyCost ¶
func ProjectMonthlyCost(analyzer *CostAnalyzer, dailyMultiplier int) []MonthlyProjection
ProjectMonthlyCost projects monthly costs based on daily usage