-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpost-deploy-observability.ts
More file actions
47 lines (39 loc) · 1.38 KB
/
post-deploy-observability.ts
File metadata and controls
47 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { readGlobalConfigSync } from '../../../lib/schemas/io/global-config';
import { enableTransactionSearch } from '../../aws/transaction-search';
export interface TransactionSearchSetupOptions {
region: string;
accountId: string;
agentNames: string[];
hasGateways?: boolean;
}
export interface TransactionSearchSetupResult {
success: boolean;
error?: string;
}
/**
* Post-deploy step: enable CloudWatch Transaction Search (Application Signals +
* resource policy + CloudWatchLogs destination + 100% indexing).
* All operations are idempotent.
*
* Can be disabled via ~/.agentcore/config.json: { "disableTransactionSearch": true }
*
* This is a non-blocking best-effort operation — failures do not fail the deploy.
*/
export async function setupTransactionSearch(
options: TransactionSearchSetupOptions
): Promise<TransactionSearchSetupResult> {
const { region, accountId, agentNames } = options;
if (agentNames.length === 0 && !options.hasGateways) {
return { success: true };
}
const config = readGlobalConfigSync();
if (config.disableTransactionSearch) {
return { success: true };
}
const indexPercentage = config.transactionSearchIndexPercentage ?? 100;
const result = await enableTransactionSearch(region, accountId, indexPercentage);
if (!result.success) {
return { success: false, error: result.error };
}
return { success: true };
}