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

Function enqueue

apps/sim/lib/monitoring/metrics.ts:94–117  ·  view source on GitHub ↗
(
  MetricName: string,
  Value: number,
  Unit: StandardUnit,
  labels: Record<string, string | undefined>
)

Source from the content-addressed store, hash-verified

92}
93
94function enqueue(
95 MetricName: string,
96 Value: number,
97 Unit: StandardUnit,
98 labels: Record<string, string | undefined>
99): void {
100 if (!ENABLED) return
101 buffer.push({
102 MetricName,
103 Value,
104 Unit,
105 Timestamp: new Date(),
106 Dimensions: buildDimensions(labels),
107 })
108 if (buffer.length > MAX_BUFFER) {
109 // Flushing has stalled (CloudWatch slow/erroring) — bound memory by dropping
110 // the oldest points instead of growing without limit.
111 const overflow = buffer.length - MAX_BUFFER
112 buffer.splice(0, overflow)
113 dropped += overflow
114 }
115 ensureBackground()
116 if (buffer.length >= FLUSH_THRESHOLD) void flushHostedKeyMetrics()
117}
118
119/** Drain the buffer to CloudWatch. Safe to call repeatedly; await before exit. */
120export async function flushHostedKeyMetrics(): Promise<void> {

Callers 9

recordUsedFunction · 0.70
recordFailedFunction · 0.70
recordCostChargedFunction · 0.70
recordThrottledFunction · 0.70
recordQueueWaitFunction · 0.70
recordQueueWaitExceededFunction · 0.70
recordUnknownModelCostFunction · 0.70
multipart.test.tsFile · 0.50

Calls 4

buildDimensionsFunction · 0.85
ensureBackgroundFunction · 0.85
flushHostedKeyMetricsFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected