Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions services/apps/data_sink_worker/src/service/dataSink.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,31 +488,48 @@ export default class DataSinkService extends LoggerBase {
const end = performance.now()
const totalTime = end - start

for (const type of types) {
const items = groupedByType.get(type)
const msPerItem = Math.floor(totalTime / items.length)

const args = { type }

if (type === IntegrationResultType.ACTIVITY) {
items.forEach((item) => {
const activityArgs = {
...args,
platform: item.platform,
integrationId: item.integrationId,
onboarding:
item.onboarding === null || item.onboarding === undefined
? '<not-set>'
: item.onboarding.toString(),
channel: (item.data.data as IActivityData).channel,
}
telemetry.distribution('data_sink_worker.process_result', msPerItem, activityArgs)
})
} else {
items.forEach(() => {
telemetry.distribution('data_sink_worker.process_result', msPerItem, args)
})
try {
for (const type of types) {
const items = groupedByType.get(type)
const msPerItem = Math.floor(totalTime / items.length)

const args = { type }

if (type === IntegrationResultType.ACTIVITY) {
items.forEach((item) => {
const activityData = item.data?.data as IActivityData | undefined
if (!activityData) {
this.log.warn(
{
resultId: item.id,
integrationId: item.integrationId,
platform: item.platform,
streamId: item.streamId,
dataType: item.data?.type,
},
'Activity result has missing data payload (data.data is undefined)!',
)
}
const activityArgs = {
...args,
platform: item.platform,
integrationId: item.integrationId,
onboarding:
item.onboarding === null || item.onboarding === undefined
? '<not-set>'
: item.onboarding.toString(),
channel: activityData?.channel,
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activityArgs sets channel to activityData?.channel, which can be undefined. The telemetry client’s normalizeTags passes tag values through without filtering undefined, and DogStatsD expects tag values to be strings/numbers; this can throw and cause the whole telemetry loop to abort (only caught at the outer try/catch). Consider omitting the channel tag when missing or mapping it to a sentinel string like '<not-set>' to avoid telemetry errors/noise.

Suggested change
channel: activityData?.channel,
channel: activityData?.channel ?? '<not-set>',

Copilot uses AI. Check for mistakes.
}
telemetry.distribution('data_sink_worker.process_result', msPerItem, activityArgs)
})
} else {
items.forEach(() => {
telemetry.distribution('data_sink_worker.process_result', msPerItem, args)
})
}
}
} catch (telemetryErr) {
this.log.error(telemetryErr, 'Error while reporting telemetry for processed results!')
}
}
}
Loading