chore(core): add location startup diagnostics
This commit is contained in:
parent
fe0c74f4df
commit
8c9b5b7b4e
5 changed files with 191 additions and 62 deletions
|
|
@ -6,10 +6,22 @@ import os from "os"
|
|||
import path from "path"
|
||||
import { fileLogger } from "../../src/observability/logging"
|
||||
import { resource } from "../../src/observability/otlp"
|
||||
import { makeEventLoopDelayMonitor } from "../../src/observability/event-loop-delay"
|
||||
|
||||
const otelResourceAttributes = process.env.OTEL_RESOURCE_ATTRIBUTES
|
||||
const opencodeClient = process.env.OPENCODE_CLIENT
|
||||
|
||||
test("measures an immediate event-loop block and stops sampling", async () => {
|
||||
const monitor = makeEventLoopDelayMonitor()
|
||||
const startedAt = performance.now()
|
||||
while (performance.now() - startedAt < 60) {}
|
||||
const maxMs = monitor.stop()
|
||||
await Bun.sleep(40)
|
||||
|
||||
expect(maxMs).toBeGreaterThanOrEqual(20)
|
||||
expect(monitor.maxMs()).toBe(maxMs)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (otelResourceAttributes === undefined) delete process.env.OTEL_RESOURCE_ATTRIBUTES
|
||||
else process.env.OTEL_RESOURCE_ATTRIBUTES = otelResourceAttributes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue