-
Notifications
You must be signed in to change notification settings - Fork 680
feat(control-plane): [issue 4746] pool sufficiency metrics #4747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { Octokit } from '@octokit/rest'; | ||
import { addPersistentContextToChildLogger, createChildLogger } from '@aws-github-runner/aws-powertools-util'; | ||
import { | ||
addPersistentContextToChildLogger, | ||
createChildLogger, | ||
createSingleMetric, | ||
} from '@aws-github-runner/aws-powertools-util'; | ||
import { getParameter, putParameter } from '@aws-github-runner/aws-ssm-util'; | ||
import yn from 'yn'; | ||
|
||
|
@@ -9,6 +13,7 @@ import { RunnerInputParameters } from './../aws/runners.d'; | |
import ScaleError from './ScaleError'; | ||
import { publishRetryMessage } from './job-retry'; | ||
import { metricGitHubAppRateLimit } from '../github/rate-limit'; | ||
import { MetricUnit } from '@aws-lambda-powertools/metrics'; | ||
|
||
const logger = createChildLogger('scale-up'); | ||
|
||
|
@@ -307,6 +312,7 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage | |
|
||
if (scaleUp) { | ||
logger.info(`Attempting to launch a new runner`); | ||
createPoolSufficiencyMetric(environment, payload, false); | ||
|
||
await createRunners( | ||
{ | ||
|
@@ -348,6 +354,7 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage | |
} | ||
} else { | ||
logger.info('No runner will be created, job is not queued.'); | ||
createPoolSufficiencyMetric(environment, payload, true); | ||
} | ||
} | ||
|
||
|
@@ -473,3 +480,14 @@ async function createJitConfig(githubRunnerConfig: CreateGitHubRunnerConfig, ins | |
} | ||
} | ||
} | ||
|
||
function createPoolSufficiencyMetric(environment: string, payload: ActionRequestMessage, wasSufficient: boolean) { | ||
if (yn(process.env.ENABLE_METRIC_POOL_SUFFICIENCY, { default: false })) { | ||
const metric = createSingleMetric('SufficientPoolHosts', MetricUnit.Count, wasSufficient ? 1.0 : 0.0, { | ||
Environment: environment, | ||
}); | ||
metric.addMetadata('Environment', environment); | ||
metric.addMetadata('RepositoryName', payload.repositoryName); | ||
metric.addMetadata('RepositoryOwner', payload.repositoryOwner); | ||
} | ||
} | ||
Comment on lines
+484
to
+493
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Environment dimension is added twice - once in the metric creation and again as metadata. The dimension in the metric creation (line 487) should be sufficient for grouping metrics, making the duplicate metadata on line 489 redundant. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not correct review comment. First time environment is added as dimension. addMetadata is only added in the log not as dimension, correct? |
Uh oh!
There was an error while loading. Please reload this page.