@@ -9,7 +9,7 @@ import { getErrorMessage } from 'src/operator/utils'
99import { env } from 'src/common/envalid'
1010
1111const cmdName = getFilename ( __filename )
12- const { COLLECTION_INTERVAL_SECONDS , COLLECTION_DURATION_SECONDS } = env
12+ const { COLLECTION_INTERVAL_SECONDS , COLLECTION_DURATION_SECONDS , APL_OPERATOR_NAMESPACE , TRACES_REPORT_NAME } = env
1313const COLLECTION_INTERVAL_MS = COLLECTION_INTERVAL_SECONDS * 1000
1414const COLLECTION_DURATION_MS = COLLECTION_DURATION_SECONDS * 1000
1515interface ResourceReport {
@@ -414,17 +414,15 @@ export async function collectTraces(): Promise<void> {
414414 ...( collectionErrors . length > 0 && { errors : collectionErrors } ) ,
415415 }
416416
417- // Store in ConfigMap
418- const configMapName = 'apl-traces-report'
419- const targetNamespace = 'apl-operator'
420-
421417 if ( failedResources . length === 0 ) {
422418 d . info ( 'No failing resources found. Your APL instance seems to be healthy.' )
423419 }
424420
425421 // Always write the report to ConfigMap (even when healthy, for timestamp visibility)
426- await writeReportToConfigMap ( configMapName , targetNamespace , report )
427- d . info ( `Trace report stored in ConfigMap ${ targetNamespace } /${ configMapName } (${ failedResources . length } issues)` )
422+ await writeReportToConfigMap ( TRACES_REPORT_NAME , APL_OPERATOR_NAMESPACE , report )
423+ d . info (
424+ `Trace report stored in ConfigMap ${ APL_OPERATOR_NAMESPACE } /${ TRACES_REPORT_NAME } (${ failedResources . length } issues)` ,
425+ )
428426 } catch ( error ) {
429427 d . error ( 'Failed to collect traces:' , error )
430428 throw error
@@ -450,11 +448,8 @@ async function getCollectionStartTime(name: string, namespace: string): Promise<
450448
451449export async function runTraceCollectionLoop ( ) : Promise < void > {
452450 const d = terminal ( 'cmd:traces:runTraceCollectionLoop' )
453- const configMapName = 'apl-traces-report'
454- const namespace = 'apl-operator'
455-
456451 // Get collection start time from ConfigMap creation timestamp
457- const startTime = await getCollectionStartTime ( configMapName , namespace )
452+ const startTime = await getCollectionStartTime ( TRACES_REPORT_NAME , APL_OPERATOR_NAMESPACE )
458453 const endTime = startTime + COLLECTION_DURATION_MS
459454 const now = Date . now ( )
460455
@@ -474,11 +469,8 @@ export async function runTraceCollectionLoop(): Promise<void> {
474469 d . warn ( 'Failed to collect traces:' , getErrorMessage ( error ) )
475470 }
476471
477- const remainingTime = endTime - Date . now ( )
478- if ( remainingTime > 0 ) {
479- const waitTime = Math . min ( COLLECTION_INTERVAL_MS , remainingTime )
480- await new Promise ( ( resolve ) => setTimeout ( resolve , waitTime ) )
481- }
472+ // Wait 5 minutes before next collection
473+ await new Promise ( ( resolve ) => setTimeout ( resolve , COLLECTION_INTERVAL_MS ) )
482474 }
483475
484476 d . info ( 'Trace collection loop completed' )
0 commit comments