Skip to content

Nested Cargo calls and session IDs #16477

@weihanglo

Description

@weihanglo

Problem

With -Zbuild-analysis, Cargo assigns a unique session ID to each invocation for logging purpose. However, this creates challenges when Cargo calls itself recursively (for example cargo fix) or when external build orchestrators call Cargo multiple times within a single "build session." These use cases might want a way to correlate all calls.

Currently, each nested call gets its own session ID, making it difficult to associate related logs across the entire build process.

Proposed Solution

Some possible solutions:

  • Do nothing. Nested calls get unique IDs (timestamp will be different unless the machine is really, really fast)
  • Allow callers to specify a custom session ID that nested calls can inherit or reference.
    • For logging we might need to capture this field as well. For example build-started event can have a custom_metadata field for external build orchestrators
  • Generate hierarchical session IDs automatically. For example, parent session ID as prefix, and with unique suffixes for each nested call

Notes

Part of #15844

See also

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-build-analysisNightly: build-analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions