@open-mercato/telemetry 0.11.1-develop.8433.1.e3ebfc0705 → 0.11.1-develop.8441.1.92a9090201
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.
- package/AGENTS.md +2 -0
- package/README.md +8 -0
- package/package.json +2 -2
- package/src/__tests__/report-error.test.ts +56 -1
package/AGENTS.md
CHANGED
|
@@ -31,6 +31,8 @@ off by default. Spec:
|
|
|
31
31
|
two instruments must never share a name.
|
|
32
32
|
- Keep the built-in metric names, units, and fixed labels synchronized with the
|
|
33
33
|
catalog in `packages/telemetry/README.md`.
|
|
34
|
+
- Keep access-log backlog stages fixed to `crud_dispatch` and `service_write`,
|
|
35
|
+
and the dropped-reason label fixed to `capacity`.
|
|
34
36
|
- Keep metric labels low-cardinality. Tenant, organization, and user IDs belong
|
|
35
37
|
on span attributes, never metric labels.
|
|
36
38
|
- Apply redaction at the provider boundary as well as at facade call sites.
|
package/README.md
CHANGED
|
@@ -302,6 +302,14 @@ without making `@open-mercato/shared` depend on this package.
|
|
|
302
302
|
| `nodejs.eventloop.delay.p50` / `p90` / `p99` | gauge | `s` | none |
|
|
303
303
|
| `process.memory.usage` | gauge | `By` | none |
|
|
304
304
|
| `v8js.memory.heap.used` | gauge | `By` | `v8js.heap.space.name` |
|
|
305
|
+
| `om.audit_logs.pending_writes` | gauge | `{task}` | `stage=crud_dispatch` or `stage=service_write` |
|
|
306
|
+
| `om.audit_logs.oldest_pending_age` | gauge | `s` | `stage=crud_dispatch` or `stage=service_write` |
|
|
307
|
+
| `om.audit_logs.dropped` | counter | `{task}` | `stage=crud_dispatch` or `stage=service_write`, `reason=capacity` |
|
|
308
|
+
|
|
309
|
+
Access-log gauges join the process sampler only while a stage has accepted
|
|
310
|
+
pending work and emit a final zero before unregistering. Capacity rejections
|
|
311
|
+
increment `om.audit_logs.dropped` immediately. The two fixed stages are bounded
|
|
312
|
+
independently and metric labels never include request or record data.
|
|
305
313
|
|
|
306
314
|
Pool acquisition wait is recorded per `pool.connect` call, including failed
|
|
307
315
|
promise and callback acquisitions, and includes opening a new connection when
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/telemetry",
|
|
3
|
-
"version": "0.11.1-develop.
|
|
3
|
+
"version": "0.11.1-develop.8441.1.92a9090201",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vendor-neutral spans, metrics, and error reporting backed by a pluggable OTLP provider. Off by default; the telemetry runtime is loaded only when explicitly enabled.",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@open-mercato/shared": "0.11.1-develop.
|
|
41
|
+
"@open-mercato/shared": "0.11.1-develop.8441.1.92a9090201"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18.0.0"
|
|
@@ -3,7 +3,12 @@ import {
|
|
|
3
3
|
resetLoggerExtension,
|
|
4
4
|
resetLoggerRegistry,
|
|
5
5
|
} from '@open-mercato/shared/lib/logger'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
registerTelemetryMetricCollector,
|
|
8
|
+
resetTelemetryMetricCollectors,
|
|
9
|
+
resetTelemetryRuntime,
|
|
10
|
+
} from '@open-mercato/shared/lib/telemetry/runtime'
|
|
11
|
+
import { createRuntimeMetricsSampler, type RuntimeMetricSources } from '../runtime-metrics'
|
|
7
12
|
import { initTelemetry, resetTelemetryInit } from '../init'
|
|
8
13
|
import { registerProvider, resetActiveProvider } from '../provider/registry'
|
|
9
14
|
import { resetTelemetryEnvCache } from '../env'
|
|
@@ -94,9 +99,59 @@ describe('reportError policy', () => {
|
|
|
94
99
|
})
|
|
95
100
|
|
|
96
101
|
afterEach(() => {
|
|
102
|
+
resetTelemetryMetricCollectors()
|
|
103
|
+
resetTelemetryInit()
|
|
97
104
|
delete process.env.TELEMETRY_BACKEND
|
|
98
105
|
})
|
|
99
106
|
|
|
107
|
+
it('reports sampler and collector failures through an enabled provider that rejects gauges', async () => {
|
|
108
|
+
const { provider, span, metrics, reported } = recordingProvider({ withErrorSink: true })
|
|
109
|
+
const failure = new Error('[internal] gauge sink unavailable')
|
|
110
|
+
const recordMetric = provider.recordMetric
|
|
111
|
+
let rejectGauges = true
|
|
112
|
+
provider.recordMetric = (point) => {
|
|
113
|
+
if (rejectGauges && point.kind === 'gauge') throw failure
|
|
114
|
+
recordMetric(point)
|
|
115
|
+
}
|
|
116
|
+
await activate(provider)
|
|
117
|
+
let sample = () => {}
|
|
118
|
+
const sources: RuntimeMetricSources = {
|
|
119
|
+
createEventLoopDelayMonitor: () => ({
|
|
120
|
+
enable() {}, disable() {}, percentile: () => 0, reset() {},
|
|
121
|
+
}),
|
|
122
|
+
eventLoopUtilization: () => ({ idle: 0, active: 0, utilization: 0 }),
|
|
123
|
+
memoryUsage: () => ({ rss: 123 }),
|
|
124
|
+
heapSpaceStatistics: () => [],
|
|
125
|
+
setInterval: (handler) => {
|
|
126
|
+
sample = handler
|
|
127
|
+
return { unref() {} } as unknown as ReturnType<typeof setInterval>
|
|
128
|
+
},
|
|
129
|
+
clearInterval() {},
|
|
130
|
+
}
|
|
131
|
+
const dispose = createRuntimeMetricsSampler(sources)
|
|
132
|
+
try {
|
|
133
|
+
expect(sample).not.toThrow()
|
|
134
|
+
rejectGauges = false
|
|
135
|
+
registerTelemetryMetricCollector(() => { throw failure })
|
|
136
|
+
const nextCollector = jest.fn()
|
|
137
|
+
registerTelemetryMetricCollector(nextCollector)
|
|
138
|
+
expect(sample).not.toThrow()
|
|
139
|
+
expect(nextCollector).toHaveBeenCalledTimes(1)
|
|
140
|
+
expect(span.exceptions).toEqual([failure, failure])
|
|
141
|
+
expect(metrics.filter((point) => point.name === 'om.errors').map((point) => point.labels))
|
|
142
|
+
.toEqual([
|
|
143
|
+
{ module: 'telemetry', 'error.code': 'telemetry.runtime_sampling_failed' },
|
|
144
|
+
{ module: 'telemetry', 'error.code': 'telemetry.metric_collector_failed' },
|
|
145
|
+
])
|
|
146
|
+
expect(reported.map((entry) => entry.context.code)).toEqual([
|
|
147
|
+
'telemetry.runtime_sampling_failed',
|
|
148
|
+
'telemetry.metric_collector_failed',
|
|
149
|
+
])
|
|
150
|
+
} finally {
|
|
151
|
+
dispose()
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
|
|
100
155
|
it('stamps the code on the span, the log record and the metric label', async () => {
|
|
101
156
|
const { provider, span, logs, metrics } = recordingProvider()
|
|
102
157
|
await activate(provider)
|