Skip to content

Commit

Permalink
[pgk/ottl] Remove debug log from invalidComparison (open-telemetry#31813
Browse files Browse the repository at this point in the history
)

**Description:**
When we added the boolean comparison feature we included a debug log to
help troubleshoot when 2 comparisons were invalid, such as checking if a
`string` was equal to a `float64`. Since then we've had complaints about
how noisy the log is, mainly because it happens when checking against
`nil`, which happens frequently when checking if an attribute has a
specific value when it is present.

This PR removes the log.

**Link to tracking Issue:**

Closes
open-telemetry#29015
  • Loading branch information
TylerHelmuth authored Apr 5, 2024
1 parent af3c7fe commit ef4402b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pkg/ottl/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"bytes"
"time"

"go.uber.org/zap"
"golang.org/x/exp/constraints"
)

Expand All @@ -17,9 +16,7 @@ import (

// invalidComparison returns false for everything except ne (where it returns true to indicate that the
// objects were definitely not equivalent).
// It also gives us an opportunity to log something.
func (p *Parser[K]) invalidComparison(msg string, op compareOp) bool {
p.telemetrySettings.Logger.Debug(msg, zap.Any("op", op))
func (p *Parser[K]) invalidComparison(op compareOp) bool {
return op == ne
}

Expand Down Expand Up @@ -87,7 +84,7 @@ func (p *Parser[K]) compareBool(a bool, b any, op compareOp) bool {
case bool:
return compareBools(a, v, op)
default:
return p.invalidComparison("bool to non-bool", op)
return p.invalidComparison(op)
}
}

Expand All @@ -96,7 +93,7 @@ func (p *Parser[K]) compareString(a string, b any, op compareOp) bool {
case string:
return comparePrimitives(a, v, op)
default:
return p.invalidComparison("string to non-string", op)
return p.invalidComparison(op)
}
}

Expand All @@ -110,7 +107,7 @@ func (p *Parser[K]) compareByte(a []byte, b any, op compareOp) bool {
}
return compareBytes(a, v, op)
default:
return p.invalidComparison("Bytes to non-Bytes", op)
return p.invalidComparison(op)
}
}

Expand All @@ -121,7 +118,7 @@ func (p *Parser[K]) compareInt64(a int64, b any, op compareOp) bool {
case float64:
return comparePrimitives(float64(a), v, op)
default:
return p.invalidComparison("int to non-numeric value", op)
return p.invalidComparison(op)
}
}

Expand All @@ -132,7 +129,7 @@ func (p *Parser[K]) compareFloat64(a float64, b any, op compareOp) bool {
case float64:
return comparePrimitives(a, v, op)
default:
return p.invalidComparison("float to non-numeric value", op)
return p.invalidComparison(op)
}
}

Expand All @@ -143,7 +140,7 @@ func (p *Parser[K]) compareDuration(a time.Duration, b any, op compareOp) bool {
vnsecs := v.Nanoseconds()
return comparePrimitives(ansecs, vnsecs, op)
default:
return p.invalidComparison("cannot compare invalid duration", op)
return p.invalidComparison(op)
}
}

Expand All @@ -164,10 +161,10 @@ func (p *Parser[K]) compareTime(a time.Time, b any, op compareOp) bool {
case gt:
return a.After(v)
default:
return p.invalidComparison("invalid comparison operator", op)
return p.invalidComparison(op)
}
default:
return p.invalidComparison("time to non-time value", op)
return p.invalidComparison(op)
}
}

Expand Down Expand Up @@ -211,7 +208,7 @@ func (p *Parser[K]) compare(a any, b any, op compareOp) bool {
case ne:
return a != b
default:
return p.invalidComparison("unsupported type for inequality on left", op)
return p.invalidComparison(op)
}
}
}

0 comments on commit ef4402b

Please sign in to comment.