@@ -140,7 +140,6 @@ def generate_loki_data(
140140 logger .debug (f"Time range in epoch seconds: { start_epoch } to { end_epoch } " )
141141
142142 log_data_list = [] # This list will hold all our data points
143- last_end_of_step_epoch = None # Track last entry's end epoch
144143
145144 # Loop through the time range and generate data points
146145 for current_epoch in range (
@@ -167,13 +166,13 @@ def generate_loki_data(
167166 "end_time" : end_str
168167 })
169168
170- # Track the last end epoch
171- last_end_of_step_epoch = end_of_step_epoch
172-
173169 # Add final entry that ends at end_epoch (current time)
174- if log_data_list and end_epoch > start_epoch and last_end_of_step_epoch :
170+ if log_data_list and end_epoch > start_epoch :
175171 # Calculate start of final entry based on end of last generated entry
176- final_start_epoch = last_end_of_step_epoch + 1
172+ last_entry_end = log_data_list [- 1 ]["end_time" ]
173+ # Parse the last entry's end time to get the epoch
174+ last_end_dt = datetime .fromisoformat (last_entry_end )
175+ final_start_epoch = int (last_end_dt .timestamp ()) + 1
177176 final_nanoseconds = int (final_start_epoch * 1_000_000_000 )
178177
179178 # Only add if the final entry would have a valid duration
@@ -225,11 +224,8 @@ def generate_loki_data(
225224
226225 # Validate required fields
227226 # metadata is optional for generation; name is not a log-type field
228- required_for_item = [
229- f for f in required_fields
230- if f not in ("name" , "metadata" )
231- ]
232- missing = [f for f in required_for_item if f not in log_type_config ]
227+ required_for_item = set (required_fields ) - {"name" , "metadata" }
228+ missing = required_for_item - set (log_type_config )
233229 if missing :
234230 logger .error (
235231 f"Missing required fields in { type_key !r} config: { missing } "
0 commit comments