Skip to content

Conversation

@BlakeOrth
Copy link
Contributor

Which issue does this PR close?

This does not fully close, but is an incremental building block component for:

Functionally this code currently does nothing, but it will allow users to change the mode of an instrumented object store through either a CLI flag or with a runtime command.

The full context of how this code is likely to progress can be seen in the POC for this effort:

Rationale for this change

This is another bite-sized building block on the road to completing #17207

What changes are included in this PR?

  • Adds mode type to allow changing the mode of an InstrumentedObjectStore to datafusion-cli
  • Implements string parsing and u8 conversion for InstrumentedObjectStoreMode
  • Adds tests to validate trait implementations

Are these changes tested?

Yes. Unit tests have been added for the trait implementations on this new type.

Are there any user-facing changes?

No.

cc @alamb

(I'm trying to keep these as small as possible and have them still make sense, however the PRs following this one will likely start to introduce real functionality and may end up being a bit larger)

 - Adds mode type to allow changing the mode of an
   InstrumentedObjectStore to datafusion-cli
 - Implements string parsing and u8 conversion for
   InstrumentedObjectStoreMode
 - Adds tests to validate trait implementations
impl FromStr for InstrumentedObjectStoreMode {
type Err = DataFusionError;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that while this is functionally "dead code" in the current implementation, it's important for parsing cli arguments/commands which will come in a follow-on PR "soon" (tm)

#[derive(Debug)]
struct InstrumentedObjectStore {
inner: Arc<dyn ObjectStore>,
instrument_mode: AtomicU8,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This type likely seems like an odd decision in isolation, but it becomes necessary when the mode actually needs to switch behavior in the ObjectStore implementation methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe an AtomicBool would make sense given it only has two states 🤔

Minor detail however

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! ...but -- The actual intent here is to have this actually end up looking like:

pub enum InstrumentedObjectStoreMode {
    /// Disable collection of profiling data
    #[default]
    Disabled,
    /// Enable collection of profiling data and output a summary
    Summary,
    /// Enable collection of profiling data and output all profiling details
    Trace,
}

Thus why it's an AtomicU8. I can change it to a bool until the above is implemented in a PR if that would be preferable though.

#[derive(Debug)]
struct InstrumentedObjectStore {
inner: Arc<dyn ObjectStore>,
instrument_mode: AtomicU8,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe an AtomicBool would make sense given it only has two states 🤔

Minor detail however

@alamb alamb added this pull request to the merge queue Oct 9, 2025
@alamb
Copy link
Contributor

alamb commented Oct 9, 2025

Thanks @BlakeOrth

Merged via the queue into apache:main with commit 73b1f2b Oct 9, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants