@smithers-orchestrator/observability 0.16.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 (202) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +44 -0
  3. package/src/MetricName.ts +1 -0
  4. package/src/MetricsServiceLive.js +9 -0
  5. package/src/ResolvedSmithersObservabilityOptions.ts +10 -0
  6. package/src/SmithersEvent.ts +603 -0
  7. package/src/SmithersLogFormat.ts +1 -0
  8. package/src/SmithersMetricDefinition.ts +15 -0
  9. package/src/SmithersMetricType.ts +1 -0
  10. package/src/SmithersMetricUnit.ts +8 -0
  11. package/src/SmithersObservability.js +6 -0
  12. package/src/SmithersObservabilityOptions.ts +10 -0
  13. package/src/SmithersObservabilityService.ts +15 -0
  14. package/src/_coreCorrelation/CorrelationContext.ts +10 -0
  15. package/src/_coreCorrelation/CorrelationContextLive.js +11 -0
  16. package/src/_coreCorrelation/CorrelationContextService.js +6 -0
  17. package/src/_coreCorrelation/CorrelationContextServiceShape.ts +14 -0
  18. package/src/_coreCorrelation/CorrelationPatch.ts +3 -0
  19. package/src/_coreCorrelation/_correlationStorage.js +4 -0
  20. package/src/_coreCorrelation/correlationContextFiberRef.js +2 -0
  21. package/src/_coreCorrelation/correlationContextToLogAnnotations.js +28 -0
  22. package/src/_coreCorrelation/getCurrentCorrelationContext.js +9 -0
  23. package/src/_coreCorrelation/getCurrentCorrelationContextEffect.js +11 -0
  24. package/src/_coreCorrelation/index.js +14 -0
  25. package/src/_coreCorrelation/mergeCorrelationContext.js +61 -0
  26. package/src/_coreCorrelation/runWithCorrelationContext.js +14 -0
  27. package/src/_coreCorrelation/updateCurrentCorrelationContext.js +19 -0
  28. package/src/_coreCorrelation/withCorrelationContext.js +15 -0
  29. package/src/_coreCorrelation/withCurrentCorrelationContext.js +13 -0
  30. package/src/_coreMetrics.js +510 -0
  31. package/src/_coreMetricsShape.ts +55 -0
  32. package/src/_corePrometheus.js +93 -0
  33. package/src/_corePrometheusShape.ts +11 -0
  34. package/src/_coreTracing.js +142 -0
  35. package/src/_coreTracingShape.ts +17 -0
  36. package/src/_smithersSpanAttributeAliases.js +19 -0
  37. package/src/_smithersTraceSpanStorage.js +3 -0
  38. package/src/annotateSmithersTrace.js +11 -0
  39. package/src/correlation.js +20 -0
  40. package/src/createSmithersObservabilityLayer.js +49 -0
  41. package/src/createSmithersOtelLayer.js +21 -0
  42. package/src/createSmithersRuntimeLayer.js +2 -0
  43. package/src/getCurrentSmithersTraceAnnotations.js +14 -0
  44. package/src/getCurrentSmithersTraceSpan.js +7 -0
  45. package/src/index.d.ts +1032 -0
  46. package/src/index.js +35 -0
  47. package/src/logging.js +91 -0
  48. package/src/makeSmithersSpanAttributes.js +20 -0
  49. package/src/metrics/SmithersMetricDefinition.ts +17 -0
  50. package/src/metrics/SmithersMetricType.ts +1 -0
  51. package/src/metrics/SmithersMetricUnit.ts +8 -0
  52. package/src/metrics/_asyncExternalWaitCounts.js +4 -0
  53. package/src/metrics/_buckets.js +43 -0
  54. package/src/metrics/_processStartMs.js +1 -0
  55. package/src/metrics/activeNodes.js +2 -0
  56. package/src/metrics/activeRuns.js +2 -0
  57. package/src/metrics/agentActionsTotal.js +2 -0
  58. package/src/metrics/agentDurationMs.js +3 -0
  59. package/src/metrics/agentErrorsTotal.js +2 -0
  60. package/src/metrics/agentEventsTotal.js +2 -0
  61. package/src/metrics/agentInvocationsTotal.js +2 -0
  62. package/src/metrics/agentRetriesTotal.js +2 -0
  63. package/src/metrics/agentSessionsTotal.js +2 -0
  64. package/src/metrics/agentTokensTotal.js +2 -0
  65. package/src/metrics/alertDeliveriesAttempted.js +2 -0
  66. package/src/metrics/alertDeliveriesSuppressed.js +2 -0
  67. package/src/metrics/alertsAcknowledgedTotal.js +2 -0
  68. package/src/metrics/alertsActive.js +2 -0
  69. package/src/metrics/alertsEscalatedTotal.js +2 -0
  70. package/src/metrics/alertsFiredTotal.js +2 -0
  71. package/src/metrics/alertsReopenedTotal.js +2 -0
  72. package/src/metrics/alertsResolvedTotal.js +2 -0
  73. package/src/metrics/alertsSilencedTotal.js +2 -0
  74. package/src/metrics/approvalPending.js +2 -0
  75. package/src/metrics/approvalWaitDuration.js +3 -0
  76. package/src/metrics/approvalsDenied.js +2 -0
  77. package/src/metrics/approvalsGranted.js +2 -0
  78. package/src/metrics/approvalsRequested.js +2 -0
  79. package/src/metrics/attemptDuration.js +3 -0
  80. package/src/metrics/attentionBacklog.js +2 -0
  81. package/src/metrics/cacheHits.js +2 -0
  82. package/src/metrics/cacheMisses.js +2 -0
  83. package/src/metrics/dbQueryDuration.js +3 -0
  84. package/src/metrics/dbRetries.js +2 -0
  85. package/src/metrics/dbTransactionDuration.js +3 -0
  86. package/src/metrics/dbTransactionRetries.js +2 -0
  87. package/src/metrics/dbTransactionRollbacks.js +2 -0
  88. package/src/metrics/devtoolsActiveSubscribers.js +2 -0
  89. package/src/metrics/devtoolsBackpressureDisconnectTotal.js +2 -0
  90. package/src/metrics/devtoolsDeltaBuildMs.js +3 -0
  91. package/src/metrics/devtoolsEventBytes.js +3 -0
  92. package/src/metrics/devtoolsEventTotal.js +2 -0
  93. package/src/metrics/devtoolsSnapshotBuildMs.js +3 -0
  94. package/src/metrics/devtoolsSubscribeTotal.js +2 -0
  95. package/src/metrics/errorsTotal.js +2 -0
  96. package/src/metrics/eventsEmittedTotal.js +2 -0
  97. package/src/metrics/externalWaitAsyncPending.js +2 -0
  98. package/src/metrics/gatewayApprovalDecisionsTotal.js +2 -0
  99. package/src/metrics/gatewayAuthEventsTotal.js +2 -0
  100. package/src/metrics/gatewayConnectionsActive.js +2 -0
  101. package/src/metrics/gatewayConnectionsClosedTotal.js +2 -0
  102. package/src/metrics/gatewayConnectionsTotal.js +2 -0
  103. package/src/metrics/gatewayCronTriggersTotal.js +2 -0
  104. package/src/metrics/gatewayErrorsTotal.js +2 -0
  105. package/src/metrics/gatewayHeartbeatTicksTotal.js +2 -0
  106. package/src/metrics/gatewayMessagesReceivedTotal.js +2 -0
  107. package/src/metrics/gatewayMessagesSentTotal.js +2 -0
  108. package/src/metrics/gatewayRpcCallsTotal.js +2 -0
  109. package/src/metrics/gatewayRpcDuration.js +3 -0
  110. package/src/metrics/gatewayRunsCompletedTotal.js +2 -0
  111. package/src/metrics/gatewayRunsStartedTotal.js +2 -0
  112. package/src/metrics/gatewaySignalsTotal.js +2 -0
  113. package/src/metrics/gatewayWebhooksReceivedTotal.js +2 -0
  114. package/src/metrics/gatewayWebhooksRejectedTotal.js +2 -0
  115. package/src/metrics/gatewayWebhooksVerifiedTotal.js +2 -0
  116. package/src/metrics/heartbeatDataSizeBytes.js +3 -0
  117. package/src/metrics/heartbeatIntervalMs.js +3 -0
  118. package/src/metrics/hotReloadDuration.js +3 -0
  119. package/src/metrics/hotReloadFailures.js +2 -0
  120. package/src/metrics/hotReloads.js +2 -0
  121. package/src/metrics/httpRequestDuration.js +3 -0
  122. package/src/metrics/httpRequests.js +2 -0
  123. package/src/metrics/index.js +151 -0
  124. package/src/metrics/metricsServiceAdapter.js +188 -0
  125. package/src/metrics/nodeDuration.js +3 -0
  126. package/src/metrics/nodeRetriesTotal.js +2 -0
  127. package/src/metrics/nodesFailed.js +2 -0
  128. package/src/metrics/nodesFinished.js +2 -0
  129. package/src/metrics/nodesStarted.js +2 -0
  130. package/src/metrics/processHeapUsedBytes.js +2 -0
  131. package/src/metrics/processMemoryRssBytes.js +2 -0
  132. package/src/metrics/processUptimeSeconds.js +2 -0
  133. package/src/metrics/promptSizeBytes.js +3 -0
  134. package/src/metrics/responseSizeBytes.js +3 -0
  135. package/src/metrics/rewindDurationMs.js +3 -0
  136. package/src/metrics/rewindFramesDeleted.js +3 -0
  137. package/src/metrics/rewindRollbackTotal.js +2 -0
  138. package/src/metrics/rewindSandboxesReverted.js +3 -0
  139. package/src/metrics/rewindTotal.js +2 -0
  140. package/src/metrics/runDuration.js +3 -0
  141. package/src/metrics/runsAncestryDepth.js +3 -0
  142. package/src/metrics/runsCancelledTotal.js +2 -0
  143. package/src/metrics/runsCarriedStateBytes.js +3 -0
  144. package/src/metrics/runsContinuedTotal.js +2 -0
  145. package/src/metrics/runsFailedTotal.js +2 -0
  146. package/src/metrics/runsFinishedTotal.js +2 -0
  147. package/src/metrics/runsResumedTotal.js +2 -0
  148. package/src/metrics/runsTotal.js +2 -0
  149. package/src/metrics/sandboxActive.js +2 -0
  150. package/src/metrics/sandboxBundleSizeBytes.js +3 -0
  151. package/src/metrics/sandboxCompletedTotal.js +2 -0
  152. package/src/metrics/sandboxCreatedTotal.js +2 -0
  153. package/src/metrics/sandboxDurationMs.js +3 -0
  154. package/src/metrics/sandboxPatchCount.js +3 -0
  155. package/src/metrics/sandboxTransportDurationMs.js +3 -0
  156. package/src/metrics/schedulerConcurrencyUtilization.js +2 -0
  157. package/src/metrics/schedulerQueueDepth.js +2 -0
  158. package/src/metrics/schedulerWaitDuration.js +3 -0
  159. package/src/metrics/scorerEventsFailed.js +2 -0
  160. package/src/metrics/scorerEventsFinished.js +2 -0
  161. package/src/metrics/scorerEventsStarted.js +2 -0
  162. package/src/metrics/smithersMetricCatalog.js +484 -0
  163. package/src/metrics/smithersMetricCatalogByKey.js +2 -0
  164. package/src/metrics/smithersMetricCatalogByName.js +2 -0
  165. package/src/metrics/smithersMetricCatalogByPrometheusName.js +2 -0
  166. package/src/metrics/supervisorPollDuration.js +3 -0
  167. package/src/metrics/supervisorPollsTotal.js +2 -0
  168. package/src/metrics/supervisorResumeLag.js +3 -0
  169. package/src/metrics/supervisorResumedTotal.js +2 -0
  170. package/src/metrics/supervisorSkippedTotal.js +2 -0
  171. package/src/metrics/supervisorStaleDetected.js +2 -0
  172. package/src/metrics/taskHeartbeatTimeoutTotal.js +2 -0
  173. package/src/metrics/taskHeartbeatsTotal.js +2 -0
  174. package/src/metrics/timerDelayDuration.js +3 -0
  175. package/src/metrics/timersCancelled.js +2 -0
  176. package/src/metrics/timersCreated.js +2 -0
  177. package/src/metrics/timersFired.js +2 -0
  178. package/src/metrics/timersPending.js +2 -0
  179. package/src/metrics/toPrometheusMetricName.js +8 -0
  180. package/src/metrics/tokensCacheReadTotal.js +2 -0
  181. package/src/metrics/tokensCacheWriteTotal.js +2 -0
  182. package/src/metrics/tokensContextWindowBucketTotal.js +2 -0
  183. package/src/metrics/tokensContextWindowPerCall.js +3 -0
  184. package/src/metrics/tokensInputPerCall.js +3 -0
  185. package/src/metrics/tokensInputTotal.js +2 -0
  186. package/src/metrics/tokensOutputPerCall.js +3 -0
  187. package/src/metrics/tokensOutputTotal.js +2 -0
  188. package/src/metrics/tokensReasoningTotal.js +2 -0
  189. package/src/metrics/toolCallErrorsTotal.js +2 -0
  190. package/src/metrics/toolCallsTotal.js +2 -0
  191. package/src/metrics/toolDuration.js +3 -0
  192. package/src/metrics/toolOutputTruncatedTotal.js +2 -0
  193. package/src/metrics/trackEvent.js +604 -0
  194. package/src/metrics/updateAsyncExternalWaitPending.js +14 -0
  195. package/src/metrics/updateProcessMetrics.js +17 -0
  196. package/src/metrics/vcsDuration.js +3 -0
  197. package/src/prometheusContentType.js +1 -0
  198. package/src/renderPrometheusMetrics.js +205 -0
  199. package/src/resolveSmithersObservabilityOptions.js +79 -0
  200. package/src/smithersMetrics.js +2 -0
  201. package/src/smithersSpanNames.js +6 -0
  202. package/src/withSmithersSpan.js +15 -0
@@ -0,0 +1,484 @@
1
+ import { toPrometheusMetricName } from "./toPrometheusMetricName.js";
2
+ import { durationBuckets, fastBuckets, toolBuckets, tokenBuckets, contextWindowBuckets, sizeBuckets, carriedStateSizeBuckets, ancestryDepthBuckets, } from "./_buckets.js";
3
+ // External package metrics
4
+ import { memoryFactReads, memoryFactWrites, memoryRecallDuration, memoryRecallQueries, memoryMessageSaves, } from "@smithers-orchestrator/memory/metrics";
5
+ import { openApiToolCallsTotal, openApiToolCallErrorsTotal, openApiToolDuration, } from "@smithers-orchestrator/openapi/metrics";
6
+ import { scorerDuration, scorersFailed, scorersFinished, scorersStarted, } from "@smithers-orchestrator/scorers/metrics";
7
+ import { replaysStarted, runForksCreated, snapshotDuration, snapshotsCaptured, } from "@smithers-orchestrator/time-travel/metrics";
8
+ // Local metric instances
9
+ import { runsTotal } from "./runsTotal.js";
10
+ import { nodesStarted } from "./nodesStarted.js";
11
+ import { nodesFinished } from "./nodesFinished.js";
12
+ import { nodesFailed } from "./nodesFailed.js";
13
+ import { toolCallsTotal } from "./toolCallsTotal.js";
14
+ import { cacheHits } from "./cacheHits.js";
15
+ import { cacheMisses } from "./cacheMisses.js";
16
+ import { dbRetries } from "./dbRetries.js";
17
+ import { dbTransactionRollbacks } from "./dbTransactionRollbacks.js";
18
+ import { dbTransactionRetries } from "./dbTransactionRetries.js";
19
+ import { hotReloads } from "./hotReloads.js";
20
+ import { hotReloadFailures } from "./hotReloadFailures.js";
21
+ import { httpRequests } from "./httpRequests.js";
22
+ import { approvalsRequested } from "./approvalsRequested.js";
23
+ import { approvalsGranted } from "./approvalsGranted.js";
24
+ import { approvalsDenied } from "./approvalsDenied.js";
25
+ import { timersCreated } from "./timersCreated.js";
26
+ import { timersFired } from "./timersFired.js";
27
+ import { timersCancelled } from "./timersCancelled.js";
28
+ import { sandboxCreatedTotal } from "./sandboxCreatedTotal.js";
29
+ import { sandboxCompletedTotal } from "./sandboxCompletedTotal.js";
30
+ import { alertsFiredTotal } from "./alertsFiredTotal.js";
31
+ import { alertsAcknowledgedTotal } from "./alertsAcknowledgedTotal.js";
32
+ import { scorerEventsStarted } from "./scorerEventsStarted.js";
33
+ import { scorerEventsFinished } from "./scorerEventsFinished.js";
34
+ import { scorerEventsFailed } from "./scorerEventsFailed.js";
35
+ import { tokensInputTotal } from "./tokensInputTotal.js";
36
+ import { tokensOutputTotal } from "./tokensOutputTotal.js";
37
+ import { tokensCacheReadTotal } from "./tokensCacheReadTotal.js";
38
+ import { tokensCacheWriteTotal } from "./tokensCacheWriteTotal.js";
39
+ import { tokensReasoningTotal } from "./tokensReasoningTotal.js";
40
+ import { tokensContextWindowBucketTotal } from "./tokensContextWindowBucketTotal.js";
41
+ import { runsFinishedTotal } from "./runsFinishedTotal.js";
42
+ import { runsFailedTotal } from "./runsFailedTotal.js";
43
+ import { runsCancelledTotal } from "./runsCancelledTotal.js";
44
+ import { runsResumedTotal } from "./runsResumedTotal.js";
45
+ import { runsContinuedTotal } from "./runsContinuedTotal.js";
46
+ import { supervisorPollsTotal } from "./supervisorPollsTotal.js";
47
+ import { supervisorStaleDetected } from "./supervisorStaleDetected.js";
48
+ import { supervisorResumedTotal } from "./supervisorResumedTotal.js";
49
+ import { supervisorSkippedTotal } from "./supervisorSkippedTotal.js";
50
+ import { errorsTotal } from "./errorsTotal.js";
51
+ import { nodeRetriesTotal } from "./nodeRetriesTotal.js";
52
+ import { toolCallErrorsTotal } from "./toolCallErrorsTotal.js";
53
+ import { toolOutputTruncatedTotal } from "./toolOutputTruncatedTotal.js";
54
+ import { agentInvocationsTotal } from "./agentInvocationsTotal.js";
55
+ import { agentTokensTotal } from "./agentTokensTotal.js";
56
+ import { agentErrorsTotal } from "./agentErrorsTotal.js";
57
+ import { agentRetriesTotal } from "./agentRetriesTotal.js";
58
+ import { agentEventsTotal } from "./agentEventsTotal.js";
59
+ import { agentSessionsTotal } from "./agentSessionsTotal.js";
60
+ import { agentActionsTotal } from "./agentActionsTotal.js";
61
+ import { gatewayConnectionsTotal } from "./gatewayConnectionsTotal.js";
62
+ import { gatewayConnectionsClosedTotal } from "./gatewayConnectionsClosedTotal.js";
63
+ import { gatewayMessagesReceivedTotal } from "./gatewayMessagesReceivedTotal.js";
64
+ import { gatewayMessagesSentTotal } from "./gatewayMessagesSentTotal.js";
65
+ import { gatewayRpcCallsTotal } from "./gatewayRpcCallsTotal.js";
66
+ import { gatewayErrorsTotal } from "./gatewayErrorsTotal.js";
67
+ import { gatewayRunsStartedTotal } from "./gatewayRunsStartedTotal.js";
68
+ import { gatewayRunsCompletedTotal } from "./gatewayRunsCompletedTotal.js";
69
+ import { gatewayApprovalDecisionsTotal } from "./gatewayApprovalDecisionsTotal.js";
70
+ import { gatewaySignalsTotal } from "./gatewaySignalsTotal.js";
71
+ import { gatewayAuthEventsTotal } from "./gatewayAuthEventsTotal.js";
72
+ import { gatewayHeartbeatTicksTotal } from "./gatewayHeartbeatTicksTotal.js";
73
+ import { gatewayCronTriggersTotal } from "./gatewayCronTriggersTotal.js";
74
+ import { gatewayWebhooksReceivedTotal } from "./gatewayWebhooksReceivedTotal.js";
75
+ import { gatewayWebhooksVerifiedTotal } from "./gatewayWebhooksVerifiedTotal.js";
76
+ import { gatewayWebhooksRejectedTotal } from "./gatewayWebhooksRejectedTotal.js";
77
+ import { eventsEmittedTotal } from "./eventsEmittedTotal.js";
78
+ import { taskHeartbeatsTotal } from "./taskHeartbeatsTotal.js";
79
+ import { taskHeartbeatTimeoutTotal } from "./taskHeartbeatTimeoutTotal.js";
80
+ import { activeRuns } from "./activeRuns.js";
81
+ import { activeNodes } from "./activeNodes.js";
82
+ import { schedulerQueueDepth } from "./schedulerQueueDepth.js";
83
+ import { sandboxActive } from "./sandboxActive.js";
84
+ import { alertsActive } from "./alertsActive.js";
85
+ import { gatewayConnectionsActive } from "./gatewayConnectionsActive.js";
86
+ import { approvalPending } from "./approvalPending.js";
87
+ import { externalWaitAsyncPending } from "./externalWaitAsyncPending.js";
88
+ import { timersPending } from "./timersPending.js";
89
+ import { schedulerConcurrencyUtilization } from "./schedulerConcurrencyUtilization.js";
90
+ import { processUptimeSeconds } from "./processUptimeSeconds.js";
91
+ import { processMemoryRssBytes } from "./processMemoryRssBytes.js";
92
+ import { processHeapUsedBytes } from "./processHeapUsedBytes.js";
93
+ import { nodeDuration } from "./nodeDuration.js";
94
+ import { attemptDuration } from "./attemptDuration.js";
95
+ import { toolDuration } from "./toolDuration.js";
96
+ import { dbQueryDuration } from "./dbQueryDuration.js";
97
+ import { dbTransactionDuration } from "./dbTransactionDuration.js";
98
+ import { httpRequestDuration } from "./httpRequestDuration.js";
99
+ import { hotReloadDuration } from "./hotReloadDuration.js";
100
+ import { vcsDuration } from "./vcsDuration.js";
101
+ import { agentDurationMs } from "./agentDurationMs.js";
102
+ import { tokensInputPerCall } from "./tokensInputPerCall.js";
103
+ import { tokensOutputPerCall } from "./tokensOutputPerCall.js";
104
+ import { tokensContextWindowPerCall } from "./tokensContextWindowPerCall.js";
105
+ import { runDuration } from "./runDuration.js";
106
+ import { promptSizeBytes } from "./promptSizeBytes.js";
107
+ import { responseSizeBytes } from "./responseSizeBytes.js";
108
+ import { approvalWaitDuration } from "./approvalWaitDuration.js";
109
+ import { timerDelayDuration } from "./timerDelayDuration.js";
110
+ import { gatewayRpcDuration } from "./gatewayRpcDuration.js";
111
+ import { schedulerWaitDuration } from "./schedulerWaitDuration.js";
112
+ import { supervisorPollDuration } from "./supervisorPollDuration.js";
113
+ import { supervisorResumeLag } from "./supervisorResumeLag.js";
114
+ import { runsAncestryDepth } from "./runsAncestryDepth.js";
115
+ import { runsCarriedStateBytes } from "./runsCarriedStateBytes.js";
116
+ import { sandboxDurationMs } from "./sandboxDurationMs.js";
117
+ import { sandboxBundleSizeBytes } from "./sandboxBundleSizeBytes.js";
118
+ import { sandboxTransportDurationMs } from "./sandboxTransportDurationMs.js";
119
+ import { sandboxPatchCount } from "./sandboxPatchCount.js";
120
+ import { heartbeatDataSizeBytes } from "./heartbeatDataSizeBytes.js";
121
+ import { heartbeatIntervalMs } from "./heartbeatIntervalMs.js";
122
+ /** @typedef {import("./SmithersMetricType.ts").SmithersMetricType} SmithersMetricType */
123
+
124
+ /** @typedef {import("./SmithersMetricDefinition.ts").SmithersMetricDefinition} SmithersMetricDefinition */
125
+
126
+ /**
127
+ * @param {any} boundaries
128
+ * @returns {readonly number[]}
129
+ */
130
+ function metricBoundaryValues(boundaries) {
131
+ return Array.from((boundaries?.values ?? [])).sort((left, right) => left - right);
132
+ }
133
+ /**
134
+ * @param {Metric.Metric<any, any, any>} metric
135
+ * @returns {readonly number[]}
136
+ */
137
+ function metricHistogramBoundaries(metric) {
138
+ return Array.from((metric?.keyType?.boundaries?.values ?? []))
139
+ .filter((value) => Number.isFinite(value))
140
+ .sort((left, right) => left - right);
141
+ }
142
+ /**
143
+ * @param {string} key
144
+ * @param {Metric.Metric<any, any, any>} metric
145
+ * @param {string} name
146
+ * @param {SmithersMetricType} type
147
+ * @param {Omit< SmithersMetricDefinition, "key" | "metric" | "name" | "prometheusName" | "type" >} options
148
+ * @returns {SmithersMetricDefinition}
149
+ */
150
+ function metricDefinition(key, metric, name, type, options) {
151
+ return {
152
+ key,
153
+ metric,
154
+ name,
155
+ prometheusName: toPrometheusMetricName(name),
156
+ type,
157
+ ...options,
158
+ };
159
+ }
160
+ const durationBucketValues = metricBoundaryValues(durationBuckets);
161
+ const fastBucketValues = metricBoundaryValues(fastBuckets);
162
+ const toolBucketValues = metricBoundaryValues(toolBuckets);
163
+ const tokenBucketValues = metricBoundaryValues(tokenBuckets);
164
+ const contextWindowBucketValues = metricBoundaryValues(contextWindowBuckets);
165
+ const sizeBucketValues = metricBoundaryValues(sizeBuckets);
166
+ const carriedStateSizeBucketValues = metricBoundaryValues(carriedStateSizeBuckets);
167
+ const ancestryDepthBucketValues = metricBoundaryValues(ancestryDepthBuckets);
168
+ export const smithersMetricCatalog = [
169
+ metricDefinition("runsTotal", runsTotal, "smithers.runs.total", "counter", { label: "Runs started", unit: "count" }),
170
+ metricDefinition("nodesStarted", nodesStarted, "smithers.nodes.started", "counter", { label: "Nodes started", unit: "count" }),
171
+ metricDefinition("nodesFinished", nodesFinished, "smithers.nodes.finished", "counter", { label: "Nodes finished", unit: "count" }),
172
+ metricDefinition("nodesFailed", nodesFailed, "smithers.nodes.failed", "counter", { label: "Nodes failed", unit: "count" }),
173
+ metricDefinition("toolCallsTotal", toolCallsTotal, "smithers.tool_calls.total", "counter", { label: "Tool calls", unit: "count" }),
174
+ metricDefinition("cacheHits", cacheHits, "smithers.cache.hits", "counter", { label: "Cache hits", unit: "count" }),
175
+ metricDefinition("cacheMisses", cacheMisses, "smithers.cache.misses", "counter", { label: "Cache misses", unit: "count" }),
176
+ metricDefinition("dbRetries", dbRetries, "smithers.db.retries", "counter", { label: "DB retries", unit: "count" }),
177
+ metricDefinition("dbTransactionRollbacks", dbTransactionRollbacks, "smithers.db.transaction_rollbacks", "counter", { label: "DB transaction rollbacks", unit: "count" }),
178
+ metricDefinition("dbTransactionRetries", dbTransactionRetries, "smithers.db.transaction_retries", "counter", { label: "DB transaction retries", unit: "count" }),
179
+ metricDefinition("hotReloads", hotReloads, "smithers.hot.reloads", "counter", { label: "Hot reloads", unit: "count" }),
180
+ metricDefinition("hotReloadFailures", hotReloadFailures, "smithers.hot.reload_failures", "counter", { label: "Hot reload failures", unit: "count" }),
181
+ metricDefinition("httpRequests", httpRequests, "smithers.http.requests", "counter", {
182
+ label: "HTTP requests",
183
+ unit: "count",
184
+ labels: ["method", "route", "status_code", "status_class"],
185
+ }),
186
+ metricDefinition("approvalsRequested", approvalsRequested, "smithers.approvals.requested", "counter", { label: "Approvals requested", unit: "count" }),
187
+ metricDefinition("approvalsGranted", approvalsGranted, "smithers.approvals.granted", "counter", { label: "Approvals granted", unit: "count" }),
188
+ metricDefinition("approvalsDenied", approvalsDenied, "smithers.approvals.denied", "counter", { label: "Approvals denied", unit: "count" }),
189
+ metricDefinition("timersCreated", timersCreated, "smithers.timers.created", "counter", { label: "Timers created", unit: "count" }),
190
+ metricDefinition("timersFired", timersFired, "smithers.timers.fired", "counter", { label: "Timers fired", unit: "count" }),
191
+ metricDefinition("timersCancelled", timersCancelled, "smithers.timers.cancelled", "counter", { label: "Timers cancelled", unit: "count" }),
192
+ metricDefinition("sandboxCreatedTotal", sandboxCreatedTotal, "smithers.sandbox.created_total", "counter", {
193
+ label: "Sandboxes created",
194
+ unit: "count",
195
+ labels: ["runtime"],
196
+ }),
197
+ metricDefinition("sandboxCompletedTotal", sandboxCompletedTotal, "smithers.sandbox.completed_total", "counter", {
198
+ label: "Sandboxes completed",
199
+ unit: "count",
200
+ labels: ["runtime", "status"],
201
+ }),
202
+ metricDefinition("alertsFiredTotal", alertsFiredTotal, "smithers.alerts.fired_total", "counter", {
203
+ label: "Alerts fired",
204
+ unit: "count",
205
+ labels: ["policy"],
206
+ }),
207
+ metricDefinition("alertsAcknowledgedTotal", alertsAcknowledgedTotal, "smithers.alerts.acknowledged_total", "counter", {
208
+ label: "Alerts acknowledged",
209
+ unit: "count",
210
+ labels: ["policy"],
211
+ }),
212
+ metricDefinition("scorerEventsStarted", scorerEventsStarted, "smithers.scorer_events.started", "counter", { label: "Scorer events started", unit: "count" }),
213
+ metricDefinition("scorerEventsFinished", scorerEventsFinished, "smithers.scorer_events.finished", "counter", { label: "Scorer events finished", unit: "count" }),
214
+ metricDefinition("scorerEventsFailed", scorerEventsFailed, "smithers.scorer_events.failed", "counter", { label: "Scorer events failed", unit: "count" }),
215
+ metricDefinition("tokensInputTotal", tokensInputTotal, "smithers.tokens.input_total", "counter", {
216
+ label: "Input tokens",
217
+ unit: "tokens",
218
+ labels: ["agent", "model"],
219
+ }),
220
+ metricDefinition("tokensOutputTotal", tokensOutputTotal, "smithers.tokens.output_total", "counter", {
221
+ label: "Output tokens",
222
+ unit: "tokens",
223
+ labels: ["agent", "model"],
224
+ }),
225
+ metricDefinition("tokensCacheReadTotal", tokensCacheReadTotal, "smithers.tokens.cache_read_total", "counter", {
226
+ label: "Cache read tokens",
227
+ unit: "tokens",
228
+ labels: ["agent", "model"],
229
+ }),
230
+ metricDefinition("tokensCacheWriteTotal", tokensCacheWriteTotal, "smithers.tokens.cache_write_total", "counter", {
231
+ label: "Cache write tokens",
232
+ unit: "tokens",
233
+ labels: ["agent", "model"],
234
+ }),
235
+ metricDefinition("tokensReasoningTotal", tokensReasoningTotal, "smithers.tokens.reasoning_total", "counter", {
236
+ label: "Reasoning tokens",
237
+ unit: "tokens",
238
+ labels: ["agent", "model"],
239
+ }),
240
+ metricDefinition("tokensContextWindowBucketTotal", tokensContextWindowBucketTotal, "smithers.tokens.context_window_bucket_total", "counter", {
241
+ label: "Context window bucket hits",
242
+ unit: "count",
243
+ labels: ["agent", "bucket", "model"],
244
+ }),
245
+ metricDefinition("runsFinishedTotal", runsFinishedTotal, "smithers.runs.finished_total", "counter", { label: "Runs finished", unit: "count" }),
246
+ metricDefinition("runsFailedTotal", runsFailedTotal, "smithers.runs.failed_total", "counter", { label: "Runs failed", unit: "count" }),
247
+ metricDefinition("runsCancelledTotal", runsCancelledTotal, "smithers.runs.cancelled_total", "counter", { label: "Runs cancelled", unit: "count" }),
248
+ metricDefinition("runsResumedTotal", runsResumedTotal, "smithers.runs.resumed_total", "counter", { label: "Runs resumed", unit: "count" }),
249
+ metricDefinition("runsContinuedTotal", runsContinuedTotal, "smithers.runs.continued_total", "counter", { label: "Runs continued", unit: "count" }),
250
+ metricDefinition("supervisorPollsTotal", supervisorPollsTotal, "smithers.supervisor.polls_total", "counter", { label: "Supervisor polls", unit: "count" }),
251
+ metricDefinition("supervisorStaleDetected", supervisorStaleDetected, "smithers.supervisor.stale_detected", "counter", { label: "Supervisor stale runs detected", unit: "count" }),
252
+ metricDefinition("supervisorResumedTotal", supervisorResumedTotal, "smithers.supervisor.resumed_total", "counter", { label: "Supervisor auto-resumes", unit: "count" }),
253
+ metricDefinition("supervisorSkippedTotal", supervisorSkippedTotal, "smithers.supervisor.skipped_total", "counter", {
254
+ label: "Supervisor skipped auto-resumes",
255
+ unit: "count",
256
+ labels: ["reason"],
257
+ }),
258
+ metricDefinition("errorsTotal", errorsTotal, "smithers.errors.total", "counter", { label: "Errors", unit: "count" }),
259
+ metricDefinition("nodeRetriesTotal", nodeRetriesTotal, "smithers.node.retries_total", "counter", { label: "Node retries", unit: "count" }),
260
+ metricDefinition("toolCallErrorsTotal", toolCallErrorsTotal, "smithers.tool_calls.errors_total", "counter", { label: "Tool call errors", unit: "count" }),
261
+ metricDefinition("toolOutputTruncatedTotal", toolOutputTruncatedTotal, "smithers.tool.output_truncated_total", "counter", { label: "Tool outputs truncated", unit: "count" }),
262
+ metricDefinition("agentInvocationsTotal", agentInvocationsTotal, "smithers.agent_invocations_total", "counter", {
263
+ label: "Agent invocations",
264
+ unit: "count",
265
+ labels: ["engine", "model"],
266
+ }),
267
+ metricDefinition("agentTokensTotal", agentTokensTotal, "smithers.agent_tokens_total", "counter", {
268
+ label: "Agent tokens",
269
+ unit: "tokens",
270
+ labels: ["engine", "model", "kind", "source"],
271
+ }),
272
+ metricDefinition("agentErrorsTotal", agentErrorsTotal, "smithers.agent_errors_total", "counter", {
273
+ label: "Agent errors",
274
+ unit: "count",
275
+ labels: ["engine", "model", "reason", "source"],
276
+ }),
277
+ metricDefinition("agentRetriesTotal", agentRetriesTotal, "smithers.agent_retries_total", "counter", {
278
+ label: "Agent retries",
279
+ unit: "count",
280
+ labels: ["engine", "model", "reason", "source"],
281
+ }),
282
+ metricDefinition("agentEventsTotal", agentEventsTotal, "smithers.agent_events_total", "counter", {
283
+ label: "Agent events",
284
+ unit: "count",
285
+ labels: ["engine", "event_type", "source"],
286
+ }),
287
+ metricDefinition("agentSessionsTotal", agentSessionsTotal, "smithers.agent_sessions_total", "counter", {
288
+ label: "Agent sessions",
289
+ unit: "count",
290
+ labels: ["engine", "model", "resume", "source", "status"],
291
+ }),
292
+ metricDefinition("agentActionsTotal", agentActionsTotal, "smithers.agent_actions_total", "counter", {
293
+ label: "Agent actions",
294
+ unit: "count",
295
+ labels: ["action_name", "action_type", "engine", "source"],
296
+ }),
297
+ metricDefinition("gatewayConnectionsTotal", gatewayConnectionsTotal, "smithers.gateway.connections_total", "counter", {
298
+ label: "Gateway connections opened",
299
+ unit: "count",
300
+ labels: ["transport"],
301
+ }),
302
+ metricDefinition("gatewayConnectionsClosedTotal", gatewayConnectionsClosedTotal, "smithers.gateway.connections_closed_total", "counter", {
303
+ label: "Gateway connections closed",
304
+ unit: "count",
305
+ labels: ["code", "reason", "transport"],
306
+ }),
307
+ metricDefinition("gatewayMessagesReceivedTotal", gatewayMessagesReceivedTotal, "smithers.gateway.messages_received_total", "counter", {
308
+ label: "Gateway messages received",
309
+ unit: "count",
310
+ labels: ["kind", "transport"],
311
+ }),
312
+ metricDefinition("gatewayMessagesSentTotal", gatewayMessagesSentTotal, "smithers.gateway.messages_sent_total", "counter", {
313
+ label: "Gateway messages sent",
314
+ unit: "count",
315
+ labels: ["kind", "transport"],
316
+ }),
317
+ metricDefinition("gatewayRpcCallsTotal", gatewayRpcCallsTotal, "smithers.gateway.rpc_calls_total", "counter", {
318
+ label: "Gateway RPC calls",
319
+ unit: "count",
320
+ labels: ["method", "transport"],
321
+ }),
322
+ metricDefinition("gatewayErrorsTotal", gatewayErrorsTotal, "smithers.gateway.errors_total", "counter", {
323
+ label: "Gateway errors",
324
+ unit: "count",
325
+ labels: ["code", "stage", "transport"],
326
+ }),
327
+ metricDefinition("gatewayRunsStartedTotal", gatewayRunsStartedTotal, "smithers.gateway.runs_started_total", "counter", {
328
+ label: "Gateway runs started",
329
+ unit: "count",
330
+ labels: ["transport"],
331
+ }),
332
+ metricDefinition("gatewayRunsCompletedTotal", gatewayRunsCompletedTotal, "smithers.gateway.runs_completed_total", "counter", {
333
+ label: "Gateway runs completed",
334
+ unit: "count",
335
+ labels: ["status", "transport"],
336
+ }),
337
+ metricDefinition("gatewayApprovalDecisionsTotal", gatewayApprovalDecisionsTotal, "smithers.gateway.approval_decisions_total", "counter", {
338
+ label: "Gateway approval decisions",
339
+ unit: "count",
340
+ labels: ["decision", "transport"],
341
+ }),
342
+ metricDefinition("gatewaySignalsTotal", gatewaySignalsTotal, "smithers.gateway.signals_total", "counter", {
343
+ label: "Gateway signals",
344
+ unit: "count",
345
+ labels: ["outcome", "transport"],
346
+ }),
347
+ metricDefinition("gatewayAuthEventsTotal", gatewayAuthEventsTotal, "smithers.gateway.auth_events_total", "counter", {
348
+ label: "Gateway auth events",
349
+ unit: "count",
350
+ labels: ["outcome", "transport"],
351
+ }),
352
+ metricDefinition("gatewayHeartbeatTicksTotal", gatewayHeartbeatTicksTotal, "smithers.gateway.heartbeat_ticks_total", "counter", { label: "Gateway heartbeats", unit: "count" }),
353
+ metricDefinition("gatewayCronTriggersTotal", gatewayCronTriggersTotal, "smithers.gateway.cron_triggers_total", "counter", {
354
+ label: "Gateway cron triggers",
355
+ unit: "count",
356
+ labels: ["source"],
357
+ }),
358
+ metricDefinition("gatewayWebhooksReceivedTotal", gatewayWebhooksReceivedTotal, "smithers.gateway.webhooks_received_total", "counter", {
359
+ label: "Gateway webhooks received",
360
+ unit: "count",
361
+ labels: ["provider"],
362
+ }),
363
+ metricDefinition("gatewayWebhooksVerifiedTotal", gatewayWebhooksVerifiedTotal, "smithers.gateway.webhooks_verified_total", "counter", {
364
+ label: "Gateway webhooks verified",
365
+ unit: "count",
366
+ labels: ["provider"],
367
+ }),
368
+ metricDefinition("gatewayWebhooksRejectedTotal", gatewayWebhooksRejectedTotal, "smithers.gateway.webhooks_rejected_total", "counter", {
369
+ label: "Gateway webhooks rejected",
370
+ unit: "count",
371
+ labels: ["provider", "reason"],
372
+ }),
373
+ metricDefinition("eventsEmittedTotal", eventsEmittedTotal, "smithers.events.emitted_total", "counter", { label: "Events emitted", unit: "count" }),
374
+ metricDefinition("taskHeartbeatsTotal", taskHeartbeatsTotal, "smithers.heartbeats.total", "counter", { label: "Task heartbeats", unit: "count" }),
375
+ metricDefinition("taskHeartbeatTimeoutTotal", taskHeartbeatTimeoutTotal, "smithers.heartbeats.timeout_total", "counter", { label: "Task heartbeat timeouts", unit: "count" }),
376
+ metricDefinition("memoryFactReads", memoryFactReads, "smithers.memory.fact_reads", "counter", { label: "Memory fact reads", unit: "count" }),
377
+ metricDefinition("memoryFactWrites", memoryFactWrites, "smithers.memory.fact_writes", "counter", { label: "Memory fact writes", unit: "count" }),
378
+ metricDefinition("memoryRecallQueries", memoryRecallQueries, "smithers.memory.recall_queries", "counter", { label: "Memory recall queries", unit: "count" }),
379
+ metricDefinition("memoryMessageSaves", memoryMessageSaves, "smithers.memory.message_saves", "counter", { label: "Memory messages saved", unit: "count" }),
380
+ metricDefinition("openApiToolCallsTotal", openApiToolCallsTotal, "smithers.openapi.tool_calls", "counter", { label: "OpenAPI tool calls", unit: "count" }),
381
+ metricDefinition("openApiToolCallErrorsTotal", openApiToolCallErrorsTotal, "smithers.openapi.tool_call_errors", "counter", { label: "OpenAPI tool call errors", unit: "count" }),
382
+ metricDefinition("scorersStarted", scorersStarted, "smithers.scorers.started", "counter", { label: "Scorers started", unit: "count" }),
383
+ metricDefinition("scorersFinished", scorersFinished, "smithers.scorers.finished", "counter", { label: "Scorers finished", unit: "count" }),
384
+ metricDefinition("scorersFailed", scorersFailed, "smithers.scorers.failed", "counter", { label: "Scorers failed", unit: "count" }),
385
+ metricDefinition("snapshotsCaptured", snapshotsCaptured, "smithers.snapshots.captured", "counter", { label: "Snapshots captured", unit: "count" }),
386
+ metricDefinition("runForksCreated", runForksCreated, "smithers.forks.created", "counter", { label: "Run forks created", unit: "count" }),
387
+ metricDefinition("replaysStarted", replaysStarted, "smithers.replays.started", "counter", { label: "Replays started", unit: "count" }),
388
+ metricDefinition("activeRuns", activeRuns, "smithers.runs.active", "gauge", { label: "Active runs", unit: "count" }),
389
+ metricDefinition("activeNodes", activeNodes, "smithers.nodes.active", "gauge", { label: "Active nodes", unit: "count" }),
390
+ metricDefinition("schedulerQueueDepth", schedulerQueueDepth, "smithers.scheduler.queue_depth", "gauge", { label: "Scheduler queue depth", unit: "count" }),
391
+ metricDefinition("sandboxActive", sandboxActive, "smithers.sandbox.active", "gauge", {
392
+ label: "Active sandboxes",
393
+ unit: "count",
394
+ labels: ["runtime"],
395
+ }),
396
+ metricDefinition("alertsActive", alertsActive, "smithers.alerts.active", "gauge", {
397
+ label: "Active alerts",
398
+ unit: "count",
399
+ labels: ["policy"],
400
+ }),
401
+ metricDefinition("gatewayConnectionsActive", gatewayConnectionsActive, "smithers.gateway.connections_active", "gauge", {
402
+ label: "Active gateway connections",
403
+ unit: "count",
404
+ labels: ["transport"],
405
+ }),
406
+ metricDefinition("approvalPending", approvalPending, "smithers.approval.pending", "gauge", { label: "Pending approvals", unit: "count" }),
407
+ metricDefinition("externalWaitAsyncPending", externalWaitAsyncPending, "smithers.external_wait.async_pending", "gauge", {
408
+ label: "Pending external waits",
409
+ unit: "count",
410
+ labels: ["kind"],
411
+ defaultLabels: [{ kind: "approval" }, { kind: "event" }],
412
+ }),
413
+ metricDefinition("timersPending", timersPending, "smithers.timers.pending", "gauge", { label: "Pending timers", unit: "count" }),
414
+ metricDefinition("schedulerConcurrencyUtilization", schedulerConcurrencyUtilization, "smithers.scheduler.concurrency_utilization", "gauge", {
415
+ label: "Scheduler concurrency utilization",
416
+ unit: "ratio",
417
+ }),
418
+ metricDefinition("processUptimeSeconds", processUptimeSeconds, "smithers.process.uptime_seconds", "gauge", { label: "Process uptime", unit: "seconds" }),
419
+ metricDefinition("processMemoryRssBytes", processMemoryRssBytes, "smithers.process.memory_rss_bytes", "gauge", { label: "Process RSS memory", unit: "bytes" }),
420
+ metricDefinition("processHeapUsedBytes", processHeapUsedBytes, "smithers.process.heap_used_bytes", "gauge", { label: "Process heap used", unit: "bytes" }),
421
+ metricDefinition("nodeDuration", nodeDuration, "smithers.node.duration_ms", "histogram", { label: "Node duration", unit: "milliseconds", boundaries: durationBucketValues }),
422
+ metricDefinition("attemptDuration", attemptDuration, "smithers.attempt.duration_ms", "histogram", { label: "Attempt duration", unit: "milliseconds", boundaries: durationBucketValues }),
423
+ metricDefinition("toolDuration", toolDuration, "smithers.tool.duration_ms", "histogram", { label: "Tool duration", unit: "milliseconds", boundaries: toolBucketValues }),
424
+ metricDefinition("dbQueryDuration", dbQueryDuration, "smithers.db.query_ms", "histogram", { label: "DB query duration", unit: "milliseconds", boundaries: fastBucketValues }),
425
+ metricDefinition("dbTransactionDuration", dbTransactionDuration, "smithers.db.transaction_ms", "histogram", { label: "DB transaction duration", unit: "milliseconds", boundaries: fastBucketValues }),
426
+ metricDefinition("httpRequestDuration", httpRequestDuration, "smithers.http.request_duration_ms", "histogram", {
427
+ label: "HTTP request duration",
428
+ unit: "milliseconds",
429
+ labels: ["method", "route", "status_code", "status_class"],
430
+ boundaries: fastBucketValues,
431
+ }),
432
+ metricDefinition("hotReloadDuration", hotReloadDuration, "smithers.hot.reload_duration_ms", "histogram", { label: "Hot reload duration", unit: "milliseconds", boundaries: durationBucketValues }),
433
+ metricDefinition("vcsDuration", vcsDuration, "smithers.vcs.duration_ms", "histogram", { label: "VCS duration", unit: "milliseconds", boundaries: fastBucketValues }),
434
+ metricDefinition("agentDurationMs", agentDurationMs, "smithers.agent_duration_ms", "histogram", {
435
+ label: "Agent duration",
436
+ unit: "milliseconds",
437
+ labels: ["engine", "model"],
438
+ boundaries: durationBucketValues,
439
+ }),
440
+ metricDefinition("tokensInputPerCall", tokensInputPerCall, "smithers.tokens.input_per_call", "histogram", {
441
+ label: "Input tokens per call",
442
+ unit: "tokens",
443
+ labels: ["agent", "model"],
444
+ boundaries: tokenBucketValues,
445
+ }),
446
+ metricDefinition("tokensOutputPerCall", tokensOutputPerCall, "smithers.tokens.output_per_call", "histogram", {
447
+ label: "Output tokens per call",
448
+ unit: "tokens",
449
+ labels: ["agent", "model"],
450
+ boundaries: tokenBucketValues,
451
+ }),
452
+ metricDefinition("tokensContextWindowPerCall", tokensContextWindowPerCall, "smithers.tokens.context_window_per_call", "histogram", {
453
+ label: "Context window per call",
454
+ unit: "tokens",
455
+ labels: ["agent", "model"],
456
+ boundaries: contextWindowBucketValues,
457
+ }),
458
+ metricDefinition("runDuration", runDuration, "smithers.run.duration_ms", "histogram", { label: "Run duration", unit: "milliseconds", boundaries: durationBucketValues }),
459
+ metricDefinition("promptSizeBytes", promptSizeBytes, "smithers.prompt.size_bytes", "histogram", { label: "Prompt size", unit: "bytes", boundaries: sizeBucketValues }),
460
+ metricDefinition("responseSizeBytes", responseSizeBytes, "smithers.response.size_bytes", "histogram", { label: "Response size", unit: "bytes", boundaries: sizeBucketValues }),
461
+ metricDefinition("approvalWaitDuration", approvalWaitDuration, "smithers.approval.wait_duration_ms", "histogram", { label: "Approval wait duration", unit: "milliseconds", boundaries: durationBucketValues }),
462
+ metricDefinition("timerDelayDuration", timerDelayDuration, "smithers.timers.delay_ms", "histogram", { label: "Timer delay", unit: "milliseconds", boundaries: durationBucketValues }),
463
+ metricDefinition("gatewayRpcDuration", gatewayRpcDuration, "smithers.gateway.rpc_duration_ms", "histogram", {
464
+ label: "Gateway RPC duration",
465
+ unit: "milliseconds",
466
+ labels: ["method", "transport"],
467
+ boundaries: durationBucketValues,
468
+ }),
469
+ metricDefinition("schedulerWaitDuration", schedulerWaitDuration, "smithers.scheduler.wait_duration_ms", "histogram", { label: "Scheduler wait duration", unit: "milliseconds", boundaries: durationBucketValues }),
470
+ metricDefinition("supervisorPollDuration", supervisorPollDuration, "smithers.supervisor.poll_duration_ms", "histogram", { label: "Supervisor poll duration", unit: "milliseconds", boundaries: fastBucketValues }),
471
+ metricDefinition("supervisorResumeLag", supervisorResumeLag, "smithers.supervisor.resume_lag_ms", "histogram", { label: "Supervisor resume lag", unit: "milliseconds", boundaries: durationBucketValues }),
472
+ metricDefinition("runsAncestryDepth", runsAncestryDepth, "smithers.runs.ancestry_depth", "histogram", { label: "Run ancestry depth", unit: "depth", boundaries: ancestryDepthBucketValues }),
473
+ metricDefinition("runsCarriedStateBytes", runsCarriedStateBytes, "smithers.runs.carried_state_bytes", "histogram", { label: "Run carried state size", unit: "bytes", boundaries: carriedStateSizeBucketValues }),
474
+ metricDefinition("sandboxDurationMs", sandboxDurationMs, "smithers.sandbox.duration_ms", "histogram", { label: "Sandbox duration", unit: "milliseconds", boundaries: durationBucketValues }),
475
+ metricDefinition("sandboxBundleSizeBytes", sandboxBundleSizeBytes, "smithers.sandbox.bundle_size_bytes", "histogram", { label: "Sandbox bundle size", unit: "bytes", boundaries: sizeBucketValues }),
476
+ metricDefinition("sandboxTransportDurationMs", sandboxTransportDurationMs, "smithers.sandbox.transport_duration_ms", "histogram", { label: "Sandbox transport duration", unit: "milliseconds", boundaries: durationBucketValues }),
477
+ metricDefinition("sandboxPatchCount", sandboxPatchCount, "smithers.sandbox.patch_count", "histogram", { label: "Sandbox patch count", unit: "count", boundaries: tokenBucketValues }),
478
+ metricDefinition("heartbeatDataSizeBytes", heartbeatDataSizeBytes, "smithers.heartbeats.data_size_bytes", "histogram", { label: "Heartbeat data size", unit: "bytes", boundaries: sizeBucketValues }),
479
+ metricDefinition("heartbeatIntervalMs", heartbeatIntervalMs, "smithers.heartbeats.interval_ms", "histogram", { label: "Heartbeat interval", unit: "milliseconds", boundaries: fastBucketValues }),
480
+ metricDefinition("memoryRecallDuration", memoryRecallDuration, "smithers.memory.recall_duration_ms", "histogram", { label: "Memory recall duration", unit: "milliseconds", boundaries: metricHistogramBoundaries(memoryRecallDuration) }),
481
+ metricDefinition("openApiToolDuration", openApiToolDuration, "smithers.openapi.tool_duration_ms", "histogram", { label: "OpenAPI tool duration", unit: "milliseconds", boundaries: metricHistogramBoundaries(openApiToolDuration) }),
482
+ metricDefinition("scorerDuration", scorerDuration, "smithers.scorer.duration_ms", "histogram", { label: "Scorer duration", unit: "milliseconds", boundaries: metricHistogramBoundaries(scorerDuration) }),
483
+ metricDefinition("snapshotDuration", snapshotDuration, "smithers.snapshot.duration_ms", "histogram", { label: "Snapshot duration", unit: "milliseconds", boundaries: metricHistogramBoundaries(snapshotDuration) }),
484
+ ];
@@ -0,0 +1,2 @@
1
+ import { smithersMetricCatalog } from "./smithersMetricCatalog.js";
2
+ export const smithersMetricCatalogByKey = new Map(smithersMetricCatalog.map((metric) => [metric.key, metric]));
@@ -0,0 +1,2 @@
1
+ import { smithersMetricCatalog } from "./smithersMetricCatalog.js";
2
+ export const smithersMetricCatalogByName = new Map(smithersMetricCatalog.map((metric) => [metric.name, metric]));
@@ -0,0 +1,2 @@
1
+ import { smithersMetricCatalog } from "./smithersMetricCatalog.js";
2
+ export const smithersMetricCatalogByPrometheusName = new Map(smithersMetricCatalog.map((metric) => [metric.prometheusName, metric]));
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { fastBuckets } from "./_buckets.js";
3
+ export const supervisorPollDuration = Metric.histogram("smithers.supervisor.poll_duration_ms", fastBuckets);
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const supervisorPollsTotal = Metric.counter("smithers.supervisor.polls_total");
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { durationBuckets } from "./_buckets.js";
3
+ export const supervisorResumeLag = Metric.histogram("smithers.supervisor.resume_lag_ms", durationBuckets);
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const supervisorResumedTotal = Metric.counter("smithers.supervisor.resumed_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const supervisorSkippedTotal = Metric.counter("smithers.supervisor.skipped_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const supervisorStaleDetected = Metric.counter("smithers.supervisor.stale_detected");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const taskHeartbeatTimeoutTotal = Metric.counter("smithers.heartbeats.timeout_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const taskHeartbeatsTotal = Metric.counter("smithers.heartbeats.total");
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { durationBuckets } from "./_buckets.js";
3
+ export const timerDelayDuration = Metric.histogram("smithers.timers.delay_ms", durationBuckets);
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const timersCancelled = Metric.counter("smithers.timers.cancelled");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const timersCreated = Metric.counter("smithers.timers.created");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const timersFired = Metric.counter("smithers.timers.fired");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const timersPending = Metric.gauge("smithers.timers.pending");
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {string} name
3
+ * @returns {string}
4
+ */
5
+ export function toPrometheusMetricName(name) {
6
+ const next = name.replace(/[^a-zA-Z0-9_:]/g, "_");
7
+ return /^[a-zA-Z_:]/.test(next) ? next : `_${next}`;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensCacheReadTotal = Metric.counter("smithers.tokens.cache_read_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensCacheWriteTotal = Metric.counter("smithers.tokens.cache_write_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensContextWindowBucketTotal = Metric.counter("smithers.tokens.context_window_bucket_total");
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { contextWindowBuckets } from "./_buckets.js";
3
+ export const tokensContextWindowPerCall = Metric.histogram("smithers.tokens.context_window_per_call", contextWindowBuckets);
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { tokenBuckets } from "./_buckets.js";
3
+ export const tokensInputPerCall = Metric.histogram("smithers.tokens.input_per_call", tokenBuckets);
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensInputTotal = Metric.counter("smithers.tokens.input_total");
@@ -0,0 +1,3 @@
1
+ import { Metric } from "effect";
2
+ import { tokenBuckets } from "./_buckets.js";
3
+ export const tokensOutputPerCall = Metric.histogram("smithers.tokens.output_per_call", tokenBuckets);
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensOutputTotal = Metric.counter("smithers.tokens.output_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const tokensReasoningTotal = Metric.counter("smithers.tokens.reasoning_total");
@@ -0,0 +1,2 @@
1
+ import { Metric } from "effect";
2
+ export const toolCallErrorsTotal = Metric.counter("smithers.tool_calls.errors_total");