import logging
from aiva.utils.logging import get_trace_id

class ThresholdManager:
    def __init__(self, threshold):
        self.threshold = threshold
        self.current_value = 0
        self.logger = logging.getLogger(__name__)

    def update_value(self, new_value):
        if new_value >= self.threshold and self.current_value < self.threshold:
            trace_id = get_trace_id()
            self.logger.info("Threshold breached", extra={"threshold": self.threshold, "current_value": new_value, "trace_id": trace_id})
        self.current_value = new_value