Skip to content

Commit 1e22b97

Browse files
joanagmaiaclaude
andauthored
feat: route packages_worker Temporal alerts to dedicated Akrites Slack channel (#4409)
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e633ba2 commit 1e22b97

7 files changed

Lines changed: 29 additions & 3 deletions

File tree

services/apps/packages_worker/src/activities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ export {
6161
blastRadiusReachability,
6262
blastRadiusReport,
6363
} from './blast-radius/activities'
64+
export { slackNotify } from './activities/index'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { getServiceChildLogger } from '@crowd/logging'
2+
import { SlackChannel, SlackPersona, sendSlackNotificationAsync } from '@crowd/slack'
3+
4+
const log = getServiceChildLogger('activity-interceptor')
5+
6+
async function slackNotify(message: string, persona: SlackPersona | string) {
7+
await sendSlackNotificationAsync(
8+
SlackChannel.CDP_AKRITES_ALERTS,
9+
persona as SlackPersona,
10+
'Temporal Alert',
11+
message,
12+
)
13+
log.info('Slack notification sent from Temporal activity')
14+
}
15+
16+
export { slackNotify }

services/apps/packages_worker/src/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Config } from '@crowd/archetype-standard'
22
import { Options, ServiceWorker } from '@crowd/archetype-worker'
3+
import { SlackChannel } from '@crowd/slack'
34

45
const config: Config = {
56
envvars: [],
@@ -10,6 +11,7 @@ const config: Config = {
1011

1112
const options: Options = {
1213
postgres: { enabled: false }, // packages-db is managed via getPackagesDb()
14+
alertChannel: SlackChannel.CDP_AKRITES_ALERTS,
1315
}
1416

1517
export const svc = new ServiceWorker(config, options)

services/archetypes/worker/src/activities/activityInterceptor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { SlackChannel, SlackPersona, sendSlackNotificationAsync } from '@crowd/s
66
import telemetry from '@crowd/telemetry'
77

88
export class ActivityMonitoringInterceptor implements ActivityInboundCallsInterceptor {
9-
public constructor(private readonly ctx: Context) {}
9+
public constructor(
10+
private readonly ctx: Context,
11+
private readonly alertChannel: SlackChannel = SlackChannel.CDP_ALERTS,
12+
) {}
1013
async execute(
1114
input: ActivityExecuteInput,
1215
next: Next<ActivityInboundCallsInterceptor, 'execute'>,
@@ -34,7 +37,7 @@ export class ActivityMonitoringInterceptor implements ActivityInboundCallsInterc
3437

3538
// Fire and forget - don't await to avoid blocking the activity
3639
sendSlackNotificationAsync(
37-
SlackChannel.CDP_ALERTS,
40+
this.alertChannel,
3841
SlackPersona.WARNING_PROPAGATOR,
3942
'High Activity Retry Count',
4043
message,

services/archetypes/worker/src/worker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { DbStore, getDbConnection } from '@crowd/database'
1414
import { getServiceChildLogger } from '@crowd/logging'
1515
import { OpenSearchService, getOpensearchClient } from '@crowd/opensearch'
1616
import { IQueue, QueueFactory } from '@crowd/queue'
17+
import { SlackChannel } from '@crowd/slack'
1718
import { getDataConverter } from '@crowd/temporal'
1819

1920
import * as metricActivities from './activities'
@@ -51,6 +52,7 @@ Options is used to configure the worker service.
5152
export interface Options {
5253
maxTaskQueueActivitiesPerSecond?: number
5354
maxConcurrentActivityTaskExecutions?: number
55+
alertChannel?: SlackChannel
5456
postgres?: {
5557
enabled: boolean
5658
}
@@ -288,7 +290,7 @@ export class ServiceWorker extends Service {
288290
activity: [
289291
(ctx) => {
290292
return {
291-
inbound: new ActivityMonitoringInterceptor(ctx),
293+
inbound: new ActivityMonitoringInterceptor(ctx, this.options.alertChannel),
292294
}
293295
},
294296
],

services/libs/slack/src/channels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = {
1313
[SlackChannel.INSIGHTS_ALERTS]: process.env.INSIGHTS_ALERTS_SLACK_WEBHOOK_URL,
1414
[SlackChannel.INSIGHTS_CRITICAL_ALERTS]: process.env.INSIGHTS_CRITICAL_ALERTS_SLACK_WEBHOOK_URL,
1515
[SlackChannel.CDP_LFX_SELF_SERVE_ALERTS]: process.env.CDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URL,
16+
[SlackChannel.CDP_AKRITES_ALERTS]: process.env.CDP_AKRITES_ALERTS_SLACK_WEBHOOK_URL,
1617
}
1718

1819
// Check for missing webhook URLs on initialization

services/libs/slack/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum SlackChannel {
77
INSIGHTS_ALERTS = 'INSIGHTS_ALERTS',
88
INSIGHTS_CRITICAL_ALERTS = 'INSIGHTS_CRITICAL_ALERTS',
99
CDP_LFX_SELF_SERVE_ALERTS = 'CDP_LFX_SELF_SERVE_ALERTS',
10+
CDP_AKRITES_ALERTS = 'CDP_AKRITES_ALERTS',
1011
}
1112

1213
export enum SlackPersona {

0 commit comments

Comments
 (0)