Skip to content

refactor(patterndetector): hoist recordTimestamp(lr) helper #378

Description

@trilamsr

Context

Post-wave-audit finding #4 (see docs/v1-rc1-post-wave-audit.md).

Every projector ends with the same timestamp fallback:

if t := lr.Timestamp(); t != 0 {
    r.Timestamp = t.AsTime()
} else {
    r.Timestamp = lr.ObservedTimestamp().AsTime()
}

14 sites in module/processor/patterndetectorprocessor/.

Fix

func recordTimestamp(lr plog.LogRecord) time.Time {
    if t := lr.Timestamp(); t != 0 {
        return t.AsTime()
    }
    return lr.ObservedTimestamp().AsTime()
}

Same file as the k8s helper (#3). Land them together.

Acceptance

  • One-liner per projector replaces the four-line block.
  • Test covers Timestamp == 0, Timestamp != 0, ObservedTimestamp == 0 (returns zero time).

Bundle with #3 in a single refactor PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpost-wave-auditFiled by docs/v1-rc1-post-wave-audit.md (2026-06-01)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions