formatDuration converts duration to a string in the format accepted by Elasticsearch.
(d time.Duration)
| 64 | // formatDuration converts duration to a string in the format |
| 65 | // accepted by Elasticsearch. |
| 66 | func formatDuration(d time.Duration) string { |
| 67 | if d < time.Millisecond { |
| 68 | return strconv.FormatInt(int64(d), 10) + "nanos" |
| 69 | } |
| 70 | return strconv.FormatInt(int64(d)/int64(time.Millisecond), 10) + "ms" |
| 71 | } |