Skip to content

[Context]: add diagnostic events for context lifecycle #8

Description

@rian-be

Summary

Add lightweight diagnostic events for context creation, activation, execution, and disposal.

Goal

Make the package observable without turning it into a full logging or telemetry framework.

Problem

The current package has execution helpers and diagnostic models, but there is no simple event surface for consumers who want to react to context lifecycle changes in real time.

Without events, application code has to infer lifecycle changes indirectly from logs or wrapper code. That is awkward for:

  • tracing
  • auditing
  • debugging
  • integration with observability pipelines
  • custom instrumentation in larger applications

Scope

  • Add a context lifecycle event model
  • Emit events for context begin, end, success, fault, and cancellation
  • Expose event payloads with enough metadata for diagnostics
  • Keep the event surface opt-in
  • Keep event emission lightweight
  • Keep the event layer in the core package if it stays thin enough
  • Add examples showing how consumers can subscribe to events

Design Expectations

  • Events should be small, structured, and easy to consume.
  • Event emission should not change context semantics.
  • The API should stay focused on lifecycle observation, not policy.
  • Consumers should be able to ignore the event layer entirely.

Acceptance Criteria

  • The package exposes clear diagnostic event surface.
  • Events describe context lifecycle changes with useful metadata.
  • Execution behavior stays unchanged when no listeners are present.
  • The event model stays lightweight and predictable.

Non Goals

  • No full audit backend.
  • No persistence storage.
  • No policy enforcement.
  • No background event bus.
  • No ASP.NET specific diagnostics integration.

Notes

This issue is for lifecycle observability, not for broader governance or telemetry infrastructure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions