| 317 | } |
| 318 | |
| 319 | func (m *MetricsCompare) validate() error { |
| 320 | err := m.f.validate() |
| 321 | if err != nil { |
| 322 | return err |
| 323 | } |
| 324 | |
| 325 | if m.topN <= 0 { |
| 326 | return fmt.Errorf("compare() top number of values must be integer greater than 0") |
| 327 | } |
| 328 | |
| 329 | if m.start == 0 && m.end == 0 { |
| 330 | return nil |
| 331 | } |
| 332 | |
| 333 | if m.start <= 0 || m.end <= 0 { |
| 334 | return fmt.Errorf("compare() timestamps must be positive integer unix nanoseconds") |
| 335 | } |
| 336 | if m.end <= m.start { |
| 337 | return fmt.Errorf("compare() end timestamp must be greater than start timestamp") |
| 338 | } |
| 339 | return nil |
| 340 | } |
| 341 | |
| 342 | func (m *MetricsCompare) String() string { |
| 343 | return "compare(" + m.f.String() + "}" |