Summary
Add an opt-in ActivityObserver that consumes already-emitted ContextLifecycleEvents and produces System.Diagnostics.Activity spans (named context.execute), so APM tools (Jaeger/Zipkin/OpenTelemetry) work without touching the core execution path.
Goal
Make the package observable "for free" in apps already using tracing, while keeping Core neutral to any telemetry technology.
Problem
ContextManager/ExecuteInContext already emits lifecycle events, but nothing turns them into standard spans. Consumers who want to correlate context execution with existing traces in Jaeger/Zipkin/OpenTelemetry have to hand-wire an observer and know the exact event shape.
Scope
Design Expectations
Activity is never created inside ContextManager (Core) — per 10.3 the observer owns trace creation.- The context stays immutable (no reference to
Activity stored on IContext); correlation is carried via lifecycle-event tags per 1.9. - Reduce span noise: document filtering; spans are opt-in via registration.
- Uses
System.Diagnostics.DiagnosticSource / the modern TimeProvider-friendly API for testable timestamps.
Acceptance Criteria
Non-Goals
- No change to the Core runtime execution path.
- No APM-specific sink (OpenTelemetry/AppInsights teams handle export).
- No global relation registry kept by the library (tree is built externally, per 1.10/10.4).
Summary
Add an opt-in
ActivityObserverthat consumes already-emittedContextLifecycleEvents and producesSystem.Diagnostics.Activityspans (namedcontext.execute), so APM tools (Jaeger/Zipkin/OpenTelemetry) work without touching the core execution path.Goal
Make the package observable "for free" in apps already using tracing, while keeping Core neutral to any telemetry technology.
Problem
ContextManager/ExecuteInContextalready emits lifecycle events, but nothing turns them into standard spans. Consumers who want to correlate context execution with existing traces in Jaeger/Zipkin/OpenTelemetry have to hand-wire an observer and know the exact event shape.Scope
ActivityObserver(in the Diagnostics layer) subscribed toContextLifecycleEvent.context.executeonExecuteInContext, with attributescontext.typeandcontext.id.ActivitySource(e.g.services.AddActivitySource("ModularityKit.Context.Shop")).Design Expectations
Activityis never created insideContextManager(Core) — per 10.3 the observer owns trace creation.Activitystored onIContext); correlation is carried via lifecycle-event tags per 1.9.System.Diagnostics.DiagnosticSource/ the modernTimeProvider-friendly API for testable timestamps.Acceptance Criteria
AddActivitySource+ registering the observer requires no change to application code that usesExecuteInContext.context.typeandcontext.id.IContextremains immutable; noActivityproperty is added.Non-Goals