3.1 KiB
3.1 KiB
Observability Hooks, Context, Metrics, and Tracing
Task ID: S-OBSERVABILITY-01..04 Phase: P2 Status: APPROVED Contracts: C-01, C-02, C-03, C-04, C-05
1. Context and baseline
ObservabilityHooks and Observability do not yet exist in src/ or include/Void/Observability/. Higher modules need zero-dependency instrumentation hooks, HookLease drain lifetimes, immutable ContextSnapshot propagation, bounded producer-sharded metrics, head-sampled bounded tracing, and a deterministic text snapshot exporter with zero dependency on Async, IO, Runtime, Log, Net, Configuration, or System.
2. Deliverables
src/ObservabilityHooks/module.cmake(header-onlyVoid/Observability/Hooks.hpp, zero deps)src/Observability/module.cmake(INTERNAL_DEPS ObservabilityHooks Core Functional Time Memory,EXCLUDE_HEADERS Void/Observability/Hooks.hpp)include/Void/Observability/Hooks.hpp:MetricKind,AttributeView,MetricPoint,DiagnosticEvent,ObservationHooks,kNullObservationHooks,DrainStatus,HookRegistrationId,HookLease,HookSlotinclude/Void/Observability/Context.hpp:ObservabilityErrorCode,make_observability_error(kObservabilityErrorDomain = 14),TraceId,SpanId,TraceContext,ContextLimits,ContextSnapshot,ScopedContextinclude/Void/Observability/AsyncContext.hpp:bind_context,ContextAwaitable(no#include <Void/Async/...>)include/Void/Observability/Metrics.hpp&src/Observability/Metrics.cpp:MetricsLimits,InstrumentSpec,InstrumentHandle,HistogramSnapshot,SeriesSnapshot,MetricsSnapshot,MetricRegistryinclude/Void/Observability/Tracing.hpp&src/Observability/Tracing.cpp:TracingLimits,SpanStatus,SpanSpec,SpanEvent,CompletedSpan,ExportBatch,ExportReport,ExportOptions,Span,SpanExporter,CallbackSpanExporter,TextSnapshotExporter,Tracerinclude/Void/Observability/Observability.hpptests/standalone/Observability/Observability.cpptests/package/ObservabilityHooksOnly/{CMakeLists.txt,main.cpp}&tests/package/ObservabilityOnly/{CMakeLists.txt,main.cpp}registered intests/package/InstalledComponents.cmake
3. Edge cases
- Null hooks allocate zero memory and initialize no backend.
HookSlot::detach_and_draindetects self-drain from within an active callback (would_deadlock) and destroys owners strictly outside the lock.- Exiting producer threads retain their metric shards via
std::shared_ptr<Shard>inMetricRegistrywhilethread_localcaches holdstd::weak_ptr<Shard>, preventing leaks whenMetricRegistryis destroyed. - Cardinality overflow routes to
__overflow__and increments overflow counters; exporting respects span/byte caps, retry limits, and deadline/stop without spawning hidden background threads.
4. Verification commands
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w5-obs -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOID_ENABLED_MODULES="Observability;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w5-obs && /tmp/void-w5-obs/tests/VoidTests --filter "Observability*" && ctest --test-dir /tmp/void-w5-obs --output-on-failure --timeout 120'