Allow changing trace continuation behavior for delayed messages - #7845
Merged
Conversation
irinascurtu
approved these changes
Jul 13, 2026
irinascurtu
marked this pull request as ready for review
July 13, 2026 11:49
tmasternak
requested changes
Jul 20, 2026
tmasternak
reviewed
Jul 27, 2026
tmasternak
reviewed
Jul 27, 2026
…ng recoverability actions
…e` in tests and implementation to enforce singleton usage.
…s for better trace clarity in recoverability pipeline.
…s to improve trace clarity in the recoverability pipeline.
…s, sagas, and recoverability) are happening before RoutingContext stage, and that StartNewTrace header is properly set before reaching that state.
…y set recoverability trace metadata for DelayedRetry
…layed-message trace mode The dedicated "Recoverability" span/activity work (ActivityFactory.StartRecoverabilityActivity and its wiring/tagging) has been split out to the recoverability-action-spans branch. This PR now only concerns how trace mode is decided for delayed sends, saga timeouts, and delayed retries via InstrumentationOptions.
tmasternak
force-pushed
the
tracing-recoverability-action
branch
from
July 28, 2026 12:09
39c64a0 to
c9769e2
Compare
tmasternak
reviewed
Jul 28, 2026
… refactor `ActivityFactory` constructor for improved initialization consistency
…regression Covers the three delayed-message origins this PR configures: explicit delayed sends (SendOperationTraceMode), saga timeouts (SagaTimeoutTraceMode), and recoverability delayed retries (Recoverability.DelayedRetryTraceMode). Each area verifies the backward-compatible default (start a new linked trace) and that the new option flips it to continuing the existing trace. The delayed-send tests also cover per-message override precedence: an explicit StartNewTraceOnReceive always wins, and a ContinueExistingTraceOnReceive request cannot defeat the delayed-send backward-compatible default. Also fixes When_retrying_messages.Should_correlate_delayed_retry_with_send, which asserted the opposite (same-trace) behavior and never actually ran due to Requires.DelayedDelivery() gating - switched to the in-memory transport's native delayed delivery support so it exercises the real code path. Restores PopulateRecoverabilityTraceMetadataBehavior's MoveToError handling (dropped when DelayedRetry-only gating was introduced), which had silently broken When_incoming_message_moved_to_error_queue.Should_add_start_new_trace_header. MoveToError itself stays hardcoded to always start a new trace, matching pre-existing behavior; it was not part of this PR's configurable scope after MoveToErrorTraceMode was removed from InstrumentationOptions.
tmasternak
reviewed
Jul 28, 2026
Replaces `TestEndpointContinuingTrace` with a unified `TestEndpoint` that dynamically configures `TraceMode` for delayed sends and saga timeouts. Simplifies `RetryingEndpoint` initialization. Removes redundant handler setup in trace tests.
…nto tracing-recoverability-action
tmasternak
reviewed
Jul 28, 2026
Co-authored-by: Tomasz Masternak <tomasz.masternak@particular.net>
…difiers in otel tests saga
…emoving redundant per-message overrides
tmasternak
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this change, delayed messages (explicit delayed sends, saga timeouts, and recoverability delayed retries) have always started a new OpenTelemetry trace when received, with a link back to the original trace.
New options
This PR introduces three new settings under
endpointConfiguration.Tracing():DelayedDelivery.SendOperationTraceModeDelayedDelivery.SagaTimeoutTraceModeRecoverability.DelayedRetryTraceModeControlled entirely on the sending side
Similarly to
SendTraceMode/PublishTraceModesettings, it's the sender that decides and stamps theStartNewTraceheader before dispatch (OpenTelemetrySendBehaviorfor delayed sends/timeouts,PopulateRecoverabilityTraceMetadataBehaviorfor delayed retries).Backward compatible by default
For backwards compatibility reasons, the per-message options (
SendOptions.StartNewTraceOnReceive()/ContinueExistingTraceOnReceive()) still do not apply to delayed messages. To change the behavior, new settings have to be used.