feat(jobs): propagate CorrelationId from web requests to background jobs#1225
Open
cesarcastrocuba wants to merge 1 commit intofullstackhero:developfrom
Open
feat(jobs): propagate CorrelationId from web requests to background jobs#1225cesarcastrocuba wants to merge 1 commit intofullstackhero:developfrom
cesarcastrocuba wants to merge 1 commit intofullstackhero:developfrom
Conversation
- Implemented CorrelationIdContext to store and access correlation IDs. - Added CorrelationIdMiddleware to capture X-Correlation-Id header or TraceIdentifier. - Updated FshJobFilter to capture CorrelationId during job creation. - Implemented CorrelationIdJobFilter to restore CorrelationId in Serilog LogContext. - Updated FshJobActivator to restore CorrelationId in DI scoped context. - Registered new services and filters in BuildingBlocks.Web and BuildingBlocks.Jobs.
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.
Feat: Jobs CorrelationId Propagation
Summary
This PR implements end-to-end CorrelationId propagation from web requests to background jobs (Hangfire). This ensures that every background job processed by the system can be traced back to its originating web request, significantly improving observability and debugging capabilities.
Key Changes
Infrastructure (BuildingBlocks.Core)
Web (BuildingBlocks.Web)
X-Correlation-Idheader (or fallback toTraceIdentifier) and initialize the context for every incoming request.Background Jobs (BuildingBlocks.Jobs)
LogContext, ensuring it appears in all logs generated during job execution.Serilogdependency to the Jobs project to support log context enrichment.Verification Results
correlation_idproperty, linked to the original HTTP request.Checklist