Skip to content

feat(observability): Compute-driven logging, tracing, and dashboard - #507

Draft
Simone319 wants to merge 5 commits into
mainfrom
zimzha/observability-deploy-runtime-split
Draft

feat(observability): Compute-driven logging, tracing, and dashboard#507
Simone319 wants to merge 5 commits into
mainfrom
zimzha/observability-deploy-runtime-split

Conversation

@Simone319

@Simone319 Simone319 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Draft — alternative observability model. This is a self-contained alternative to the earlier stacked PRs (#504 logging/tracing, #505 dashboard). It reworks observability so it composes correctly once an app has more than one compute, keying every decision off compute state instead of the Logger/Tracer/Dashboard blocks poking a single implicit compute.

The model

Logging — always on; retention is a compute prop.
Every compute captures stdout to its own log group unconditionally — there is no "enable logging" step. Retention moves to the compute: LambdaCompute gains a logRetention prop that overrides the stack-wide defaults.logRetention. The CDK Logger becomes a no-op placeholder, and its retention option is removed. Any number of Loggers coexist freely.

Log level — per-instance only.
Log level is set solely per Logger via the level option (default 'info'). There is no app-wide BlocksDefaults.logLevel and no LOG_LEVEL env var — Blocks stamps no log-level config, and the runtime Logger no longer reads LOG_LEVEL. Multiple Loggers with different levels coexist without any shared config.

Tracing — presence-gated, fleet-wide.
Creating any Tracer in the app enables X-Ray on every compute. X-Ray provisions real, costed infrastructure, so it stays off until the app opts in by constructing a Tracer. Implemented with a core tracer registry: registerTracer() records presence, finalizeTracing() enables tracing on all computes at finalize (before the dashboard finalize). Compute.enableTracing() is idempotent, so multiple Tracers are safe.

Dashboard — compute-state-driven, finalize-deferred.
DashboardOptions gains logs?: boolean / traces?: boolean (default true) — app-wide display toggles applied uniformly to every compute section. The dashboard covers every compute in the app (resolved at finalize, so construction order never matters); no computes selector is exposed yet, since it would leak the internal Compute type before customers can construct one to pass.

Each compute renders a health section always, a logs section (unless logs: false), and a traces section only when tracing is enabled on it (unless traces: false). Metrics remain app-scoped and are passed explicitly. The deprecated LoggerBBRef / TracerBBRef types are removed — the dashboard reads compute state directly.

⚠️ Behavior / API changes

  • Logger no longer reconfigures log retention; the retention option was removed from LoggingOptions. Set logRetention on the compute instead.
  • A Tracer now enables X-Ray on all computes, not one.
  • Logger no longer reads the LOG_LEVEL env var; log level is set solely via the per-Logger level option (default 'info'). Blocks stamps no app-wide log-level config, and BlocksDefaults has no logLevel field.
  • Removed the deprecated LoggerBBRef / TracerBBRef dashboard types.

Testing

npm run build, npm run lint:deps, npm run check:api, and unit tests for all touched packages pass on Node 22 (core 758, bb-logger 57, plus blocks, bb-dashboard, bb-tracer, bb-lambda-compute, bb-async-job, bb-cron-job). e2e not run in this draft.

Rework observability so it composes correctly across multiple computes,
keying off compute state rather than the Logger/Tracer/Dashboard blocks
poking a single implicit compute.

- Logging is always on; retention is a compute-level setting (LambdaCompute
  `logRetention` prop, falling back to `defaults.logRetention`). The CDK
  `Logger` is a no-op placeholder and its `retention` option is removed.
- App-wide default log level is a new `BlocksDefaults.logLevel`, stamped once
  as the `LOG_LEVEL` runtime config; a Logger's `level` still wins per instance.
- Tracing is presence-gated: any `Tracer` in the app enables X-Ray on every
  compute via a new core tracer registry (`registerTracer`/`finalizeTracing`),
  run before dashboard finalize. `Compute.enableTracing()` is idempotent.
- Dashboard is organized by compute with `computes?` (defaults to all, resolved
  at finalize) plus `logs`/`traces` display toggles. Health + logs always
  render; traces render when the compute is traced. Removed the deprecated
  `LoggerBBRef`/`TracerBBRef` types.

Updates all Compute-subclass test stubs, rewrites bb-logger/bb-dashboard CDK
tests for the new model, refreshes READMEs/DESIGN docs and API reports.
@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b9dd27

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@aws-blocks/core Minor
@aws-blocks/blocks Minor
@aws-blocks/bb-lambda-compute Minor
@aws-blocks/bb-dashboard Minor
@aws-blocks/bb-logger Minor
@aws-blocks/bb-tracer Minor
@aws-blocks/bb-kv-store Patch
@aws-blocks/bb-distributed-table Patch
@aws-blocks/auth-common Patch
@aws-blocks/bb-app-setting Patch
@aws-blocks/bb-data Patch
@aws-blocks/bb-distributed-data Patch
@aws-blocks/bb-auth-basic Patch
@aws-blocks/bb-auth-cognito Patch
@aws-blocks/bb-auth-oidc Patch
@aws-blocks/bb-realtime Patch
@aws-blocks/bb-async-job Patch
@aws-blocks/bb-cron-job Patch
@aws-blocks/bb-file-bucket Patch
@aws-blocks/bb-agent Patch
@aws-blocks/bb-knowledge-base Patch
@aws-blocks/bb-email-client Patch
@aws-blocks/bb-metrics Patch
@aws-blocks/data-common Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…lity.ts

Rename widgets.ts to observability.ts and fold the X-Ray tracing activation
(previously inline in LambdaCompute.applyTracing) into it, so all of the
compute's observability — tracing infra plus the dashboard health/logs/traces
widget builders — lives in one module. The class body now delegates:
applyTracing() calls applyXRayTracing(), keeping index.cdk.ts focused on the
compute's core function + gateway wiring.

No behavior or public API change (observability.ts is package-internal).
…is public

Drop the `computes?: Compute[]` option from the public DashboardOptions. It
leaked the internal `Compute` type before customers can construct a compute to
pass. The dashboard still works: its finalizer always covers every compute in
the app via getComputes() (complete today — one default compute), so behavior
is unchanged.

Add a TODO(multi-compute) in index.cdk.ts describing the intended behavior when
the option returns: resolve `options.computes ?? getComputes(this)`, where an
explicit list restricts/orders the rendered computes and omitting it keeps the
cover-every-compute default. Update README/DESIGN/changeset and drop the
explicit-computes test.
Drop the app-wide log-level knob entirely: log level is now set solely
per-Logger via the `level` option (default 'info').

- Remove `logLevel` from `BlocksDefaults` and both presets.
- Remove the central `registerConfig('LOG_LEVEL', ...)` in blocks-backend
  setup, so no LOG_LEVEL config is stamped on computes.
- Remove the `process.env.LOG_LEVEL` fallback from the runtime Logger and
  its env-var tests.
- Update bb-logger docs (DESIGN, README, JSDoc) and the observability
  changeset to reflect the removal.
…pute-driven model

Fix comments/JSDoc that described the pre-PR "Logger/Tracer attached to a
compute" model, which no longer holds: logs are always captured per compute
and tracing is fleet-wide presence-gated.

- types.ts: rewrite the metrics JSDoc parenthetical and the
  ResolvedDashboardConfig note (logs always-on; traces fleet-wide; toggles).
- widgets.ts: correct the per-compute logs/traces comments and drop the two
  dead resolveConfig() bullets (log-group / tracing resolution was removed).
- index.mock.ts: stdout logging is per-compute, not a Logger-BB responsibility.
- changeset: bump bb-logger and bb-tracer patch -> minor (both carry breaking
  pre-1.0 behavior changes, matching the other packages in this changeset).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant