11import logging
2+ import math
23import random
34from datetime import datetime
45from typing import Any
@@ -116,6 +117,19 @@ def _get_quick_start_params_mapping(iteration: int = 0) -> dict:
116117 }
117118
118119
120+ def _metric_cumulative_shift (iteration : int ) -> tuple [float , float ]:
121+ """Compute cumulative metric shifts at a given iteration for Metric_Trend monitors.
122+
123+ Returns (discount_shift, price_shift) — the total shift from baseline
124+ that should be applied to the underlying data at this iteration.
125+ Uses composite sine waves for organic-looking oscillation patterns.
126+ """
127+ i = iteration
128+ discount = - 1.0 + 1.8 * math .sin (2 * math .pi * i / 14 + math .pi ) + 0.7 * math .sin (2 * math .pi * i / 6 + math .pi + 0.5 )
129+ price = 80 * math .sin (2 * math .pi * i / 16 ) + 40 * math .sin (2 * math .pi * i / 7 + 0.3 ) + 100
130+ return discount , price
131+
132+
119133def _get_monitor_params_mapping (run_date : datetime , iteration : int = 0 ) -> dict :
120134 # Volume: linear growth with jitter, spike at specific iteration for anomaly
121135 if iteration == 37 :
@@ -126,6 +140,12 @@ def _get_monitor_params_mapping(run_date: datetime, iteration: int = 0) -> dict:
126140 # Freshness: update every other iteration, late update for anomaly
127141 is_update_suppliers_iter = (iteration % 2 == 0 and iteration != 38 ) or iteration == 39
128142
143+ # Metrics: compute deltas for discount and price shifts
144+ curr_discount , curr_price = _metric_cumulative_shift (iteration )
145+ prev_discount , prev_price = _metric_cumulative_shift (iteration - 1 ) if iteration > 1 else (0.0 , 0.0 )
146+ discount_delta = round (curr_discount - prev_discount , 3 )
147+ price_delta = round (curr_price - prev_price , 2 )
148+
129149 return {
130150 ** _get_settings_params_mapping (),
131151 "ITERATION_NUMBER" : iteration ,
@@ -137,6 +157,8 @@ def _get_monitor_params_mapping(run_date: datetime, iteration: int = 0) -> dict:
137157 "IS_CREATE_RETURNS_TABLE_ITER" : iteration == 32 ,
138158 "IS_DELETE_CUSTOMER_ITER" : iteration in (18 , 22 , 34 ),
139159 "IS_UPDATE_SUPPLIERS_ITER" : is_update_suppliers_iter ,
160+ "DISCOUNT_DELTA" : discount_delta ,
161+ "PRICE_DELTA" : price_delta ,
140162 }
141163
142164
0 commit comments