Skip to content

feat: worktime scoring strategy for Prometheus discovery#54

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/feature-developer-worktime-function
Draft

feat: worktime scoring strategy for Prometheus discovery#54
Copilot wants to merge 2 commits into
mainfrom
copilot/feature-developer-worktime-function

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Adds a strategy-pattern–based scoring function that weights Prometheus range query data points by time of day before aggregation. This lets operators prioritize images pulled during business hours over nighttime noise.

Changes

  • API types (api/v1alpha1): ScoringStrategy, WorktimeStrategy, WorktimeWindow — configurable time-of-day windows with weight multipliers and timezone support
  • Strategy interface (internal/discovery/scoring.go): ScoreWeighter interface with worktimeWeighter implementation; extensible for future strategies
  • Aggregation integration: aggregateRangeValues applies per-datapoint weight multiplication when a weighter is configured; no-op when nil (backward compatible)
  • Controller wiring: buildSource constructs the weighter from API config and passes it through to PrometheusSource
  • CRD + deepcopy regenerated via make codegen

Example

prometheus:
  endpoint: https://mimir.example.com
  lookback: 168h
  aggregationMethod: sum
  scoringStrategy:
    type: worktime
    worktime:
      timezone: "Europe/Berlin"
      windows:
        - { startHour: 9,  endHour: 17, weight: "1.0" }
        - { startHour: 6,  endHour: 9,  weight: "0.3" }
        - { startHour: 17, endHour: 19, weight: "0.3" }

Data points at 3am get weight 0 (dropped from sum); data points at 10am get full weight. The strategy is optional and nil-safe — existing configs are unaffected.

Implements a strategy pattern for time-based weighting of Prometheus
range query data points. The WorktimeStrategy allows configuring
time-of-day windows with weight multipliers, so images discovered
during business hours score higher than those discovered at night.

API additions:
- ScoringStrategy type with worktime variant
- WorktimeStrategy with configurable windows and timezone
- WorktimeWindow with startHour, endHour, weight

Implementation:
- ScoreWeighter interface in internal/discovery/scoring.go
- worktimeWeighter implementation with timezone support
- Integration into aggregateRangeValues via optional weighter param
- Controller wiring in buildSource

Closes #53
Copilot AI changed the title [WIP] Implement developer worktime scoring function for metric lookups feat: worktime scoring strategy for Prometheus discovery Jun 22, 2026
Copilot finished work on behalf of Breee June 22, 2026 12:37
Copilot AI requested a review from Breee June 22, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants