@smthrs/observability 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +21 -0
  2. package/docker-compose.otel.yml +104 -0
  3. package/grafana/dashboards/smithers-dashboard.json +453 -0
  4. package/grafana/provisioning/dashboards/dashboards.yml +12 -0
  5. package/grafana/provisioning/datasources/datasources.yml +49 -0
  6. package/loki/loki-config.yaml +35 -0
  7. package/otel-collector-config.yml +38 -0
  8. package/package.json +47 -0
  9. package/prometheus/prometheus.yml +8 -0
  10. package/src/MetricName.ts +1 -0
  11. package/src/MetricsServiceLive.js +9 -0
  12. package/src/README.md +28 -0
  13. package/src/ResolvedSmithersObservabilityOptions.ts +12 -0
  14. package/src/SmithersEvent.ts +773 -0
  15. package/src/SmithersLogFormat.ts +1 -0
  16. package/src/SmithersMetricDefinition.ts +15 -0
  17. package/src/SmithersMetricType.ts +1 -0
  18. package/src/SmithersMetricUnit.ts +1 -0
  19. package/src/SmithersObservability.js +15 -0
  20. package/src/SmithersObservabilityOptions.ts +12 -0
  21. package/src/SmithersObservabilityService.ts +13 -0
  22. package/src/_coreCorrelation/CorrelationContext.ts +10 -0
  23. package/src/_coreCorrelation/CorrelationContextLive.js +11 -0
  24. package/src/_coreCorrelation/CorrelationContextService.js +15 -0
  25. package/src/_coreCorrelation/CorrelationContextServiceShape.ts +12 -0
  26. package/src/_coreCorrelation/CorrelationPatch.ts +3 -0
  27. package/src/_coreCorrelation/README.md +20 -0
  28. package/src/_coreCorrelation/_correlationStorage.js +4 -0
  29. package/src/_coreCorrelation/correlationContextFiberRef.js +5 -0
  30. package/src/_coreCorrelation/correlationContextToLogAnnotations.js +18 -0
  31. package/src/_coreCorrelation/getCurrentCorrelationContext.js +9 -0
  32. package/src/_coreCorrelation/getCurrentCorrelationContextEffect.js +11 -0
  33. package/src/_coreCorrelation/index.js +14 -0
  34. package/src/_coreCorrelation/mergeCorrelationContext.js +51 -0
  35. package/src/_coreCorrelation/runWithCorrelationContext.js +14 -0
  36. package/src/_coreCorrelation/updateCurrentCorrelationContext.js +17 -0
  37. package/src/_coreCorrelation/withCorrelationContext.js +38 -0
  38. package/src/_coreCorrelation/withCurrentCorrelationContext.js +11 -0
  39. package/src/_coreMetrics.js +14 -0
  40. package/src/_coreMetricsShape.ts +44 -0
  41. package/src/_corePrometheus.js +91 -0
  42. package/src/_corePrometheusShape.ts +11 -0
  43. package/src/_coreTracing.js +132 -0
  44. package/src/_coreTracingShape.ts +17 -0
  45. package/src/_otelLogBuilders.js +102 -0
  46. package/src/_sessionFileResolvers.js +164 -0
  47. package/src/_smithersSpanAttributeAliases.js +19 -0
  48. package/src/_smithersTraceSpanStorage.js +3 -0
  49. package/src/_traceEventNormalizers.js +499 -0
  50. package/src/_traceRedaction.js +162 -0
  51. package/src/agentSessionEventToOtelLogRecord.js +55 -0
  52. package/src/agentTrace.ts +144 -0
  53. package/src/agentTraceCapabilities.js +151 -0
  54. package/src/annotateSmithersTrace.js +11 -0
  55. package/src/canonicalTraceEventToOtelLogRecord.js +55 -0
  56. package/src/correlation.js +56 -0
  57. package/src/createSmithersObservabilityLayer.js +59 -0
  58. package/src/createSmithersOtelLayer.js +23 -0
  59. package/src/createSmithersRuntimeLayer.js +2 -0
  60. package/src/detectAgentFamily.js +26 -0
  61. package/src/detectCaptureMode.js +24 -0
  62. package/src/emitOtelLogRecord.js +19 -0
  63. package/src/getCurrentSmithersTraceAnnotations.js +14 -0
  64. package/src/getCurrentSmithersTraceSpan.js +7 -0
  65. package/src/index.d.ts +1321 -0
  66. package/src/index.js +136 -0
  67. package/src/kindPhase.js +17 -0
  68. package/src/logging.js +248 -0
  69. package/src/makeSmithersSpanAttributes.js +20 -0
  70. package/src/metrics/README.md +22 -0
  71. package/src/metrics/SmithersMetricDefinition.ts +17 -0
  72. package/src/metrics/SmithersMetricType.ts +1 -0
  73. package/src/metrics/SmithersMetricUnit.ts +1 -0
  74. package/src/metrics/_asyncExternalWaitCounts.js +4 -0
  75. package/src/metrics/_buckets.js +37 -0
  76. package/src/metrics/_incrementGauge.js +11 -0
  77. package/src/metrics/_processStartMs.js +1 -0
  78. package/src/metrics/activeNodes.js +2 -0
  79. package/src/metrics/activeRuns.js +2 -0
  80. package/src/metrics/agentActionsTotal.js +2 -0
  81. package/src/metrics/agentDurationMs.js +3 -0
  82. package/src/metrics/agentErrorsTotal.js +2 -0
  83. package/src/metrics/agentEventsTotal.js +2 -0
  84. package/src/metrics/agentInvocationsTotal.js +2 -0
  85. package/src/metrics/agentRetriesTotal.js +2 -0
  86. package/src/metrics/agentSessionsTotal.js +2 -0
  87. package/src/metrics/agentTokensTotal.js +2 -0
  88. package/src/metrics/alertDeliveriesAttempted.js +2 -0
  89. package/src/metrics/alertDeliveriesSuppressed.js +2 -0
  90. package/src/metrics/alertsAcknowledgedTotal.js +2 -0
  91. package/src/metrics/alertsActive.js +2 -0
  92. package/src/metrics/alertsEscalatedTotal.js +2 -0
  93. package/src/metrics/alertsFiredTotal.js +2 -0
  94. package/src/metrics/alertsReopenedTotal.js +2 -0
  95. package/src/metrics/alertsResolvedTotal.js +2 -0
  96. package/src/metrics/alertsSilencedTotal.js +2 -0
  97. package/src/metrics/approvalPending.js +2 -0
  98. package/src/metrics/approvalWaitDuration.js +5 -0
  99. package/src/metrics/approvalsDenied.js +2 -0
  100. package/src/metrics/approvalsGranted.js +2 -0
  101. package/src/metrics/approvalsRequested.js +2 -0
  102. package/src/metrics/attemptDuration.js +3 -0
  103. package/src/metrics/attentionBacklog.js +2 -0
  104. package/src/metrics/cacheHits.js +2 -0
  105. package/src/metrics/cacheMisses.js +2 -0
  106. package/src/metrics/dbQueryDuration.js +3 -0
  107. package/src/metrics/dbRetries.js +2 -0
  108. package/src/metrics/dbTransactionDuration.js +3 -0
  109. package/src/metrics/dbTransactionRetries.js +2 -0
  110. package/src/metrics/dbTransactionRollbacks.js +2 -0
  111. package/src/metrics/devtoolsActiveSubscribers.js +2 -0
  112. package/src/metrics/devtoolsBackpressureDisconnectTotal.js +2 -0
  113. package/src/metrics/devtoolsDeltaBuildMs.js +3 -0
  114. package/src/metrics/devtoolsEventBytes.js +3 -0
  115. package/src/metrics/devtoolsEventTotal.js +2 -0
  116. package/src/metrics/devtoolsSnapshotBuildMs.js +5 -0
  117. package/src/metrics/devtoolsSubscribeTotal.js +2 -0
  118. package/src/metrics/errorsTotal.js +2 -0
  119. package/src/metrics/eventsEmittedTotal.js +2 -0
  120. package/src/metrics/externalWaitAsyncPending.js +2 -0
  121. package/src/metrics/gatewayApprovalDecisionsTotal.js +2 -0
  122. package/src/metrics/gatewayAuthEventsTotal.js +2 -0
  123. package/src/metrics/gatewayConnectionsActive.js +2 -0
  124. package/src/metrics/gatewayConnectionsClosedTotal.js +2 -0
  125. package/src/metrics/gatewayConnectionsTotal.js +2 -0
  126. package/src/metrics/gatewayCronTriggersTotal.js +2 -0
  127. package/src/metrics/gatewayErrorsTotal.js +2 -0
  128. package/src/metrics/gatewayHeartbeatTicksTotal.js +2 -0
  129. package/src/metrics/gatewayMessagesReceivedTotal.js +2 -0
  130. package/src/metrics/gatewayMessagesSentTotal.js +2 -0
  131. package/src/metrics/gatewayRpcCallsTotal.js +2 -0
  132. package/src/metrics/gatewayRpcDuration.js +3 -0
  133. package/src/metrics/gatewayRunEventBackpressureDisconnectTotal.js +4 -0
  134. package/src/metrics/gatewayRunsCompletedTotal.js +2 -0
  135. package/src/metrics/gatewayRunsStartedTotal.js +2 -0
  136. package/src/metrics/gatewaySignalsTotal.js +2 -0
  137. package/src/metrics/gatewayWebhooksReceivedTotal.js +2 -0
  138. package/src/metrics/gatewayWebhooksRejectedTotal.js +2 -0
  139. package/src/metrics/gatewayWebhooksVerifiedTotal.js +2 -0
  140. package/src/metrics/heartbeatDataSizeBytes.js +5 -0
  141. package/src/metrics/heartbeatIntervalMs.js +3 -0
  142. package/src/metrics/hotReloadDuration.js +3 -0
  143. package/src/metrics/hotReloadFailures.js +2 -0
  144. package/src/metrics/hotReloads.js +2 -0
  145. package/src/metrics/httpRequestDuration.js +3 -0
  146. package/src/metrics/httpRequests.js +2 -0
  147. package/src/metrics/index.d.ts +1163 -0
  148. package/src/metrics/index.js +168 -0
  149. package/src/metrics/memoryFactReads.js +3 -0
  150. package/src/metrics/memoryFactWrites.js +3 -0
  151. package/src/metrics/memoryMessageSaves.js +3 -0
  152. package/src/metrics/memoryRecallDuration.js +11 -0
  153. package/src/metrics/memoryRecallQueries.js +3 -0
  154. package/src/metrics/metricsServiceAdapter.js +181 -0
  155. package/src/metrics/nodeDuration.js +3 -0
  156. package/src/metrics/nodeRetriesTotal.js +2 -0
  157. package/src/metrics/nodesFailed.js +2 -0
  158. package/src/metrics/nodesFinished.js +2 -0
  159. package/src/metrics/nodesStarted.js +2 -0
  160. package/src/metrics/openApiToolCallErrorsTotal.js +3 -0
  161. package/src/metrics/openApiToolCallsTotal.js +3 -0
  162. package/src/metrics/openApiToolDuration.js +9 -0
  163. package/src/metrics/processHeapUsedBytes.js +2 -0
  164. package/src/metrics/processMemoryRssBytes.js +2 -0
  165. package/src/metrics/processUptimeSeconds.js +2 -0
  166. package/src/metrics/promptSizeBytes.js +3 -0
  167. package/src/metrics/replaysStarted.js +3 -0
  168. package/src/metrics/responseSizeBytes.js +3 -0
  169. package/src/metrics/rewindDurationMs.js +3 -0
  170. package/src/metrics/rewindFramesDeleted.js +3 -0
  171. package/src/metrics/rewindRollbackTotal.js +2 -0
  172. package/src/metrics/rewindSandboxesReverted.js +3 -0
  173. package/src/metrics/rewindTotal.js +2 -0
  174. package/src/metrics/runDuration.js +3 -0
  175. package/src/metrics/runForksCreated.js +3 -0
  176. package/src/metrics/runsAncestryDepth.js +3 -0
  177. package/src/metrics/runsCancelledTotal.js +2 -0
  178. package/src/metrics/runsCarriedStateBytes.js +5 -0
  179. package/src/metrics/runsContinuedTotal.js +2 -0
  180. package/src/metrics/runsFailedTotal.js +2 -0
  181. package/src/metrics/runsFinishedTotal.js +2 -0
  182. package/src/metrics/runsResumedTotal.js +2 -0
  183. package/src/metrics/runsTotal.js +2 -0
  184. package/src/metrics/sandboxActive.js +2 -0
  185. package/src/metrics/sandboxBundleSizeBytes.js +5 -0
  186. package/src/metrics/sandboxCompletedTotal.js +2 -0
  187. package/src/metrics/sandboxCreatedTotal.js +2 -0
  188. package/src/metrics/sandboxDurationMs.js +3 -0
  189. package/src/metrics/sandboxPatchCount.js +3 -0
  190. package/src/metrics/sandboxTransportDurationMs.js +5 -0
  191. package/src/metrics/schedulerConcurrencyUtilization.js +2 -0
  192. package/src/metrics/schedulerQueueDepth.js +2 -0
  193. package/src/metrics/schedulerWaitDuration.js +5 -0
  194. package/src/metrics/scorerDuration.js +9 -0
  195. package/src/metrics/scorerEventsFailed.js +2 -0
  196. package/src/metrics/scorerEventsFinished.js +2 -0
  197. package/src/metrics/scorerEventsStarted.js +2 -0
  198. package/src/metrics/scorersFailed.js +3 -0
  199. package/src/metrics/scorersFinished.js +3 -0
  200. package/src/metrics/scorersStarted.js +3 -0
  201. package/src/metrics/smithersMetricCatalog.js +893 -0
  202. package/src/metrics/smithersMetricCatalogByKey.js +2 -0
  203. package/src/metrics/smithersMetricCatalogByName.js +2 -0
  204. package/src/metrics/smithersMetricCatalogByPrometheusName.js +4 -0
  205. package/src/metrics/snapshotDuration.js +9 -0
  206. package/src/metrics/snapshotsCaptured.js +3 -0
  207. package/src/metrics/supervisorPollDuration.js +5 -0
  208. package/src/metrics/supervisorPollsTotal.js +2 -0
  209. package/src/metrics/supervisorResumeLag.js +5 -0
  210. package/src/metrics/supervisorResumedTotal.js +2 -0
  211. package/src/metrics/supervisorSkippedTotal.js +2 -0
  212. package/src/metrics/supervisorStaleDetected.js +2 -0
  213. package/src/metrics/taskHeartbeatTimeoutTotal.js +2 -0
  214. package/src/metrics/taskHeartbeatsTotal.js +2 -0
  215. package/src/metrics/timerDelayDuration.js +3 -0
  216. package/src/metrics/timersCancelled.js +2 -0
  217. package/src/metrics/timersCreated.js +2 -0
  218. package/src/metrics/timersFired.js +2 -0
  219. package/src/metrics/timersPending.js +2 -0
  220. package/src/metrics/toPrometheusMetricName.js +8 -0
  221. package/src/metrics/tokensCacheReadTotal.js +2 -0
  222. package/src/metrics/tokensCacheWriteTotal.js +2 -0
  223. package/src/metrics/tokensContextWindowBucketTotal.js +2 -0
  224. package/src/metrics/tokensContextWindowPerCall.js +5 -0
  225. package/src/metrics/tokensInputPerCall.js +3 -0
  226. package/src/metrics/tokensInputTotal.js +2 -0
  227. package/src/metrics/tokensOutputPerCall.js +3 -0
  228. package/src/metrics/tokensOutputTotal.js +2 -0
  229. package/src/metrics/tokensReasoningTotal.js +2 -0
  230. package/src/metrics/toolCallErrorsTotal.js +2 -0
  231. package/src/metrics/toolCallsTotal.js +2 -0
  232. package/src/metrics/toolDuration.js +3 -0
  233. package/src/metrics/toolOutputTruncatedTotal.js +2 -0
  234. package/src/metrics/trackEvent.js +608 -0
  235. package/src/metrics/updateAsyncExternalWaitPending.js +18 -0
  236. package/src/metrics/updateProcessMetrics.js +20 -0
  237. package/src/metrics/vcsDuration.js +3 -0
  238. package/src/normalizeStructuredEvent.js +15 -0
  239. package/src/prometheusContentType.js +1 -0
  240. package/src/renderPrometheusMetrics.js +212 -0
  241. package/src/resolveAgentTraceCapabilities.js +59 -0
  242. package/src/resolveSmithersObservabilityOptions.js +109 -0
  243. package/src/smithersMetrics.js +2 -0
  244. package/src/smithersSpanNames.js +6 -0
  245. package/src/unsupportedKindsForCapabilities.js +32 -0
  246. package/src/withSmithersSpan.js +17 -0
  247. package/tempo/tempo.yml +17 -0
@@ -0,0 +1,893 @@
1
+ import { toPrometheusMetricName } from "./toPrometheusMetricName.js";
2
+ import {
3
+ durationBuckets,
4
+ fastBuckets,
5
+ toolBuckets,
6
+ tokenBuckets,
7
+ contextWindowBuckets,
8
+ sizeBuckets,
9
+ carriedStateSizeBuckets,
10
+ ancestryDepthBuckets,
11
+ } from "./_buckets.js";
12
+ // Local metric instances
13
+ import { runsTotal } from "./runsTotal.js";
14
+ import { nodesStarted } from "./nodesStarted.js";
15
+ import { nodesFinished } from "./nodesFinished.js";
16
+ import { nodesFailed } from "./nodesFailed.js";
17
+ import { toolCallsTotal } from "./toolCallsTotal.js";
18
+ import { cacheHits } from "./cacheHits.js";
19
+ import { cacheMisses } from "./cacheMisses.js";
20
+ import { dbRetries } from "./dbRetries.js";
21
+ import { dbTransactionRollbacks } from "./dbTransactionRollbacks.js";
22
+ import { dbTransactionRetries } from "./dbTransactionRetries.js";
23
+ import { hotReloads } from "./hotReloads.js";
24
+ import { hotReloadFailures } from "./hotReloadFailures.js";
25
+ import { httpRequests } from "./httpRequests.js";
26
+ import { approvalsRequested } from "./approvalsRequested.js";
27
+ import { approvalsGranted } from "./approvalsGranted.js";
28
+ import { approvalsDenied } from "./approvalsDenied.js";
29
+ import { timersCreated } from "./timersCreated.js";
30
+ import { timersFired } from "./timersFired.js";
31
+ import { timersCancelled } from "./timersCancelled.js";
32
+ import { sandboxCreatedTotal } from "./sandboxCreatedTotal.js";
33
+ import { sandboxCompletedTotal } from "./sandboxCompletedTotal.js";
34
+ import { alertsFiredTotal } from "./alertsFiredTotal.js";
35
+ import { alertsAcknowledgedTotal } from "./alertsAcknowledgedTotal.js";
36
+ import { scorerEventsStarted } from "./scorerEventsStarted.js";
37
+ import { scorerEventsFinished } from "./scorerEventsFinished.js";
38
+ import { scorerEventsFailed } from "./scorerEventsFailed.js";
39
+ import { tokensInputTotal } from "./tokensInputTotal.js";
40
+ import { tokensOutputTotal } from "./tokensOutputTotal.js";
41
+ import { tokensCacheReadTotal } from "./tokensCacheReadTotal.js";
42
+ import { tokensCacheWriteTotal } from "./tokensCacheWriteTotal.js";
43
+ import { tokensReasoningTotal } from "./tokensReasoningTotal.js";
44
+ import { tokensContextWindowBucketTotal } from "./tokensContextWindowBucketTotal.js";
45
+ import { runsFinishedTotal } from "./runsFinishedTotal.js";
46
+ import { runsFailedTotal } from "./runsFailedTotal.js";
47
+ import { runsCancelledTotal } from "./runsCancelledTotal.js";
48
+ import { runsResumedTotal } from "./runsResumedTotal.js";
49
+ import { runsContinuedTotal } from "./runsContinuedTotal.js";
50
+ import { supervisorPollsTotal } from "./supervisorPollsTotal.js";
51
+ import { supervisorStaleDetected } from "./supervisorStaleDetected.js";
52
+ import { supervisorResumedTotal } from "./supervisorResumedTotal.js";
53
+ import { supervisorSkippedTotal } from "./supervisorSkippedTotal.js";
54
+ import { errorsTotal } from "./errorsTotal.js";
55
+ import { nodeRetriesTotal } from "./nodeRetriesTotal.js";
56
+ import { toolCallErrorsTotal } from "./toolCallErrorsTotal.js";
57
+ import { toolOutputTruncatedTotal } from "./toolOutputTruncatedTotal.js";
58
+ import { agentInvocationsTotal } from "./agentInvocationsTotal.js";
59
+ import { agentTokensTotal } from "./agentTokensTotal.js";
60
+ import { agentErrorsTotal } from "./agentErrorsTotal.js";
61
+ import { agentRetriesTotal } from "./agentRetriesTotal.js";
62
+ import { agentEventsTotal } from "./agentEventsTotal.js";
63
+ import { agentSessionsTotal } from "./agentSessionsTotal.js";
64
+ import { agentActionsTotal } from "./agentActionsTotal.js";
65
+ import { gatewayConnectionsTotal } from "./gatewayConnectionsTotal.js";
66
+ import { gatewayConnectionsClosedTotal } from "./gatewayConnectionsClosedTotal.js";
67
+ import { gatewayMessagesReceivedTotal } from "./gatewayMessagesReceivedTotal.js";
68
+ import { gatewayMessagesSentTotal } from "./gatewayMessagesSentTotal.js";
69
+ import { gatewayRpcCallsTotal } from "./gatewayRpcCallsTotal.js";
70
+ import { gatewayErrorsTotal } from "./gatewayErrorsTotal.js";
71
+ import { gatewayRunsStartedTotal } from "./gatewayRunsStartedTotal.js";
72
+ import { gatewayRunsCompletedTotal } from "./gatewayRunsCompletedTotal.js";
73
+ import { gatewayApprovalDecisionsTotal } from "./gatewayApprovalDecisionsTotal.js";
74
+ import { gatewaySignalsTotal } from "./gatewaySignalsTotal.js";
75
+ import { gatewayAuthEventsTotal } from "./gatewayAuthEventsTotal.js";
76
+ import { gatewayHeartbeatTicksTotal } from "./gatewayHeartbeatTicksTotal.js";
77
+ import { gatewayCronTriggersTotal } from "./gatewayCronTriggersTotal.js";
78
+ import { gatewayWebhooksReceivedTotal } from "./gatewayWebhooksReceivedTotal.js";
79
+ import { gatewayWebhooksVerifiedTotal } from "./gatewayWebhooksVerifiedTotal.js";
80
+ import { gatewayWebhooksRejectedTotal } from "./gatewayWebhooksRejectedTotal.js";
81
+ import { eventsEmittedTotal } from "./eventsEmittedTotal.js";
82
+ import { taskHeartbeatsTotal } from "./taskHeartbeatsTotal.js";
83
+ import { taskHeartbeatTimeoutTotal } from "./taskHeartbeatTimeoutTotal.js";
84
+ import { memoryFactReads } from "./memoryFactReads.js";
85
+ import { memoryFactWrites } from "./memoryFactWrites.js";
86
+ import { memoryRecallDuration } from "./memoryRecallDuration.js";
87
+ import { memoryRecallQueries } from "./memoryRecallQueries.js";
88
+ import { memoryMessageSaves } from "./memoryMessageSaves.js";
89
+ import { openApiToolCallsTotal } from "./openApiToolCallsTotal.js";
90
+ import { openApiToolCallErrorsTotal } from "./openApiToolCallErrorsTotal.js";
91
+ import { openApiToolDuration } from "./openApiToolDuration.js";
92
+ import { scorerDuration } from "./scorerDuration.js";
93
+ import { scorersFailed } from "./scorersFailed.js";
94
+ import { scorersFinished } from "./scorersFinished.js";
95
+ import { scorersStarted } from "./scorersStarted.js";
96
+ import { replaysStarted } from "./replaysStarted.js";
97
+ import { runForksCreated } from "./runForksCreated.js";
98
+ import { snapshotDuration } from "./snapshotDuration.js";
99
+ import { snapshotsCaptured } from "./snapshotsCaptured.js";
100
+ import { activeRuns } from "./activeRuns.js";
101
+ import { activeNodes } from "./activeNodes.js";
102
+ import { schedulerQueueDepth } from "./schedulerQueueDepth.js";
103
+ import { sandboxActive } from "./sandboxActive.js";
104
+ import { alertsActive } from "./alertsActive.js";
105
+ import { gatewayConnectionsActive } from "./gatewayConnectionsActive.js";
106
+ import { approvalPending } from "./approvalPending.js";
107
+ import { externalWaitAsyncPending } from "./externalWaitAsyncPending.js";
108
+ import { timersPending } from "./timersPending.js";
109
+ import { schedulerConcurrencyUtilization } from "./schedulerConcurrencyUtilization.js";
110
+ import { processUptimeSeconds } from "./processUptimeSeconds.js";
111
+ import { processMemoryRssBytes } from "./processMemoryRssBytes.js";
112
+ import { processHeapUsedBytes } from "./processHeapUsedBytes.js";
113
+ import { nodeDuration } from "./nodeDuration.js";
114
+ import { attemptDuration } from "./attemptDuration.js";
115
+ import { toolDuration } from "./toolDuration.js";
116
+ import { dbQueryDuration } from "./dbQueryDuration.js";
117
+ import { dbTransactionDuration } from "./dbTransactionDuration.js";
118
+ import { httpRequestDuration } from "./httpRequestDuration.js";
119
+ import { hotReloadDuration } from "./hotReloadDuration.js";
120
+ import { vcsDuration } from "./vcsDuration.js";
121
+ import { agentDurationMs } from "./agentDurationMs.js";
122
+ import { tokensInputPerCall } from "./tokensInputPerCall.js";
123
+ import { tokensOutputPerCall } from "./tokensOutputPerCall.js";
124
+ import { tokensContextWindowPerCall } from "./tokensContextWindowPerCall.js";
125
+ import { runDuration } from "./runDuration.js";
126
+ import { promptSizeBytes } from "./promptSizeBytes.js";
127
+ import { responseSizeBytes } from "./responseSizeBytes.js";
128
+ import { approvalWaitDuration } from "./approvalWaitDuration.js";
129
+ import { timerDelayDuration } from "./timerDelayDuration.js";
130
+ import { gatewayRpcDuration } from "./gatewayRpcDuration.js";
131
+ import { schedulerWaitDuration } from "./schedulerWaitDuration.js";
132
+ import { supervisorPollDuration } from "./supervisorPollDuration.js";
133
+ import { supervisorResumeLag } from "./supervisorResumeLag.js";
134
+ import { runsAncestryDepth } from "./runsAncestryDepth.js";
135
+ import { runsCarriedStateBytes } from "./runsCarriedStateBytes.js";
136
+ import { sandboxDurationMs } from "./sandboxDurationMs.js";
137
+ import { sandboxBundleSizeBytes } from "./sandboxBundleSizeBytes.js";
138
+ import { sandboxTransportDurationMs } from "./sandboxTransportDurationMs.js";
139
+ import { sandboxPatchCount } from "./sandboxPatchCount.js";
140
+ import { heartbeatDataSizeBytes } from "./heartbeatDataSizeBytes.js";
141
+ import { heartbeatIntervalMs } from "./heartbeatIntervalMs.js";
142
+ /** @typedef {import("./SmithersMetricType.ts").SmithersMetricType} SmithersMetricType */
143
+
144
+ /** @typedef {import("./SmithersMetricDefinition.ts").SmithersMetricDefinition} SmithersMetricDefinition */
145
+
146
+ /**
147
+ * @param {any} boundaries
148
+ * @returns {readonly number[]}
149
+ */
150
+ function metricBoundaryValues(boundaries) {
151
+ return Array.from(boundaries?.values ?? []).sort((left, right) => left - right);
152
+ }
153
+ /**
154
+ * @param {Metric.Metric<any, any, any>} metric
155
+ * @returns {readonly number[]}
156
+ */
157
+ function metricHistogramBoundaries(metric) {
158
+ return Array.from(metric?.keyType?.boundaries?.values ?? [])
159
+ .filter((value) => Number.isFinite(value))
160
+ .sort((left, right) => left - right);
161
+ }
162
+ /**
163
+ * @param {string} key
164
+ * @param {Metric.Metric<any, any, any>} metric
165
+ * @param {string} name
166
+ * @param {SmithersMetricType} type
167
+ * @param {Omit< SmithersMetricDefinition, "key" | "metric" | "name" | "prometheusName" | "type" >} options
168
+ * @returns {SmithersMetricDefinition}
169
+ */
170
+ function metricDefinition(key, metric, name, type, options) {
171
+ return {
172
+ key,
173
+ metric,
174
+ name,
175
+ prometheusName: toPrometheusMetricName(name),
176
+ type,
177
+ ...options,
178
+ };
179
+ }
180
+ const durationBucketValues = metricBoundaryValues(durationBuckets);
181
+ const fastBucketValues = metricBoundaryValues(fastBuckets);
182
+ const toolBucketValues = metricBoundaryValues(toolBuckets);
183
+ const tokenBucketValues = metricBoundaryValues(tokenBuckets);
184
+ const contextWindowBucketValues = metricBoundaryValues(contextWindowBuckets);
185
+ const sizeBucketValues = metricBoundaryValues(sizeBuckets);
186
+ const carriedStateSizeBucketValues = metricBoundaryValues(carriedStateSizeBuckets);
187
+ const ancestryDepthBucketValues = metricBoundaryValues(ancestryDepthBuckets);
188
+ export const smithersMetricCatalog = [
189
+ metricDefinition("runsTotal", runsTotal, "smithers.runs.total", "counter", { label: "Runs started", unit: "count" }),
190
+ metricDefinition("nodesStarted", nodesStarted, "smithers.nodes.started", "counter", {
191
+ label: "Nodes started",
192
+ unit: "count",
193
+ }),
194
+ metricDefinition("nodesFinished", nodesFinished, "smithers.nodes.finished", "counter", {
195
+ label: "Nodes finished",
196
+ unit: "count",
197
+ }),
198
+ metricDefinition("nodesFailed", nodesFailed, "smithers.nodes.failed", "counter", {
199
+ label: "Nodes failed",
200
+ unit: "count",
201
+ }),
202
+ metricDefinition("toolCallsTotal", toolCallsTotal, "smithers.tool_calls.total", "counter", {
203
+ label: "Tool calls",
204
+ unit: "count",
205
+ }),
206
+ metricDefinition("cacheHits", cacheHits, "smithers.cache.hits", "counter", { label: "Cache hits", unit: "count" }),
207
+ metricDefinition("cacheMisses", cacheMisses, "smithers.cache.misses", "counter", {
208
+ label: "Cache misses",
209
+ unit: "count",
210
+ }),
211
+ metricDefinition("dbRetries", dbRetries, "smithers.db.retries", "counter", { label: "DB retries", unit: "count" }),
212
+ metricDefinition("dbTransactionRollbacks", dbTransactionRollbacks, "smithers.db.transaction_rollbacks", "counter", {
213
+ label: "DB transaction rollbacks",
214
+ unit: "count",
215
+ }),
216
+ metricDefinition("dbTransactionRetries", dbTransactionRetries, "smithers.db.transaction_retries", "counter", {
217
+ label: "DB transaction retries",
218
+ unit: "count",
219
+ }),
220
+ metricDefinition("hotReloads", hotReloads, "smithers.hot.reloads", "counter", {
221
+ label: "Hot reloads",
222
+ unit: "count",
223
+ }),
224
+ metricDefinition("hotReloadFailures", hotReloadFailures, "smithers.hot.reload_failures", "counter", {
225
+ label: "Hot reload failures",
226
+ unit: "count",
227
+ }),
228
+ metricDefinition("httpRequests", httpRequests, "smithers.http.requests", "counter", {
229
+ label: "HTTP requests",
230
+ unit: "count",
231
+ labels: ["method", "route", "status_code", "status_class"],
232
+ }),
233
+ metricDefinition("approvalsRequested", approvalsRequested, "smithers.approvals.requested", "counter", {
234
+ label: "Approvals requested",
235
+ unit: "count",
236
+ }),
237
+ metricDefinition("approvalsGranted", approvalsGranted, "smithers.approvals.granted", "counter", {
238
+ label: "Approvals granted",
239
+ unit: "count",
240
+ }),
241
+ metricDefinition("approvalsDenied", approvalsDenied, "smithers.approvals.denied", "counter", {
242
+ label: "Approvals denied",
243
+ unit: "count",
244
+ }),
245
+ metricDefinition("timersCreated", timersCreated, "smithers.timers.created", "counter", {
246
+ label: "Timers created",
247
+ unit: "count",
248
+ }),
249
+ metricDefinition("timersFired", timersFired, "smithers.timers.fired", "counter", {
250
+ label: "Timers fired",
251
+ unit: "count",
252
+ }),
253
+ metricDefinition("timersCancelled", timersCancelled, "smithers.timers.cancelled", "counter", {
254
+ label: "Timers cancelled",
255
+ unit: "count",
256
+ }),
257
+ metricDefinition("sandboxCreatedTotal", sandboxCreatedTotal, "smithers.sandbox.created_total", "counter", {
258
+ label: "Sandboxes created",
259
+ unit: "count",
260
+ labels: ["runtime"],
261
+ }),
262
+ metricDefinition("sandboxCompletedTotal", sandboxCompletedTotal, "smithers.sandbox.completed_total", "counter", {
263
+ label: "Sandboxes completed",
264
+ unit: "count",
265
+ labels: ["runtime", "status"],
266
+ }),
267
+ metricDefinition("alertsFiredTotal", alertsFiredTotal, "smithers.alerts.fired_total", "counter", {
268
+ label: "Alerts fired",
269
+ unit: "count",
270
+ labels: ["policy"],
271
+ }),
272
+ metricDefinition(
273
+ "alertsAcknowledgedTotal",
274
+ alertsAcknowledgedTotal,
275
+ "smithers.alerts.acknowledged_total",
276
+ "counter",
277
+ {
278
+ label: "Alerts acknowledged",
279
+ unit: "count",
280
+ labels: ["policy"],
281
+ },
282
+ ),
283
+ metricDefinition("scorerEventsStarted", scorerEventsStarted, "smithers.scorer_events.started", "counter", {
284
+ label: "Scorer events started",
285
+ unit: "count",
286
+ }),
287
+ metricDefinition("scorerEventsFinished", scorerEventsFinished, "smithers.scorer_events.finished", "counter", {
288
+ label: "Scorer events finished",
289
+ unit: "count",
290
+ }),
291
+ metricDefinition("scorerEventsFailed", scorerEventsFailed, "smithers.scorer_events.failed", "counter", {
292
+ label: "Scorer events failed",
293
+ unit: "count",
294
+ }),
295
+ metricDefinition("tokensInputTotal", tokensInputTotal, "smithers.tokens.input_total", "counter", {
296
+ label: "Input tokens",
297
+ unit: "tokens",
298
+ labels: ["agent", "model"],
299
+ }),
300
+ metricDefinition("tokensOutputTotal", tokensOutputTotal, "smithers.tokens.output_total", "counter", {
301
+ label: "Output tokens",
302
+ unit: "tokens",
303
+ labels: ["agent", "model"],
304
+ }),
305
+ metricDefinition("tokensCacheReadTotal", tokensCacheReadTotal, "smithers.tokens.cache_read_total", "counter", {
306
+ label: "Cache read tokens",
307
+ unit: "tokens",
308
+ labels: ["agent", "model"],
309
+ }),
310
+ metricDefinition("tokensCacheWriteTotal", tokensCacheWriteTotal, "smithers.tokens.cache_write_total", "counter", {
311
+ label: "Cache write tokens",
312
+ unit: "tokens",
313
+ labels: ["agent", "model"],
314
+ }),
315
+ metricDefinition("tokensReasoningTotal", tokensReasoningTotal, "smithers.tokens.reasoning_total", "counter", {
316
+ label: "Reasoning tokens",
317
+ unit: "tokens",
318
+ labels: ["agent", "model"],
319
+ }),
320
+ metricDefinition(
321
+ "tokensContextWindowBucketTotal",
322
+ tokensContextWindowBucketTotal,
323
+ "smithers.tokens.context_window_bucket_total",
324
+ "counter",
325
+ {
326
+ label: "Context window bucket hits",
327
+ unit: "count",
328
+ labels: ["agent", "bucket", "model"],
329
+ },
330
+ ),
331
+ metricDefinition("runsFinishedTotal", runsFinishedTotal, "smithers.runs.finished_total", "counter", {
332
+ label: "Runs finished",
333
+ unit: "count",
334
+ }),
335
+ metricDefinition("runsFailedTotal", runsFailedTotal, "smithers.runs.failed_total", "counter", {
336
+ label: "Runs failed",
337
+ unit: "count",
338
+ }),
339
+ metricDefinition("runsCancelledTotal", runsCancelledTotal, "smithers.runs.cancelled_total", "counter", {
340
+ label: "Runs cancelled",
341
+ unit: "count",
342
+ }),
343
+ metricDefinition("runsResumedTotal", runsResumedTotal, "smithers.runs.resumed_total", "counter", {
344
+ label: "Runs resumed",
345
+ unit: "count",
346
+ }),
347
+ metricDefinition("runsContinuedTotal", runsContinuedTotal, "smithers.runs.continued_total", "counter", {
348
+ label: "Runs continued",
349
+ unit: "count",
350
+ }),
351
+ metricDefinition("supervisorPollsTotal", supervisorPollsTotal, "smithers.supervisor.polls_total", "counter", {
352
+ label: "Supervisor polls",
353
+ unit: "count",
354
+ }),
355
+ metricDefinition(
356
+ "supervisorStaleDetected",
357
+ supervisorStaleDetected,
358
+ "smithers.supervisor.stale_detected",
359
+ "counter",
360
+ { label: "Supervisor stale runs detected", unit: "count" },
361
+ ),
362
+ metricDefinition("supervisorResumedTotal", supervisorResumedTotal, "smithers.supervisor.resumed_total", "counter", {
363
+ label: "Supervisor auto-resumes",
364
+ unit: "count",
365
+ }),
366
+ metricDefinition("supervisorSkippedTotal", supervisorSkippedTotal, "smithers.supervisor.skipped_total", "counter", {
367
+ label: "Supervisor skipped auto-resumes",
368
+ unit: "count",
369
+ labels: ["reason"],
370
+ }),
371
+ metricDefinition("errorsTotal", errorsTotal, "smithers.errors.total", "counter", { label: "Errors", unit: "count" }),
372
+ metricDefinition("nodeRetriesTotal", nodeRetriesTotal, "smithers.node.retries_total", "counter", {
373
+ label: "Node retries",
374
+ unit: "count",
375
+ }),
376
+ metricDefinition("toolCallErrorsTotal", toolCallErrorsTotal, "smithers.tool_calls.errors_total", "counter", {
377
+ label: "Tool call errors",
378
+ unit: "count",
379
+ }),
380
+ metricDefinition(
381
+ "toolOutputTruncatedTotal",
382
+ toolOutputTruncatedTotal,
383
+ "smithers.tool.output_truncated_total",
384
+ "counter",
385
+ { label: "Tool outputs truncated", unit: "count" },
386
+ ),
387
+ metricDefinition("agentInvocationsTotal", agentInvocationsTotal, "smithers.agent_invocations_total", "counter", {
388
+ label: "Agent invocations",
389
+ unit: "count",
390
+ labels: ["engine", "model"],
391
+ }),
392
+ metricDefinition("agentTokensTotal", agentTokensTotal, "smithers.agent_tokens_total", "counter", {
393
+ label: "Agent tokens",
394
+ unit: "tokens",
395
+ labels: ["engine", "model", "kind", "source"],
396
+ }),
397
+ metricDefinition("agentErrorsTotal", agentErrorsTotal, "smithers.agent_errors_total", "counter", {
398
+ label: "Agent errors",
399
+ unit: "count",
400
+ labels: ["engine", "model", "reason", "source"],
401
+ }),
402
+ metricDefinition("agentRetriesTotal", agentRetriesTotal, "smithers.agent_retries_total", "counter", {
403
+ label: "Agent retries",
404
+ unit: "count",
405
+ labels: ["engine", "model", "reason", "source"],
406
+ }),
407
+ metricDefinition("agentEventsTotal", agentEventsTotal, "smithers.agent_events_total", "counter", {
408
+ label: "Agent events",
409
+ unit: "count",
410
+ labels: ["engine", "event_type", "source"],
411
+ }),
412
+ metricDefinition("agentSessionsTotal", agentSessionsTotal, "smithers.agent_sessions_total", "counter", {
413
+ label: "Agent sessions",
414
+ unit: "count",
415
+ labels: ["engine", "model", "resume", "source", "status"],
416
+ }),
417
+ metricDefinition("agentActionsTotal", agentActionsTotal, "smithers.agent_actions_total", "counter", {
418
+ label: "Agent actions",
419
+ unit: "count",
420
+ labels: ["action_kind", "engine", "entry_type", "level", "ok", "phase", "source"],
421
+ }),
422
+ metricDefinition(
423
+ "gatewayConnectionsTotal",
424
+ gatewayConnectionsTotal,
425
+ "smithers.gateway.connections_total",
426
+ "counter",
427
+ {
428
+ label: "Gateway connections opened",
429
+ unit: "count",
430
+ labels: ["transport"],
431
+ },
432
+ ),
433
+ metricDefinition(
434
+ "gatewayConnectionsClosedTotal",
435
+ gatewayConnectionsClosedTotal,
436
+ "smithers.gateway.connections_closed_total",
437
+ "counter",
438
+ {
439
+ label: "Gateway connections closed",
440
+ unit: "count",
441
+ labels: ["code", "reason", "transport"],
442
+ },
443
+ ),
444
+ metricDefinition(
445
+ "gatewayMessagesReceivedTotal",
446
+ gatewayMessagesReceivedTotal,
447
+ "smithers.gateway.messages_received_total",
448
+ "counter",
449
+ {
450
+ label: "Gateway messages received",
451
+ unit: "count",
452
+ labels: ["kind", "transport"],
453
+ },
454
+ ),
455
+ metricDefinition(
456
+ "gatewayMessagesSentTotal",
457
+ gatewayMessagesSentTotal,
458
+ "smithers.gateway.messages_sent_total",
459
+ "counter",
460
+ {
461
+ label: "Gateway messages sent",
462
+ unit: "count",
463
+ labels: ["kind", "transport"],
464
+ },
465
+ ),
466
+ metricDefinition("gatewayRpcCallsTotal", gatewayRpcCallsTotal, "smithers.gateway.rpc_calls_total", "counter", {
467
+ label: "Gateway RPC calls",
468
+ unit: "count",
469
+ labels: ["method", "transport"],
470
+ }),
471
+ metricDefinition("gatewayErrorsTotal", gatewayErrorsTotal, "smithers.gateway.errors_total", "counter", {
472
+ label: "Gateway errors",
473
+ unit: "count",
474
+ labels: ["code", "stage", "transport"],
475
+ }),
476
+ metricDefinition(
477
+ "gatewayRunsStartedTotal",
478
+ gatewayRunsStartedTotal,
479
+ "smithers.gateway.runs_started_total",
480
+ "counter",
481
+ {
482
+ label: "Gateway runs started",
483
+ unit: "count",
484
+ labels: ["transport"],
485
+ },
486
+ ),
487
+ metricDefinition(
488
+ "gatewayRunsCompletedTotal",
489
+ gatewayRunsCompletedTotal,
490
+ "smithers.gateway.runs_completed_total",
491
+ "counter",
492
+ {
493
+ label: "Gateway runs completed",
494
+ unit: "count",
495
+ labels: ["status", "transport"],
496
+ },
497
+ ),
498
+ metricDefinition(
499
+ "gatewayApprovalDecisionsTotal",
500
+ gatewayApprovalDecisionsTotal,
501
+ "smithers.gateway.approval_decisions_total",
502
+ "counter",
503
+ {
504
+ label: "Gateway approval decisions",
505
+ unit: "count",
506
+ labels: ["decision", "transport"],
507
+ },
508
+ ),
509
+ metricDefinition("gatewaySignalsTotal", gatewaySignalsTotal, "smithers.gateway.signals_total", "counter", {
510
+ label: "Gateway signals",
511
+ unit: "count",
512
+ labels: ["outcome", "transport"],
513
+ }),
514
+ metricDefinition("gatewayAuthEventsTotal", gatewayAuthEventsTotal, "smithers.gateway.auth_events_total", "counter", {
515
+ label: "Gateway auth events",
516
+ unit: "count",
517
+ labels: ["outcome", "transport"],
518
+ }),
519
+ metricDefinition(
520
+ "gatewayHeartbeatTicksTotal",
521
+ gatewayHeartbeatTicksTotal,
522
+ "smithers.gateway.heartbeat_ticks_total",
523
+ "counter",
524
+ { label: "Gateway heartbeats", unit: "count" },
525
+ ),
526
+ metricDefinition(
527
+ "gatewayCronTriggersTotal",
528
+ gatewayCronTriggersTotal,
529
+ "smithers.gateway.cron_triggers_total",
530
+ "counter",
531
+ {
532
+ label: "Gateway cron triggers",
533
+ unit: "count",
534
+ labels: ["source"],
535
+ },
536
+ ),
537
+ metricDefinition(
538
+ "gatewayWebhooksReceivedTotal",
539
+ gatewayWebhooksReceivedTotal,
540
+ "smithers.gateway.webhooks_received_total",
541
+ "counter",
542
+ {
543
+ label: "Gateway webhooks received",
544
+ unit: "count",
545
+ labels: ["provider"],
546
+ },
547
+ ),
548
+ metricDefinition(
549
+ "gatewayWebhooksVerifiedTotal",
550
+ gatewayWebhooksVerifiedTotal,
551
+ "smithers.gateway.webhooks_verified_total",
552
+ "counter",
553
+ {
554
+ label: "Gateway webhooks verified",
555
+ unit: "count",
556
+ labels: ["provider"],
557
+ },
558
+ ),
559
+ metricDefinition(
560
+ "gatewayWebhooksRejectedTotal",
561
+ gatewayWebhooksRejectedTotal,
562
+ "smithers.gateway.webhooks_rejected_total",
563
+ "counter",
564
+ {
565
+ label: "Gateway webhooks rejected",
566
+ unit: "count",
567
+ labels: ["provider", "reason"],
568
+ },
569
+ ),
570
+ metricDefinition("eventsEmittedTotal", eventsEmittedTotal, "smithers.events.emitted_total", "counter", {
571
+ label: "Events emitted",
572
+ unit: "count",
573
+ }),
574
+ metricDefinition("taskHeartbeatsTotal", taskHeartbeatsTotal, "smithers.heartbeats.total", "counter", {
575
+ label: "Task heartbeats",
576
+ unit: "count",
577
+ }),
578
+ metricDefinition(
579
+ "taskHeartbeatTimeoutTotal",
580
+ taskHeartbeatTimeoutTotal,
581
+ "smithers.heartbeats.timeout_total",
582
+ "counter",
583
+ { label: "Task heartbeat timeouts", unit: "count" },
584
+ ),
585
+ metricDefinition("memoryFactReads", memoryFactReads, "smithers.memory.fact_reads", "counter", {
586
+ label: "Memory fact reads",
587
+ unit: "count",
588
+ }),
589
+ metricDefinition("memoryFactWrites", memoryFactWrites, "smithers.memory.fact_writes", "counter", {
590
+ label: "Memory fact writes",
591
+ unit: "count",
592
+ }),
593
+ metricDefinition("memoryRecallQueries", memoryRecallQueries, "smithers.memory.recall_queries", "counter", {
594
+ label: "Memory recall queries",
595
+ unit: "count",
596
+ }),
597
+ metricDefinition("memoryMessageSaves", memoryMessageSaves, "smithers.memory.message_saves", "counter", {
598
+ label: "Memory messages saved",
599
+ unit: "count",
600
+ }),
601
+ metricDefinition("openApiToolCallsTotal", openApiToolCallsTotal, "smithers.openapi.tool_calls", "counter", {
602
+ label: "OpenAPI tool calls",
603
+ unit: "count",
604
+ }),
605
+ metricDefinition(
606
+ "openApiToolCallErrorsTotal",
607
+ openApiToolCallErrorsTotal,
608
+ "smithers.openapi.tool_call_errors",
609
+ "counter",
610
+ { label: "OpenAPI tool call errors", unit: "count" },
611
+ ),
612
+ metricDefinition("scorersStarted", scorersStarted, "smithers.scorers.started", "counter", {
613
+ label: "Scorers started",
614
+ unit: "count",
615
+ }),
616
+ metricDefinition("scorersFinished", scorersFinished, "smithers.scorers.finished", "counter", {
617
+ label: "Scorers finished",
618
+ unit: "count",
619
+ }),
620
+ metricDefinition("scorersFailed", scorersFailed, "smithers.scorers.failed", "counter", {
621
+ label: "Scorers failed",
622
+ unit: "count",
623
+ }),
624
+ metricDefinition("snapshotsCaptured", snapshotsCaptured, "smithers.snapshots.captured", "counter", {
625
+ label: "Snapshots captured",
626
+ unit: "count",
627
+ }),
628
+ metricDefinition("runForksCreated", runForksCreated, "smithers.forks.created", "counter", {
629
+ label: "Run forks created",
630
+ unit: "count",
631
+ }),
632
+ metricDefinition("replaysStarted", replaysStarted, "smithers.replays.started", "counter", {
633
+ label: "Replays started",
634
+ unit: "count",
635
+ }),
636
+ metricDefinition("activeRuns", activeRuns, "smithers.runs.active", "gauge", { label: "Active runs", unit: "count" }),
637
+ metricDefinition("activeNodes", activeNodes, "smithers.nodes.active", "gauge", {
638
+ label: "Active nodes",
639
+ unit: "count",
640
+ }),
641
+ metricDefinition("schedulerQueueDepth", schedulerQueueDepth, "smithers.scheduler.queue_depth", "gauge", {
642
+ label: "Scheduler queue depth",
643
+ unit: "count",
644
+ }),
645
+ metricDefinition("sandboxActive", sandboxActive, "smithers.sandbox.active", "gauge", {
646
+ label: "Active sandboxes",
647
+ unit: "count",
648
+ labels: ["runtime"],
649
+ }),
650
+ metricDefinition("alertsActive", alertsActive, "smithers.alerts.active", "gauge", {
651
+ label: "Active alerts",
652
+ unit: "count",
653
+ labels: ["policy"],
654
+ }),
655
+ metricDefinition(
656
+ "gatewayConnectionsActive",
657
+ gatewayConnectionsActive,
658
+ "smithers.gateway.connections_active",
659
+ "gauge",
660
+ {
661
+ label: "Active gateway connections",
662
+ unit: "count",
663
+ labels: ["transport"],
664
+ },
665
+ ),
666
+ metricDefinition("approvalPending", approvalPending, "smithers.approval.pending", "gauge", {
667
+ label: "Pending approvals",
668
+ unit: "count",
669
+ }),
670
+ metricDefinition(
671
+ "externalWaitAsyncPending",
672
+ externalWaitAsyncPending,
673
+ "smithers.external_wait.async_pending",
674
+ "gauge",
675
+ {
676
+ label: "Pending external waits",
677
+ unit: "count",
678
+ labels: ["kind"],
679
+ defaultLabels: [{ kind: "approval" }, { kind: "event" }],
680
+ },
681
+ ),
682
+ metricDefinition("timersPending", timersPending, "smithers.timers.pending", "gauge", {
683
+ label: "Pending timers",
684
+ unit: "count",
685
+ }),
686
+ metricDefinition(
687
+ "schedulerConcurrencyUtilization",
688
+ schedulerConcurrencyUtilization,
689
+ "smithers.scheduler.concurrency_utilization",
690
+ "gauge",
691
+ {
692
+ label: "Scheduler concurrency utilization",
693
+ unit: "ratio",
694
+ },
695
+ ),
696
+ metricDefinition("processUptimeSeconds", processUptimeSeconds, "smithers.process.uptime_seconds", "gauge", {
697
+ label: "Process uptime",
698
+ unit: "seconds",
699
+ }),
700
+ metricDefinition("processMemoryRssBytes", processMemoryRssBytes, "smithers.process.memory_rss_bytes", "gauge", {
701
+ label: "Process RSS memory",
702
+ unit: "bytes",
703
+ }),
704
+ metricDefinition("processHeapUsedBytes", processHeapUsedBytes, "smithers.process.heap_used_bytes", "gauge", {
705
+ label: "Process heap used",
706
+ unit: "bytes",
707
+ }),
708
+ metricDefinition("nodeDuration", nodeDuration, "smithers.node.duration_ms", "histogram", {
709
+ label: "Node duration",
710
+ unit: "milliseconds",
711
+ boundaries: durationBucketValues,
712
+ }),
713
+ metricDefinition("attemptDuration", attemptDuration, "smithers.attempt.duration_ms", "histogram", {
714
+ label: "Attempt duration",
715
+ unit: "milliseconds",
716
+ boundaries: durationBucketValues,
717
+ }),
718
+ metricDefinition("toolDuration", toolDuration, "smithers.tool.duration_ms", "histogram", {
719
+ label: "Tool duration",
720
+ unit: "milliseconds",
721
+ boundaries: toolBucketValues,
722
+ }),
723
+ metricDefinition("dbQueryDuration", dbQueryDuration, "smithers.db.query_ms", "histogram", {
724
+ label: "DB query duration",
725
+ unit: "milliseconds",
726
+ boundaries: fastBucketValues,
727
+ }),
728
+ metricDefinition("dbTransactionDuration", dbTransactionDuration, "smithers.db.transaction_ms", "histogram", {
729
+ label: "DB transaction duration",
730
+ unit: "milliseconds",
731
+ boundaries: fastBucketValues,
732
+ }),
733
+ metricDefinition("httpRequestDuration", httpRequestDuration, "smithers.http.request_duration_ms", "histogram", {
734
+ label: "HTTP request duration",
735
+ unit: "milliseconds",
736
+ labels: ["method", "route", "status_code", "status_class"],
737
+ boundaries: fastBucketValues,
738
+ }),
739
+ metricDefinition("hotReloadDuration", hotReloadDuration, "smithers.hot.reload_duration_ms", "histogram", {
740
+ label: "Hot reload duration",
741
+ unit: "milliseconds",
742
+ boundaries: durationBucketValues,
743
+ }),
744
+ metricDefinition("vcsDuration", vcsDuration, "smithers.vcs.duration_ms", "histogram", {
745
+ label: "VCS duration",
746
+ unit: "milliseconds",
747
+ boundaries: fastBucketValues,
748
+ }),
749
+ metricDefinition("agentDurationMs", agentDurationMs, "smithers.agent_duration_ms", "histogram", {
750
+ label: "Agent duration",
751
+ unit: "milliseconds",
752
+ labels: ["engine", "model"],
753
+ boundaries: durationBucketValues,
754
+ }),
755
+ metricDefinition("tokensInputPerCall", tokensInputPerCall, "smithers.tokens.input_per_call", "histogram", {
756
+ label: "Input tokens per call",
757
+ unit: "tokens",
758
+ labels: ["agent", "model"],
759
+ boundaries: tokenBucketValues,
760
+ }),
761
+ metricDefinition("tokensOutputPerCall", tokensOutputPerCall, "smithers.tokens.output_per_call", "histogram", {
762
+ label: "Output tokens per call",
763
+ unit: "tokens",
764
+ labels: ["agent", "model"],
765
+ boundaries: tokenBucketValues,
766
+ }),
767
+ metricDefinition(
768
+ "tokensContextWindowPerCall",
769
+ tokensContextWindowPerCall,
770
+ "smithers.tokens.context_window_per_call",
771
+ "histogram",
772
+ {
773
+ label: "Context window per call",
774
+ unit: "tokens",
775
+ labels: ["agent", "model"],
776
+ boundaries: contextWindowBucketValues,
777
+ },
778
+ ),
779
+ metricDefinition("runDuration", runDuration, "smithers.run.duration_ms", "histogram", {
780
+ label: "Run duration",
781
+ unit: "milliseconds",
782
+ boundaries: durationBucketValues,
783
+ }),
784
+ metricDefinition("promptSizeBytes", promptSizeBytes, "smithers.prompt.size_bytes", "histogram", {
785
+ label: "Prompt size",
786
+ unit: "bytes",
787
+ boundaries: sizeBucketValues,
788
+ }),
789
+ metricDefinition("responseSizeBytes", responseSizeBytes, "smithers.response.size_bytes", "histogram", {
790
+ label: "Response size",
791
+ unit: "bytes",
792
+ boundaries: sizeBucketValues,
793
+ }),
794
+ metricDefinition("approvalWaitDuration", approvalWaitDuration, "smithers.approval.wait_duration_ms", "histogram", {
795
+ label: "Approval wait duration",
796
+ unit: "milliseconds",
797
+ boundaries: durationBucketValues,
798
+ }),
799
+ metricDefinition("timerDelayDuration", timerDelayDuration, "smithers.timers.delay_ms", "histogram", {
800
+ label: "Timer delay",
801
+ unit: "milliseconds",
802
+ boundaries: durationBucketValues,
803
+ }),
804
+ metricDefinition("gatewayRpcDuration", gatewayRpcDuration, "smithers.gateway.rpc_duration_ms", "histogram", {
805
+ label: "Gateway RPC duration",
806
+ unit: "milliseconds",
807
+ labels: ["method", "transport"],
808
+ boundaries: durationBucketValues,
809
+ }),
810
+ metricDefinition("schedulerWaitDuration", schedulerWaitDuration, "smithers.scheduler.wait_duration_ms", "histogram", {
811
+ label: "Scheduler wait duration",
812
+ unit: "milliseconds",
813
+ boundaries: durationBucketValues,
814
+ }),
815
+ metricDefinition(
816
+ "supervisorPollDuration",
817
+ supervisorPollDuration,
818
+ "smithers.supervisor.poll_duration_ms",
819
+ "histogram",
820
+ { label: "Supervisor poll duration", unit: "milliseconds", boundaries: fastBucketValues },
821
+ ),
822
+ metricDefinition("supervisorResumeLag", supervisorResumeLag, "smithers.supervisor.resume_lag_ms", "histogram", {
823
+ label: "Supervisor resume lag",
824
+ unit: "milliseconds",
825
+ boundaries: durationBucketValues,
826
+ }),
827
+ metricDefinition("runsAncestryDepth", runsAncestryDepth, "smithers.runs.ancestry_depth", "histogram", {
828
+ label: "Run ancestry depth",
829
+ unit: "depth",
830
+ boundaries: ancestryDepthBucketValues,
831
+ }),
832
+ metricDefinition("runsCarriedStateBytes", runsCarriedStateBytes, "smithers.runs.carried_state_bytes", "histogram", {
833
+ label: "Run carried state size",
834
+ unit: "bytes",
835
+ boundaries: carriedStateSizeBucketValues,
836
+ }),
837
+ metricDefinition("sandboxDurationMs", sandboxDurationMs, "smithers.sandbox.duration_ms", "histogram", {
838
+ label: "Sandbox duration",
839
+ unit: "milliseconds",
840
+ boundaries: durationBucketValues,
841
+ }),
842
+ metricDefinition(
843
+ "sandboxBundleSizeBytes",
844
+ sandboxBundleSizeBytes,
845
+ "smithers.sandbox.bundle_size_bytes",
846
+ "histogram",
847
+ { label: "Sandbox bundle size", unit: "bytes", boundaries: sizeBucketValues },
848
+ ),
849
+ metricDefinition(
850
+ "sandboxTransportDurationMs",
851
+ sandboxTransportDurationMs,
852
+ "smithers.sandbox.transport_duration_ms",
853
+ "histogram",
854
+ { label: "Sandbox transport duration", unit: "milliseconds", boundaries: durationBucketValues },
855
+ ),
856
+ metricDefinition("sandboxPatchCount", sandboxPatchCount, "smithers.sandbox.patch_count", "histogram", {
857
+ label: "Sandbox patch count",
858
+ unit: "count",
859
+ boundaries: tokenBucketValues,
860
+ }),
861
+ metricDefinition(
862
+ "heartbeatDataSizeBytes",
863
+ heartbeatDataSizeBytes,
864
+ "smithers.heartbeats.data_size_bytes",
865
+ "histogram",
866
+ { label: "Heartbeat data size", unit: "bytes", boundaries: sizeBucketValues },
867
+ ),
868
+ metricDefinition("heartbeatIntervalMs", heartbeatIntervalMs, "smithers.heartbeats.interval_ms", "histogram", {
869
+ label: "Heartbeat interval",
870
+ unit: "milliseconds",
871
+ boundaries: fastBucketValues,
872
+ }),
873
+ metricDefinition("memoryRecallDuration", memoryRecallDuration, "smithers.memory.recall_duration_ms", "histogram", {
874
+ label: "Memory recall duration",
875
+ unit: "milliseconds",
876
+ boundaries: metricHistogramBoundaries(memoryRecallDuration),
877
+ }),
878
+ metricDefinition("openApiToolDuration", openApiToolDuration, "smithers.openapi.tool_duration_ms", "histogram", {
879
+ label: "OpenAPI tool duration",
880
+ unit: "milliseconds",
881
+ boundaries: metricHistogramBoundaries(openApiToolDuration),
882
+ }),
883
+ metricDefinition("scorerDuration", scorerDuration, "smithers.scorer.duration_ms", "histogram", {
884
+ label: "Scorer duration",
885
+ unit: "milliseconds",
886
+ boundaries: metricHistogramBoundaries(scorerDuration),
887
+ }),
888
+ metricDefinition("snapshotDuration", snapshotDuration, "smithers.snapshot.duration_ms", "histogram", {
889
+ label: "Snapshot duration",
890
+ unit: "milliseconds",
891
+ boundaries: metricHistogramBoundaries(snapshotDuration),
892
+ }),
893
+ ];