Skip to content

Commit

Permalink
Merge branch 'feat/math-time-duration' of https://github.com/fchikwek…
Browse files Browse the repository at this point in the history
…we/opentelemetry-collector-contrib into feat/math-time-duration
  • Loading branch information
fchikwekwe committed Jul 28, 2023
2 parents d5357af + ac8cd42 commit 04e38aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/ottl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ When defining an OTTL function, if the function needs to take an Enum then the f

Math Expressions represent arithmetic calculations. They support `+`, `-`, `*`, and `/`, along with `()` for grouping.

Math Expressions currently support `int64` and`float64`.
Math Expressions also support `time.Time` and `time.Duration`, but only with `+` and `-` and only using the following rules:
Math Expressions currently support `int64`, `float64`, `time.Time` and `time.Duration`.
For `time.Time` and `time.Duration`, only `+` and `-` are supported with the following rules:
- A `time.Time` `-` a `time.Time` yields a `time.Duration`.
- A `time.Duration` `+` a `time.Time` yields a `time.Time`.
- A `time.Time` `-` a `time.Duration` yields a `time.Time`.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ottl/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func performOpTime(x time.Time, y any, op mathOp) (any, error) {
result := x.Add(-1 * newY)
return result, nil
default:
return nil, fmt.Errorf("time.Time must be subtracted from time.Time or time.Duration; found %v instead", y)
return nil, fmt.Errorf("time.Time or time.Duration must be subtracted from time.Time; found %v instead", y)
}
}
return nil, fmt.Errorf("only addition and subtraction supported for time.Time and time.Duration")
Expand Down

0 comments on commit 04e38aa

Please sign in to comment.