MCPcopy Index your code
hub / github.com/simstudioai/sim / ExecutionLogger

Class ExecutionLogger

apps/sim/lib/logs/execution/logger.ts:299–1574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299export class ExecutionLogger implements IExecutionLoggerService {
300 private compactExecutionDataForStorage(
301 executionData: ExecutionData,
302 executionId: string
303 ): ExecutionData {
304 const originalBytes = getJsonByteSize(executionData)
305 if (originalBytes === undefined || originalBytes <= MAX_EXECUTION_DATA_BYTES) {
306 return executionData
307 }
308
309 const { executionState: _executionState, ...executionDataWithoutState } = executionData
310 const summarized: ExecutionData = {
311 ...executionDataWithoutState,
312 traceSpans: summarizeTraceSpansForExecutionData(executionData.traceSpans),
313 finalOutput: summarizeValueForExecutionData(
314 executionData.finalOutput,
315 MAX_WORKFLOW_VALUE_BYTES
316 ) as BlockOutputData,
317 executionDataTruncated: true,
318 executionDataOriginalBytes: originalBytes,
319 executionDataMaxBytes: MAX_EXECUTION_DATA_BYTES,
320 executionDataTruncationReason:
321 'Execution log exceeded the maximum stored payload size, so large inputs and outputs were summarized.',
322 }
323
324 if (executionData.workflowInput !== undefined) {
325 summarized.workflowInput = summarizeValueForExecutionData(
326 executionData.workflowInput,
327 MAX_WORKFLOW_VALUE_BYTES
328 )
329 }
330
331 if (executionData.executionState) {
332 summarized.executionStateSummary = summarizeExecutionState(executionData.executionState)
333 }
334
335 const summarizedWithSize = recordStoredByteSize(summarized)
336 if (
337 summarizedWithSize.storedBytes !== undefined &&
338 summarizedWithSize.storedBytes <= MAX_EXECUTION_DATA_BYTES
339 ) {
340 logger.warn('Summarized oversized workflow execution data before storing log', {
341 executionId,
342 originalBytes,
343 storedBytes: summarizedWithSize.storedBytes,
344 maxBytes: MAX_EXECUTION_DATA_BYTES,
345 })
346 return summarizedWithSize.executionData
347 }
348
349 const minimal: ExecutionData = {
350 ...(executionData.environment ? { environment: executionData.environment } : {}),
351 ...(executionData.trigger ? { trigger: executionData.trigger } : {}),
352 ...(executionData.correlation ? { correlation: executionData.correlation } : {}),
353 ...(executionData.error ? { error: executionData.error } : {}),
354 ...(executionData.lastStartedBlock
355 ? { lastStartedBlock: executionData.lastStartedBlock }
356 : {}),

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected