Class LifecycleRecordMerger

java.lang.Object
com.arc_e_tect.gradle.trackerlens.tracker.LifecycleRecordMerger

public class LifecycleRecordMerger extends Object
Merges LifecycleRecords sharing the same LifecycleRecord.id() - read from different history files registered on the same tracker - into one record per id.

This is what makes splitting one tracker's history across several files (or a directory of them, see HistoryFileResolver) safe: without it, an item observed in more than one file (e.g. an endpoint that both shadow-api-detector's and mirage-api-detector's own history files know about, when a user points each detector at its own file instead of a shared one) would render as duplicate rows with only a partial view of its lifecycle in each.

Always applied, even when a tracker resolves to exactly one file: merging a set of records with no id collisions is a no-op, so there is no separate single-file code path to keep in sync.

  • Constructor Details

    • LifecycleRecordMerger

      public LifecycleRecordMerger()
      Creates a new LifecycleRecordMerger.
  • Method Details

    • merge

      public List<LifecycleRecord> merge(List<String> canonicalStages, List<LifecycleRecord> records)
      Merges records by id.
      Parameters:
      canonicalStages - the tracker's canonical stage names, in order - determines both the merged record's stageReachedAt ordering and, for a stage reported by more than one record for the same id, which timestamp wins (the earliest)
      records - the records to merge, from every resolved history file
      Returns:
      one record per distinct id, in first-seen order