Skip to content

Commit

Permalink
chore: add ivm heap usage metrics (#3517)
Browse files Browse the repository at this point in the history
* chore: record ivm heap size used metric
  • Loading branch information
Jayachand authored Jul 1, 2024
1 parent c8fd8de commit 2104754
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/util/customTransformer-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ async function userTransformHandlerV1(
throw err;
} finally {
logger.debug(`Destroying IsolateVM`);
let used_heap_size = 0;
try {
used_heap_size = isolatevm.isolate.getHeapStatisticsSync()?.used_heap_size || 0;
} catch (err) {
logger.error(`Error encountered while getting heap size: ${err.message}`);
}
isolatevmFactory.destroy(isolatevm);
// send the observability stats
const tags = {
Expand All @@ -99,6 +105,7 @@ async function userTransformHandlerV1(
};
stats.counter('user_transform_function_input_events', events.length, tags);
stats.timingSummary('user_transform_function_latency_summary', invokeTime, tags);
stats.summary('user_transform_used_heap_size', used_heap_size, tags);
}

return { transformedEvents, logs };
Expand Down
16 changes: 16 additions & 0 deletions src/util/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,22 @@ class Prometheus {
'workspaceId',
],
},
{
name: 'user_transform_used_heap_size',
help: 'user_transform_used_heap_size',
type: 'summary',
labelNames: [
'identifier',
'testMode',
'sourceType',
'destinationType',
'k8_namespace',
'errored',
'statusCode',
'transformationId',
'workspaceId',
],
},
];

metrics.forEach((metric) => {
Expand Down

0 comments on commit 2104754

Please sign in to comment.