Skip to content

[Cosmos] Replace global evaluation store with pipeline-level context for fault injection diagnostics #4022

@tvaron3

Description

@tvaron3

The fault injection evaluation store (EVALUATION_STORE in fault_injection/mod.rs) uses a global LazyLock<Mutex<HashMap<u64, Vec<FaultInjectionEvaluation>>>> to pass evaluation results from FaultClient (at the HttpClient level) to the transport pipeline (which has access to DiagnosticsContextBuilder).

This works but is clunky — it requires a store/take contract, uses a global static, and passes correlation IDs via request headers.

When the driver has its own HTTP pipeline with a custom context object (rather than using azure_core::HttpClient trait), the evaluations should be encoded directly in the operation/transport metadata and flow through the pipeline without a side channel.

Current approach:

  1. Transport pipeline generates a unique request ID, adds as x-ms-fault-injection-request-id header
  2. FaultClient reads the ID, stores evaluations in a global HashMap by that ID
  3. Transport pipeline retrieves evaluations by ID after the await

Target approach:
Pass an evaluation collector (e.g., Arc<Mutex<Vec<FaultInjectionEvaluation>>>) through the pipeline context object directly, eliminating the global store and header-based correlation.

Blocked on: Custom HTTP pipeline with context passing (Transport Pipeline Spec future step).

Ref: PR #3996 review comment by @analogrelay

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosThe azure_cosmos crate

Type

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions