Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Make the packet timeline configurable. #2163

Merged
merged 8 commits into from
Jun 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import java.time.Clock
import java.time.Duration
import java.time.Instant
import java.util.Collections
import java.util.concurrent.ConcurrentLinkedQueue

@SuppressFBWarnings("CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE")
class EventTimeline(
Expand All @@ -34,9 +33,12 @@ class EventTimeline(
* by a different thread. This is not critical as it only affects the timeline and the result is just some "exit"
* events missing from the trace logs.
*/
private val timeline: ConcurrentLinkedQueue<Pair<String, Duration>> = ConcurrentLinkedQueue(),
timelineArg: MutableList<Pair<String, Duration>> = mutableListOf(),
private val clock: Clock = Clock.systemUTC()
) : Iterable<Pair<String, Duration>> {

private val timeline: MutableList<Pair<String, Duration>> = Collections.synchronizedList(timelineArg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't need the type


/**
* The [referenceTime] refers to the first timestamp we have
* in the timeline. In the timeline this is used as time "0" and
Expand All @@ -56,7 +58,7 @@ class EventTimeline(
}

fun clone(): EventTimeline {
val clone = EventTimeline(ConcurrentLinkedQueue(timeline))
val clone = EventTimeline(timeline.toMutableList())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a new bug, but while you're in there, clone() should pass clock rather than letting it default to Clock.systemUTC().

clone.referenceTime = referenceTime
return clone
}
Expand All @@ -77,7 +79,9 @@ class EventTimeline(
return with(StringBuffer()) {
referenceTime?.let {
append("Reference time: $referenceTime; ")
append(timeline.joinToString(separator = "; "))
synchronized(timeline) {
append(timeline.joinToString(separator = "; "))
}
} ?: run {
append("[No timeline]")
}
Expand Down
Loading