@softize/opus 9.0.9 → 9.1.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 +27 -0
- package/README.md +2 -2
- package/docs/adr/0001-vendor-neutral-observability-context.md +96 -0
- package/docs/protocol.md +101 -12
- package/package.json +16 -1
- package/src/audit/drivers/pg.ts +60 -8
- package/src/core/actions.ts +3 -1
- package/src/core/index.ts +4 -0
- package/src/core/runtime.ts +230 -26
- package/src/core/trace.ts +34 -0
- package/src/core/types.ts +44 -0
- package/src/observability/drivers/opentelemetry.ts +165 -0
- package/src/observability/index.ts +8 -0
- package/src/queue/drivers/bullmq.ts +47 -5
- package/src/server/drivers/fastify.ts +16 -1
- package/src/server/drivers/node.ts +23 -3
- package/src/server/index.ts +57 -0
- package/src/testing/index.ts +3 -0
- package/src/ui/docs/content/audit.md +17 -0
- package/src/ui/docs/content/observability.md +71 -0
- package/src/ui/docs/content/queue.md +29 -3
- package/src/ui/docs/content/runtime.md +18 -1
|
@@ -22,6 +22,7 @@ const runtime = createRuntime({
|
|
|
22
22
|
data: kyselyData({ db }), // fornece ctx.db
|
|
23
23
|
auth: makeAuthAdapter(), // resolve user/tenant/can
|
|
24
24
|
audit: [pgAudit({ pool })], // trilha de auditoria (N sinks)
|
|
25
|
+
observability: makeObservability(), // span ativo + TraceContext vendor-neutral
|
|
25
26
|
storage: fsStorage({ root }), // fornece ctx.storage (experimental)
|
|
26
27
|
config: { env, i18n: { defaultLocale: 'pt-BR' } },
|
|
27
28
|
})
|
|
@@ -42,6 +43,7 @@ await runtime.start()
|
|
|
42
43
|
| `auth` | `user`/`tenantId`/`can` do contexto | `jwtAuth` — `…/auth/jwt` · `betterAuthSession` — `…/auth/better-auth` |
|
|
43
44
|
| `audit` | trilha por execução de action | `pgAudit` — `…/audit/pg` · `consoleAudit` — `…/audit/console` |
|
|
44
45
|
| `log` | `ctx.log` estruturado | `pinoLogger` — `@softize/opus/log/pino` |
|
|
46
|
+
| `observability` | span ativo + propagação de trace | porta no core; driver opt-in |
|
|
45
47
|
| `eventBus` | `ctx.emit` + **reactions** | `mittEvents` — `@softize/opus/events/mitt` |
|
|
46
48
|
| `queue` | jobs em background | `bullmqQueue` — `@softize/opus/queue/bullmq` |
|
|
47
49
|
| `scheduler` | **schedules** (cron/intervalo) | `nodeCronScheduler` — `@softize/opus/scheduler/node-cron` |
|
|
@@ -60,7 +62,22 @@ Fora do runtime, mas parte do protocolo: o harness de teste (`runAction`/`testCo
|
|
|
60
62
|
|
|
61
63
|
`user`/`tenantId`/`can` (auth) · `db` (data) · `log` (logger) · `emit` (eventBus) ·
|
|
62
64
|
`storage` (storage) · `ai` (ai) · `provenance` (quem disparou: http, schedule,
|
|
63
|
-
reaction…) · `meta`.
|
|
65
|
+
reaction…) · `trace` (quando configurado) · `meta`.
|
|
66
|
+
|
|
67
|
+
O core não depende de OpenTelemetry. O `ObservabilityAdapter` envolve actions e reactions
|
|
68
|
+
com `runInSpan`; o `TraceContext` efetivo também segue para resultado, audit e eventos. Os
|
|
69
|
+
envelopes de job recebem o trace da execução que enfileirou; `executeJob()` cria a execução
|
|
70
|
+
filha no worker sem reenfileirar a action.
|
|
71
|
+
Falha de instrumentação é lenient e nunca repete o handler.
|
|
72
|
+
|
|
73
|
+
O core não extrai headers HTTP. Os drivers Fastify e Node podem fornecer
|
|
74
|
+
`ContextBase.trace` com `traceContext: 'w3c'`; o opt-in é desativado por default. Outros
|
|
75
|
+
transportes continuam responsáveis por sua fronteira. Em audit, o contexto novo usa
|
|
76
|
+
`traceContext`; o campo `trace` legado continua disponível sem mudança.
|
|
77
|
+
|
|
78
|
+
Para actions, o callback observável resolve com `ActionResult`: `resultKind: 'action-result'`
|
|
79
|
+
indica que o driver deve inspecionar `result.ok`. Uma Promise resolvida com `ok:false` ainda
|
|
80
|
+
representa span de erro. Reactions usam `resultKind: 'void'` e rejeitam em falha.
|
|
64
81
|
|
|
65
82
|
## Reactions e schedules
|
|
66
83
|
|