cost

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamoDBPricing

type DynamoDBPricing = config.DynamoDBPricing

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine computes costs for recorded requests using configurable pricing.

func New

func New(requests dataplane.RequestReader, pricing PricingConfig) *Engine

New creates a cost Engine with the given request reader and pricing config.

func (*Engine) ByRoute

func (e *Engine) ByRoute(ctx context.Context, limit int) ([]RouteCost, error)

ByRoute returns costs aggregated by service+method+path, sorted by TotalCost descending.

func (*Engine) ByService

func (e *Engine) ByService(ctx context.Context) ([]ServiceCost, error)

ByService returns costs aggregated by service, sorted by TotalCost descending.

func (*Engine) ByTenant

func (e *Engine) ByTenant(ctx context.Context, limit int) ([]TenantCost, error)

ByTenant returns costs aggregated by tenant ID, sorted by TotalCost descending. Entries with empty TenantID are skipped.

func (*Engine) RequestCost

func (e *Engine) RequestCost(entry dataplane.RequestEntry) float64

RequestCost computes the estimated cost of a single request entry.

func (*Engine) Trend

func (e *Engine) Trend(ctx context.Context, window, bucketSize time.Duration) ([]TimeBucket, error)

Trend returns cost aggregated into time buckets over the given window.

type LambdaPricing

type LambdaPricing = config.LambdaPricing

Type aliases for config pricing types so cost-package callers do not need to import config directly, and existing code referencing these types continues to compile without change.

type PricingConfig

type PricingConfig = config.PricingConfig

PricingConfig is an alias for config.PricingConfig so callers can use cost.PricingConfig without importing the config package directly.

func DefaultPricingConfig

func DefaultPricingConfig() PricingConfig

DefaultPricingConfig returns a PricingConfig with standard AWS pricing. It delegates to config.DefaultPricingConfig so pricing defaults are defined in a single place.

type RouteCost

type RouteCost struct {
	Service      string  `json:"service"`
	Method       string  `json:"method"`
	Path         string  `json:"path"`
	RequestCount int64   `json:"requestCount"`
	TotalCost    float64 `json:"totalCost"`
	AvgCost      float64 `json:"avgCost"`
}

RouteCost represents the aggregated cost for a specific route (service + method + path).

type S3Pricing

type S3Pricing = config.S3Pricing

type SQSPricing

type SQSPricing = config.SQSPricing

type ServiceCost

type ServiceCost struct {
	Service      string  `json:"service"`
	RequestCount int64   `json:"requestCount"`
	TotalCost    float64 `json:"totalCost"`
	AvgCost      float64 `json:"avgCost"`
}

ServiceCost represents the aggregated cost for a single AWS service.

type TenantCost

type TenantCost struct {
	TenantID     string  `json:"tenantId"`
	RequestCount int64   `json:"requestCount"`
	TotalCost    float64 `json:"totalCost"`
	AvgCost      float64 `json:"avgCost"`
}

TenantCost represents the aggregated cost for a specific tenant.

type TimeBucket

type TimeBucket struct {
	Start        time.Time `json:"start"`
	End          time.Time `json:"end"`
	TotalCost    float64   `json:"totalCost"`
	RequestCount int64     `json:"requestCount"`
}

TimeBucket represents aggregated cost within a time window.

type TransferPricing

type TransferPricing = config.TransferPricing

Jump to

Keyboard shortcuts

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