docs: add expansion roadmap and workflow baseline
This commit is contained in:
1 parent
f1f9ba375b
commit
faa8a5198d
65 files changed
+9292
No files matched your search
@@ -0,0 +1,166 @@
|
||||
# Observability — optional hooks, bounded metrics and traces
|
||||
|
||||
Status: NEW subsystem design; all tasks PLANNED. Baseline
|
||||
`f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`; there is no Observability module/source directory
|
||||
or exporter at this revision. R-005/R-009/R-012 and [C-01–C-05/C-11](../ARCHITECTURE.md)
|
||||
define the layering and lifetime obligations.
|
||||
|
||||
## Existing evidence and ownership boundary
|
||||
|
||||
[Log.hpp](../../../include/Void/Log/Log.hpp) provides a process-wide logging facade;
|
||||
[Entry.hpp](../../../include/Void/Log/Entry.hpp) owns log record data, and
|
||||
[FieldScope](../../../include/Void/Log/Field.hpp) provides thread-local structured fields.
|
||||
These are useful integration points, not existing metrics/tracing context propagation.
|
||||
[Logger.cpp](../../../src/Log/Logger.cpp) snapshots fields/scopes for async delivery.
|
||||
[Log](../modules/Log.md) retains all delivery, sink, saturation and flush ownership.
|
||||
|
||||
Observability owns instrumentation identities, metric aggregation, trace/span context and
|
||||
export adapters. Its lowest layer is a standard-library-only optional hook surface with no
|
||||
Net, Runtime, Log or Async imports. Proposed NEW paths are `include/Void/Observability/Hooks.hpp`,
|
||||
`include/Void/Observability/Context.hpp` and `src/Observability/`; proposed component separation
|
||||
is hooks/context, aggregation, then optional exporters. [Dependencies](../DEPENDENCIES.md)
|
||||
and [build/distribution](../BUILD-AND-DISTRIBUTION.md) own final packaging validation.
|
||||
|
||||
Higher modules may inject these hook objects. Foundation headers must still compile and
|
||||
link without a telemetry backend or runtime. Async propagates an owning context carrier
|
||||
through an optional adapter; it must not import a concrete tracer or exporter. Log's context
|
||||
bridge lives above both modules so neither imports the other. Managed Runtime composes
|
||||
resources; it never becomes a dependency of the hook definitions.
|
||||
|
||||
## NEW hook and context shape
|
||||
|
||||
Illustrative NEW interfaces in `Void::Observability`, not existing compilable APIs:
|
||||
|
||||
```cpp
|
||||
struct TraceContext {
|
||||
std::array<std::byte, 16> trace_id;
|
||||
std::array<std::byte, 8> span_id;
|
||||
std::uint8_t flags;
|
||||
};
|
||||
class ContextSnapshot; // immutable owning trace context + bounded baggage
|
||||
struct MetricPoint; // pre-registered instrument id, bounded attributes, value
|
||||
struct ObservationHooks {
|
||||
void* state;
|
||||
void (*record)(void*, const MetricPoint&) noexcept;
|
||||
};
|
||||
class HookLease; // retains callback owner until admitted calls drain
|
||||
class Span; // move-only handle, one end transition
|
||||
Result<Span> start_span(ContextSnapshot parent, SpanSpec);
|
||||
Result<ExportReport> flush(ExportOptions);
|
||||
```
|
||||
|
||||
The raw function table is a synchronous borrowing view: it never outlives its HookLease.
|
||||
The configured context retains that lease, and detach has a distinct drain operation.
|
||||
Hook callbacks must be nonblocking/noexcept; adapter boundaries catch foreign exceptions,
|
||||
increment bounded failure counters and quarantine a broken callback. A null hook performs
|
||||
no allocation or backend initialization. Registration is explicit, not done lazily per
|
||||
user-supplied label value on a hot path.
|
||||
|
||||
Trace IDs are opaque values generated through the application's approved random/id source,
|
||||
not from raw addresses. ContextSnapshot captures values at operation admission. A lexical
|
||||
thread-local scope is a convenience view only: scheduled work owns a snapshot and restores
|
||||
the previous context on entry/exit, including exceptions. A context scope cannot remain
|
||||
installed on a worker across coroutine suspension. Async's resume adapter sets it for each
|
||||
resume, or code passes the snapshot explicitly. Never retain a pointer to another thread's
|
||||
TLS, request object or stack buffer.
|
||||
|
||||
Span has one terminal end; repeated end is harmless and counted diagnostically. A child
|
||||
can finish after its parent because it owns IDs, not a parent Span pointer. Destroying an
|
||||
unended local handle ends it with Abandoned unless ownership was explicitly moved. Remote
|
||||
context is untrusted metadata: validate lengths/encoding, reject all-zero required IDs, cap
|
||||
baggage, and never use it as an authorization identity. A protocol propagation adapter belongs
|
||||
above Net/RPC; compliance with a named wire standard requires a later conformance task and
|
||||
does not alter the lightweight in-process representation.
|
||||
|
||||
## Metrics, tracing and export algorithms
|
||||
|
||||
Instrument registration freezes name, unit, kind and label schema. The same name with a
|
||||
different schema is an error. Counters are monotonic unsigned totals with checked/saturating
|
||||
overflow plus a diagnostic flag; gauges are last-value samples with timestamp; histograms
|
||||
use configured fixed bucket boundaries (default request-duration buckets from 100 µs
|
||||
through 10 s plus overflow). No per-event dynamically expanding sketch is required initially.
|
||||
Thread-local bounded shards aggregate updates; collection snapshots/swaps shards and merges
|
||||
outside producer locks. A collector must retain shard ownership while a worker exits.
|
||||
|
||||
Use cumulative metric snapshots for the first exporter, so retrying export need not double
|
||||
add a delta. Process/registry epochs distinguish restarts and reset counters. Instrument and
|
||||
label IDs come from a bounded registry; never use request IDs, raw URLs, user names or keys
|
||||
as metric labels. Route templates, fixed operation names and bounded error categories are
|
||||
the selected defaults. Cardinality overflow records a dropped-series counter under one
|
||||
pre-registered overflow series, not a newly labelled series per rejected value.
|
||||
|
||||
Tracing initially uses parent-based head sampling. Root sampling defaults to one in 100,
|
||||
implemented from a stable trace-ID hash so descendants agree without a global lock. Export
|
||||
only completed sampled spans; a separate bounded diagnostic event path may record failures
|
||||
without retaining every unsampled request. Tail sampling is explicitly deferred to
|
||||
S-OBSERVABILITY-06 because it changes memory/decision horizons. Span durations use Time's
|
||||
steady clock; exported civil timestamps use a sampled civil/steady correspondence and do
|
||||
not control deadlines.
|
||||
|
||||
Collector/exporter startup is explicit. Native aggregation and a local callback/text snapshot
|
||||
exporter come first; an optional interoperable remote exporter is a later adapter over Net.
|
||||
No external telemetry SDK is mandatory. An exporter owns immutable batches; transport retries
|
||||
are bounded and may duplicate remote trace records, which have stable IDs. The subsystem
|
||||
does not claim exactly-once delivery. Export failure must never recursively emit into the
|
||||
same telemetry path; counters and a separate optional emergency diagnostic hook suffice.
|
||||
|
||||
## Concrete limits and shutdown
|
||||
|
||||
| Resource | NEW default / failure behavior |
|
||||
| --- | --- |
|
||||
| Registry | 256 instruments, 1,024 series/instrument, 4,096 series globally; reject excess registration/series with fixed counters. |
|
||||
| Attributes | Eight metric labels, 32 span attributes, 128-byte keys, 256-byte values; reject invalid identity labels, truncate opted-in diagnostic text with a marker. |
|
||||
| Context | 16 baggage items and 2 KiB total; immutable owned copy at admission; baggage is not automatically exported or logged. |
|
||||
| Trace state | 1,024 active spans, 8 MiB active-span memory, 32 events/span and 8 KiB/span maximum; exhausted sampled admission returns an inert context-preserving handle with loss count. |
|
||||
| Completed data | 8,192 spans and 16 MiB including active export batches; reject newest completed data on saturation with loss accounting. |
|
||||
| Aggregation | 32 MiB total registry/shard/histogram storage; 32 registered producer shards, fallback to a shared bounded shard when exhausted. |
|
||||
| Export | One active batch, 256 spans/512 KiB batch, two retries within five seconds; default metrics interval ten seconds, trace flush interval one second. |
|
||||
|
||||
Storage for default bucket counts is included in aggregation limits. All strings, queues,
|
||||
callback-held batches and copied metadata count toward the appropriate byte budget, not
|
||||
just record counts. Backend transport memory has its own Net budget; composition reports
|
||||
the sum. Configuration cannot accidentally set zero to mean unlimited.
|
||||
|
||||
Admission stops first at shutdown; owned task contexts/spans drain with their tasks, then
|
||||
final metric collection and export flush run before exporter/clock/executor destruction.
|
||||
Default flush budget is five seconds. Timeout reports unsent/dropped counts and retains
|
||||
resources for admitted backend activity until its completion; it does not free buffers under
|
||||
an in-flight send. A failure to export does not roll back the business operation. Embedded
|
||||
users drive collection/flush explicitly; no hidden background thread is created by a span.
|
||||
|
||||
## Implementation tasks
|
||||
|
||||
| ID | Phase / dependencies | Scope and acceptance | Recommended role |
|
||||
| --- | --- | --- | --- |
|
||||
| S-OBSERVABILITY-01 | P1; Memory/Time/Functional contracts | Freeze lightweight hook/context headers and no-backend consumer; null hooks allocate nothing and bring no Runtime/Net/Log dependency. | astra_implementer |
|
||||
| S-OBSERVABILITY-02 | P2; S-OBSERVABILITY-01, Async admission ownership | HookLease, detach/drain, context snapshots/resume adapter and span lifetime; callbacks cannot touch freed owner/TLS after request completion. | astra_implementer |
|
||||
| S-OBSERVABILITY-03 | P2; S-OBSERVABILITY-01/02 | Bounded metric registry, shards and histograms; cardinality storm stays within limits and overflow/reset totals are visible. | sol_implementer |
|
||||
| S-OBSERVABILITY-04 | P2; S-OBSERVABILITY-02/03 | Head sampling, completed-span queue, callback/text exporter and flush; slow exporter cannot grow total memory or stall producers. | astra_implementer |
|
||||
| S-OBSERVABILITY-05 | P3; S-OBSERVABILITY-04, Net/Runtime/Log adapters | Managed lifecycle, interoperable remote export and protocol context adapter; compliance fixtures and ownership tests pass without dependency cycles. | sol_implementer |
|
||||
| S-OBSERVABILITY-06 | P3; S-OBSERVABILITY-05, measured profile | Optional bounded tail sampling with fixed trace/byte/time horizons; accept only with explicit eviction semantics and measured benefit. | astra_implementer |
|
||||
| S-OBSERVABILITY-07 | P4; S-OBSERVABILITY-05, distributed platform contracts | Replica/term/commit lag instruments using bounded identities; telemetry outage cannot block majority commit or become an authority for leadership. | sol_implementer |
|
||||
|
||||
## Verification, performance and migration
|
||||
|
||||
CURRENT: no Observability tests exist. Adjacent Log snapshot tests cover only logging;
|
||||
[validation](../VALIDATION.md) is the baseline evidence authority. PROPOSED after
|
||||
S-OBSERVABILITY-01–04 creates/discovers tests:
|
||||
`<configured-build>/tests/VoidTests --filter '^observability_'`. Test detached callback
|
||||
drain, queued work after TLS destruction, coroutine migration, nested scope restore,
|
||||
duplicate span end, zero/invalid remote IDs, clock discontinuity, exiting producer shards,
|
||||
cardinality attack, slow/failing/reentrant exporter and timeout with in-flight buffers.
|
||||
Use deterministic schedules and allocation counters, then supported sanitizers/stress.
|
||||
|
||||
Apply [performance](../PERFORMANCE.md)'s common samples/confidence/regression rules to
|
||||
null hooks, unsampled spans, counter increments, histogram contention, collection and export.
|
||||
Report p50/p95/p99, throughput, allocations, total peak/retained RSS/CPU and build cost,
|
||||
with dropped observations and export failures included. No instrumentation overhead target
|
||||
is asserted before measured baselines.
|
||||
|
||||
[Migration](../MIGRATION.md) first adds optional adapters; existing Log fields retain their
|
||||
meaning and are not automatically converted into metric labels. New consumers explicitly
|
||||
pass ContextSnapshot at admission. Telemetry configuration has schema versions and unknown
|
||||
required fields fail validation; disabling exporters is a reversible operational rollback
|
||||
that leaves null hooks safe. This is not a stable cross-toolchain C ABI until separately
|
||||
versioned through C-09. Cited Log sources have graph coverage checks and direct inspection;
|
||||
all metrics, trace/export behavior and conformance/performance results remain proposed.
|
||||
Reference in new issue
Block a user