@crvouga/mockingbird-service-otel 3.3.0 → 3.4.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Changelog — @crvouga/mockingbird-service-otel
2
2
 
3
- ## 3.3.0 (2026-10-11)
3
+ ## 3.4.0 (2026-10-12)
4
+
5
+ ### Features
6
+
7
+ - unify the emulator control plane ([2068547](https://github.com/crvouga/mockingbird/commit/2068547bedde4e2e2331c1657c1a78120e84428b))
8
+
9
+ ### Dependencies
10
+
11
+ - `@crvouga/mockingbird-service-sqlite`
12
+
13
+ ## 3.3.0 (2026-10-10)
4
14
 
5
15
  ### Features
6
16
 
package/DISCOVERY.md CHANGED
@@ -35,6 +35,7 @@ repository; live parity is an additional oracle check, not a substitute for the
35
35
 
36
36
  - `GET /__admin/health`
37
37
  - `GET /__admin`
38
+ - `GET /__admin/controls`
38
39
  - `GET /__admin/state`
39
40
  - `GET /__admin/requests`
40
41
  - `GET /__admin/metrics`
@@ -45,6 +46,28 @@ For HTTP services, use `x-mockingbird-namespace` (or the documented credential/p
45
46
  parallel tests do not share state. Admin state, journal, metrics and fault-preset endpoints are
46
47
  designed for assertions and diagnosis by consuming test suites.
47
48
 
49
+ ## Admin controls
50
+
51
+ Every HTTP emulator takes the same controls, and each means the same thing at boot
52
+ (`createRuntime({ adminControls })`, `serve --admin-controls`), over `/__admin`, and in a request header:
53
+
54
+ | Control | Admin API | Request header | Interface |
55
+ | --- | --- | --- | --- |
56
+ | Isolate state by key | `GET /__admin/namespaces` | `x-mockingbird-namespace: <key>` | [Namespaces](https://mockingbird.chrisvouga.dev/docs/admin-controls/namespaces) |
57
+ | Reset to boot | `POST /__admin/reset` | `x-mockingbird-reset: true` | [Reset](https://mockingbird.chrisvouga.dev/docs/admin-controls/reset) |
58
+ | Snapshot and restore | `POST /__admin/snapshots`, `POST /__admin/snapshots/<id>/restore` | `x-mockingbird-snapshot: <name>`, `x-mockingbird-restore: <name>` | [Snapshot and restore](https://mockingbird.chrisvouga.dev/docs/admin-controls/snapshot-and-restore) |
59
+ | Move the clock | `POST /__admin/clock` | `x-mockingbird-time: <instant>`, `x-mockingbird-advance: <duration>` | [Clock](https://mockingbird.chrisvouga.dev/docs/admin-controls/clock) |
60
+ | Read or branch from old state | `GET /__admin/timeline` | `x-mockingbird-at: <checkpoint>`, `x-mockingbird-branch: <name>` | [Checkpoints and branches](https://mockingbird.chrisvouga.dev/docs/admin-controls/checkpoints-and-branches) |
61
+ | Inject a fault | `POST /__admin/faults` | `x-mockingbird-fault: <fault>` | [Faults](https://mockingbird.chrisvouga.dev/docs/admin-controls/faults) |
62
+ | Latency and timeouts | `PUT /__admin/latency` | `x-mockingbird-delay: <duration>`, `x-mockingbird-timeout: <duration>` | [Latency and timeouts](https://mockingbird.chrisvouga.dev/docs/admin-controls/latency-and-timeouts) |
63
+ | Replay from a seed | `PUT /__admin/controls` | `x-mockingbird-seed: <seed>` | [Seed and determinism](https://mockingbird.chrisvouga.dev/docs/admin-controls/seed-and-determinism) |
64
+ | See what happened | `GET /__admin/requests`, `GET /__admin/state` | | [Journal, metrics and state](https://mockingbird.chrisvouga.dev/docs/admin-controls/journal-and-state) |
65
+
66
+ `GET /__admin` lists every route and header with a one-line summary, and `GET /__admin/controls`
67
+ is the namespace's current control document. The same seed and the same requests give the same
68
+ bytes. Setting controls as an emulator starts is [Boot](https://mockingbird.chrisvouga.dev/docs/admin-controls/boot); every route and header is in
69
+ the [Reference](https://mockingbird.chrisvouga.dev/docs/admin-controls/reference). The full guide: <https://mockingbird.chrisvouga.dev/docs/admin-controls>.
70
+
48
71
  ## Report a mismatch or missing capability
49
72
 
50
73
  Follow the [agent reporting contract](https://github.com/crvouga/mockingbird/blob/main/docs/REPORTING_ISSUES.md). Include package version,
package/README.md CHANGED
@@ -37,44 +37,51 @@ npx mockingbird-otel serve --ingest-basic-auth "$OTLP_INSTANCE_ID:$OTLP_TOKEN"
37
37
  ```
38
38
 
39
39
  ```ts
40
- import { createRuntime } from "@crvouga/mockingbird-service-otel"
41
-
42
- const otel = createRuntime()
43
- const call = (path: string, init: RequestInit) => otel.fetch(new Request(`http://otel.test${path}`, init))
44
-
45
- // What @opentelemetry/exporter-logs-otlp-http sends for one winston/pino event log.
46
- await call("/v1/logs", {
47
- method: "POST",
48
- headers: { "content-type": "application/json", authorization: "Bearer ingest-token" },
49
- body: JSON.stringify({
50
- resourceLogs: [{
51
- resource: { attributes: [{ key: "service.name", value: { stringValue: "backend" } }] },
52
- scopeLogs: [{ logRecords: [{
53
- severityText: "info",
54
- body: { stringValue: "reconcile done" }, // dropped: bodies are never stored
55
- attributes: [
56
- { key: "event", value: { stringValue: "initial_credit_reconcile_completed" } },
57
- { key: "granted", value: { intValue: "1" } },
58
- ],
59
- }] }],
60
- }],
61
- }),
40
+ import { SeverityNumber } from "@opentelemetry/api-logs"
41
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http"
42
+ import { resourceFromAttributes } from "@opentelemetry/resources"
43
+ import { LoggerProvider, SimpleLogRecordProcessor } from "@opentelemetry/sdk-logs"
44
+ import { createServer } from "@crvouga/mockingbird-service-otel/server"
45
+
46
+ const server = await createServer()
47
+
48
+ // The OpenTelemetry SDK your application already uses. Only the exporter's URL changes.
49
+ const exporter = new OTLPLogExporter({
50
+ url: `${server.url}/v1/logs`,
51
+ headers: { authorization: "Bearer ingest-token" },
52
+ })
53
+ const loggerProvider = new LoggerProvider({
54
+ resource: resourceFromAttributes({ "service.name": "backend" }),
55
+ processors: [new SimpleLogRecordProcessor(exporter)],
56
+ })
57
+ loggerProvider.getLogger("backend").emit({
58
+ severityNumber: SeverityNumber.INFO,
59
+ severityText: "info",
60
+ body: "reconcile done", // dropped: bodies are never stored
61
+ attributes: { event: "initial_credit_reconcile_completed", granted: 1 },
62
62
  })
63
+ await loggerProvider.forceFlush()
63
64
 
64
- // Long-poll until it lands, then query it the way our O2 clients do.
65
- await call("/__admin/wait", {
65
+ // Test control: long-poll until the event lands.
66
+ await fetch(`${server.url}/__admin/wait`, {
66
67
  method: "POST",
67
68
  headers: { "content-type": "application/json" },
68
69
  body: JSON.stringify({ kind: "log", where: { event: "initial_credit_reconcile_completed" } }),
69
70
  })
70
- const search = await call("/api/30rBqcDevOrg7Hn2KmQ4xW9sLtY/_search", {
71
+
72
+ // Then query it the way our O2 clients do (OpenObserve's search API is plain HTTP).
73
+ const search = await fetch(`${server.url}/api/30rBqcDevOrg7Hn2KmQ4xW9sLtY/_search`, {
71
74
  method: "POST",
72
75
  headers: { "content-type": "application/json", authorization: `Basic ${btoa("agent:pw")}` },
73
76
  body: JSON.stringify({
74
77
  query: { sql: `SELECT * FROM "default" WHERE event = 'initial_credit_reconcile_completed'` },
75
78
  }),
76
79
  })
80
+ console.log(await search.json())
77
81
  // { hits: [{ service_name: "backend", event: "…", granted: 1, severity_text: "info", _timestamp }], … }
82
+
83
+ await loggerProvider.shutdown()
84
+ await server.close()
78
85
  ```
79
86
 
80
87
  ### Receiver