File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -151,11 +151,17 @@ init_ingest_data() {
151151
152152 # Static arrays
153153 METHODS=(" GET" " POST" " PUT" " DELETE" " PATCH" " HEAD" )
154+ METHODS_LEN=${# METHODS[@]}
154155 STATUS_CODES=(200 400 401 500 503)
156+ STATUS_CODES_LEN=${# STATUS_CODES[@]}
155157 SERVICES=(" frontend" " api" " auth" " cart" " payment" )
158+ SERVICES_LEN=${# SERVICES[@]}
156159 ENDPOINTS=(" /products" " /cart" " /login" " /checkout" " /search" )
160+ ENDPOINTS_LEN=${# ENDPOINTS[@]}
157161 USER_AGENTS=(" curl/7.88.1" " python-requests/2.32.3" " Mozilla/5.0" )
162+ USER_AGENTS_LEN=${# USER_AGENTS[@]}
158163 CLUSTERS=(" web" " api" " db" )
164+ CLUSTERS_LEN=${# CLUSTERS[@]}
159165}
160166
161167# Generate batch data
@@ -175,12 +181,12 @@ generate_batch() {
175181 for (( i= 0 ; i< batch_size; i++ )) ; do
176182 # Use modulo for cycling through pre-computed arrays
177183 idx=$(( i % 100 ))
178- method_idx=$(( i % 6 ))
179- status_idx=$(( i % 5 ))
180- service_idx=$(( i % 5 ))
181- endpoint_idx=$(( i % 5 ))
182- agent_idx=$(( i % 3 ))
183- cluster_idx=$(( i % 3 ))
184+ method_idx=$(( i % METHODS_LEN ))
185+ status_idx=$(( i % STATUS_CODES_LEN ))
186+ service_idx=$(( i % SERVICES_LEN ))
187+ endpoint_idx=$(( i % ENDPOINTS_LEN ))
188+ agent_idx=$(( i % USER_AGENTS_LEN ))
189+ cluster_idx=$(( i % CLUSTERS_LEN ))
184190
185191 # Direct array access
186192 trace_id=${TRACE_IDS[$idx]}
You can’t perform that action at this time.
0 commit comments