Skip to content

Commit

Permalink
fix float32 zapcore field converter
Browse files Browse the repository at this point in the history
  • Loading branch information
rsergeychik committed Jul 22, 2024
1 parent e41a0f2 commit da07ee0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion otelzap/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ func appendField(kvs []log.KeyValue, f zapcore.Field) []log.KeyValue {
zapcore.UintptrType:
return append(kvs, log.Int64(f.Key, f.Integer))

case zapcore.Float32Type, zapcore.Float64Type:
case zapcore.Float64Type:
num := math.Float64frombits(uint64(f.Integer))
return append(kvs, log.Float64(f.Key, num))
case zapcore.Float32Type:
num := math.Float32frombits(uint32(f.Integer))
return append(kvs, log.Float64(f.Key, float64(num)))

case zapcore.Complex64Type:
str := strconv.FormatComplex(complex128(f.Interface.(complex64)), 'E', -1, 64)
Expand Down

0 comments on commit da07ee0

Please sign in to comment.