Преглед изворни кода

fix: correct UnmountedPVCost doc comment and cloudcost tracerName typo

Two small review follow-ups on PR #3735:

1. pkg/costmodel/currency_helper.go -- UnmountedPVCost is tagged
   `json:"-"` in Allocation and downstream types, so the old "fields
   that appear in JSON API responses" comment on `costFields` was
   inaccurate. It is nevertheless correct to convert it: it flows
   into SummaryAllocation and Totals aggregations, and leaving it
   in USD while the primary costs are in EUR/INR/etc. would cause
   unit mismatches downstream. Update the comment to reflect that
   internal non-JSON fields are included for this reason.

2. pkg/cloudcost/queryservice.go -- fix pre-existing typo in the
   tracerName constant: "github.com/opencost/ooencost/pkg/cloudcost"
   -> "github.com/opencost/opencost/pkg/cloudcost". Was fragmenting
   otel traces for this package vs. peer query services. Trivial
   out-of-scope cleanup flagged by the automated reviewer.

Signed-off-by: Warwick Peatey <warwick@automatic.systems>
Assisted-by: Claude Code
Warwick Peatey пре 1 месец
родитељ
комит
948abbe5b6
2 измењених фајлова са 6 додато и 2 уклоњено
  1. 1 1
      pkg/cloudcost/queryservice.go
  2. 5 1
      pkg/costmodel/currency_helper.go

+ 1 - 1
pkg/cloudcost/queryservice.go

@@ -13,7 +13,7 @@ import (
 	"go.opentelemetry.io/otel"
 )
 
-const tracerName = "github.com/opencost/ooencost/pkg/cloudcost"
+const tracerName = "github.com/opencost/opencost/pkg/cloudcost"
 
 const (
 	csvFormat = "csv"

+ 5 - 1
pkg/costmodel/currency_helper.go

@@ -81,7 +81,11 @@ func convertAllocationFields(alloc *opencost.Allocation, converter currency.Conv
 	}
 
 	// Named cost fields. Keep in sync with Allocation cost fields in
-	// core/pkg/opencost/allocation.go that appear in JSON API responses.
+	// core/pkg/opencost/allocation.go. Includes both JSON-serialised
+	// costs and internal ones like UnmountedPVCost (json:"-") which are
+	// used downstream in SummaryAllocation / Totals computations --
+	// leaving those in USD would cause unit mismatches with the
+	// converted primary costs.
 	type namedCost struct {
 		name string
 		ptr  *float64