Skip to content

refactor(otel): centralize command span tagging via ITraceable interface - #90

Merged
falberthen merged 3 commits into
masterfrom
refactor/otel-traceable-command-interface
Apr 19, 2026
Merged

refactor(otel): centralize command span tagging via ITraceable interface#90
falberthen merged 3 commits into
masterfrom
refactor/otel-traceable-command-interface

Conversation

@falberthen

Copy link
Copy Markdown
Owner

Added

Introduces ITraceable, a dedicated interface in Core.Infrastructure.OpenTelemetry, to centralize span tagging in the CommandBus instead of scattering Activity.Current?.SetTag(...) calls across command handlers.

  • Commands that carry a known OrderId implement ITraceable.GetSpanTags(). The CommandBus applies the tags automatically when dispatching, only when an active span exists.
  • Handlers where the tag value is not known at dispatch time (e.g., PlaceOrderHandler, where the order ID is generated inside the handler) retain the direct SetTag call as a documented exception.
  • Keeps ICommand as a pure dispatch contract and isolates the observability concern behind its own interface.

Removed

Removes Activity.Current?.SetTag("order.id", ...) from command handlers. The tag is now applied centrally by CommandBus for any command implementing ITraceable, eliminating the risk of new handlers silently missing the annotation.

@falberthen falberthen self-assigned this Apr 19, 2026
@falberthen falberthen added the enhancement New feature or request label Apr 19, 2026
@falberthen
falberthen merged commit 74ed2c8 into master Apr 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant