Repository navigation
Open
Labels
enhancementNew feature or requestextensionExtension behaviors / helperstraceabilityTracing, Activity, correlation, diagnostics
Description
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
- New
ActivityObserver(in the Diagnostics layer) subscribed toContextLifecycleEvent. - Produces a span named
context.executeonExecuteInContext, with attributescontext.typeandcontext.id. - Uses an injected
ActivitySource(e.g.services.AddActivitySource("ModularityKit.Context.Shop")). - Hosting example showing tracing with Jaeger/Zipkin.
Design Expectations
Activityis never created insideContextManager(Core) — per 10.3 the observer owns trace creation.- The context stays immutable (no reference to
Activitystored onIContext); 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 modernTimeProvider-friendly API for testable timestamps.
Acceptance Criteria
- Adding
AddActivitySource+ registering the observer requires no change to application code that usesExecuteInContext. - Spans appear in Jaeger/Zipkin/OpenTelemetry with
context.typeandcontext.id. -
IContextremains immutable; noActivityproperty is added. - Tracing is silent/absent unless the observer is registered.
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).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestextensionExtension behaviors / helperstraceabilityTracing, Activity, correlation, diagnostics
Activity