| 85 | } |
| 86 | |
| 87 | func (t *TraceInfo) Ready(now time.Time, writeBackoff, longWriteBackoff time.Duration) bool { |
| 88 | // Don't use the last time interval to allow the write loop to finish before |
| 89 | // we try to read it. |
| 90 | if t.timestamp.After(now.Add(-writeBackoff)) { |
| 91 | return false |
| 92 | } |
| 93 | |
| 94 | // Compare a new instance with the same timestamp to know how many longWritesRemaining. |
| 95 | totalWrites := NewTraceInfo(t.timestamp, t.tempoOrgID).longWritesRemaining |
| 96 | // We are not ready if not all writes have had a chance to send. |
| 97 | lastWrite := t.timestamp.Add(time.Duration(totalWrites) * longWriteBackoff) |
| 98 | return !now.Before(lastWrite.Add(longWriteBackoff)) |
| 99 | } |
| 100 | |
| 101 | func (t *TraceInfo) Timestamp() time.Time { |
| 102 | return t.timestamp |