Skip to content

[Context]: add bounded ContextBaggage key-value container #14

Description

@rian-be

Summary

Add a bounded ContextBaggage — a key/value container carried alongside context/trace, subject to the same limits as the context itself (max key count, max total size) to avoid transport overload.

Goal

Provide an ergonomic, bounded side-channel for auxiliary fields (tenant, region, user tags) without expanding the IContext contract on every new field.

Problem

Ad hoc baggage (e.g. W3C baggage header) has no structure or limits here. Unbounded key/value growth can overload HTTP headers/queue headers, and heavy use risks violating the principle "context is metadata, not state".

Scope

  • Key-value bag container that follows the current scope/ambient flow.
  • Bounded: configurable max number of keys and max total encoded size.
  • Set/Get/Remove API with static ambient facade plus injectable instance.
  • Wire support so the bag rides standard baggage header (compose with propagators from [Context]: add W3C/B3/composite propagator adapters and queue carriers #12).
  • Unit tests for limits and ambient flow.

Design Expectations

Acceptance Criteria

  • Bag is bounded; writes above key/size limits fail or are dropped.
  • Values flow through ambient scope and propagate via header when registered.
  • No change to existing context/execution APIs.

Non-Goals

  • No business-state usage; the bag is auxiliary metadata only.
  • No persistence, retry, or compliance logic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestextensionExtension behaviors / helperspropagationContext across process boundaries

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions