@@ -131,16 +131,23 @@ func main() {
131131 }
132132 vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (numericValue )
133133 case * protos.Value_StringValue :
134- // Try to parse the string value as a float64
135- floatVal , err := strconv . ParseFloat ( v .StringValue , 64 )
136- if err == nil {
137- vehicleDataGauge . WithLabelValues ( fieldName , vehicleData . Vin ). Set ( floatVal )
134+ // Check if the string is "<invalid>"
135+ if v . StringValue == " \u003c invalid \u003e " || v .StringValue == "<invalid>" {
136+ vehicleDataGauge . WithLabelValues ( fieldName , vehicleData . Vin ). Set ( 0 )
137+ log . Printf ( "Received invalid string value for field %s" , fieldName )
138138 } else {
139- // Handle non-numeric string values
140- vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (0 ) // Placeholder value
141- log .Printf ("Received non-numeric string value for field %s: %s" , fieldName , v .StringValue )
139+ // Try to parse the string value as a float64
140+ floatVal , err := strconv .ParseFloat (v .StringValue , 64 )
141+ if err == nil {
142+ vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (floatVal )
143+ } else {
144+ // Handle non-numeric string values
145+ vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (0 ) // Placeholder value
146+ log .Printf ("Received non-numeric string value for field %s: %s" , fieldName , v .StringValue )
147+ }
142148 }
143149 case * protos.Value_Invalid :
150+ vehicleDataGauge .WithLabelValues (fieldName , vehicleData .Vin ).Set (0 )
144151 log .Printf ("Received invalid value for field %s" , fieldName )
145152 case * protos.Value_LocationValue :
146153 // Handle LocationValue separately
0 commit comments