Skip to content

feat: Add support to set partition key and headers via Request Context#3678

Merged
lillo42 merged 7 commits into
BrighterCommand:masterfrom
lillo42:allow-set-partition-key
Jul 28, 2025
Merged

feat: Add support to set partition key and headers via Request Context#3678
lillo42 merged 7 commits into
BrighterCommand:masterfrom
lillo42:allow-set-partition-key

Conversation

@lillo42

@lillo42 lillo42 commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Add support to set Partition Key and Headers via Request Context

fix: #3662

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Failed
Enforce advisory code health rules (1 file with Complex Method)

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
CloudEventJsonMessageMapper.cs 1 advisory rule 10.00 → 9.69 Suppress

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

@lillo42 lillo42 self-assigned this Jul 21, 2025

@iancooper iancooper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some questions here. We already have a Span associated with the Context. We should be obtaining this information from the span associated with the context when we send it. Our context's span should inherit from any parent span it was created with.

We propagate the context in the BrighterTracer WriteProducerEvent where we call our customer propagator to fill the values in the message header.

I am wondering if this misses that context

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Health Improved (1 files improve in Code Health)

Gates Failed
Enforce advisory code health rules (1 file with Complex Conditional)

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
RequestContextExtensions.cs 1 advisory rule 10.00 → 9.39 Suppress
View Improvements
File Code Health Impact Categories Improved
CloudEventsTransformer.cs 8.92 → 9.69 Complex Method, Overall Code Complexity

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

Comment on lines +99 to +101
if (context != null
&& context.Bag.TryGetValue(RequestContextBagNames.Headers, out var tmp)
&& tmp is Dictionary<string, object> headers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Complex Conditional
GetHeaders has 1 complex conditionals with 2 branches, threshold = 2

Suppress

Comment on lines +143 to +145
if (context != null
&& context.Bag.TryGetValue(RequestContextBagNames.CloudEventsAdditionalProperties, out var tmp)
&& tmp is Dictionary<string, object> cloudEventAdditionalProperties)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Complex Conditional
GetCloudEventAdditionalProperties has 1 complex conditionals with 2 branches, threshold = 2

Suppress

@lillo42 lillo42 marked this pull request as ready for review July 28, 2025 14:20
@lillo42 lillo42 changed the title feat: Add support to set partition key/Headers/trace parent/trace state/baggage via Request Context feat: Add support to set partition key and headers via Request Context Jul 28, 2025
@lillo42 lillo42 merged commit 18b5ec9 into BrighterCommand:master Jul 28, 2025
22 of 24 checks passed
@lillo42 lillo42 deleted the allow-set-partition-key branch July 28, 2025 14:22
DevJonny pushed a commit to DevJonny/Brighter that referenced this pull request Feb 28, 2026
BrighterCommand#3678)

* feat: Allow flow PartitionKey/Headers/TraceParent/TraceState/Baggage to message when using default mapper

* feat: Change MassTransit and JustSaying to flow partition key, trace parent, baggage headers & trace state

* fix  build

* feat: Remove Trace Parent/State and Baggage, also add DefaultHeaders for Publication and use RequestContext Bag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add support to set PartitionKey, Bag and other property via RequestContext

2 participants