Skip to content

feat(instrumentation-build): add event-only generation - #500

Merged
rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
johanpel:event-build
Aug 4, 2026
Merged

feat(instrumentation-build): add event-only generation#500
rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
johanpel:event-build

Conversation

@johanpel

@johanpel johanpel commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

Allow quent-instrumentation-build to generate event types without exposing or depending on the full instrumentation surface.

  • Add an instrumentation option, enabled by default for compatibility.
  • Generate only event types, records, entity markers, and optional AnyEvent types when instrumentation is disabled.
  • Add typed debug and serde derive options. Debug is enabled by default; serde remains opt-in.
  • Move entity-reference types into quent-events and re-export them from quent-instrumentation.
  • Deduplicate typed and custom derives.

Related issues

#491

Testing

Passed:

  • pixi run cargo fmt --all -- --check
  • pixi run cargo test -p quent-instrumentation-build -p quent-events -p quent-instrumentation
  • pixi run cargo clippy -p quent-instrumentation-build -p quent-events -p quent-instrumentation --all-features --all-targets -- -D warnings
  • Instrumentation example lint and execution

Written by Codex.

@johanpel johanpel changed the title refactor(event-build): extract schema event generation feat(instrumentation-build): add event-only generation Aug 3, 2026
@johanpel
johanpel marked this pull request as ready for review August 3, 2026 08:56
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds shared EntityRef, AnyEntity, and Entity contracts in the events crate. The instrumentation generator now supports event-only or instrumented output modes with configurable Debug and Serde derives. The instrumentation crate adopts the shared event contract and removes the duplicate local implementation. Runtime code generation now receives Options to support both output modes.

Changes

Events and code generation

Layer / File(s) Summary
Shared event contracts
Cargo.toml, crates/events/*
Adds UUID-backed EntityRef with optional payload, AnyEntity marker type, dynamic attribute and UUID re-exports, Serde feature propagation through dependencies, and the Entity trait that associates entity types with EntityEvent types.
Configurable generator options
crates/instrumentation-build/src/lib.rs
Options gains instrumentation, debug, and serde fields. Default options enable instrumentation and debug but leave Serde disabled. Runtime selection switches between quent_instrumentation and quent_events based on output mode.
Derive and type generation
crates/instrumentation-build/src/common.rs, data_type.rs, records.rs, example/build.rs
derive_attr now accepts debug, serialize, and deserialize flags, parses configured derives, canonicalizes paths, deduplicates derives, and emits empty attributes when needed. map_data_type returns Result<TokenStream, GenerateError> and propagates options through recursive calls. Record generation passes debug and serde options through derive generation and data type mapping.
Event generation modes
crates/instrumentation-build/src/events.rs, any_event.rs, lib.rs
Event generation emits runtime re-exports, per-entity marker types, and EntityEvent metadata. generate_str conditionally emits instrumentation reexports, entity types, and model integration for instrumented output only. any_event derives now combine configured event derives with debug and serde options. Derives are deduplicated in generated output.
Runtime generation updates
crates/instrumentation-build/src/runtime/*
entity_runtime_types and entity_handle now accept Options and forward them to type mapping. Generated Handle requires E: InstrumentedEntity. Generated entities implement InstrumentedEntity without local event association. Tests separately generate event types and pass default options.
Instrumentation contract adoption
crates/instrumentation/src/*
The local Entity trait is renamed to InstrumentedEntity and extends quent_events::Entity. The entity_ref module is removed. Observer, HandleInner, and trait bounds now use InstrumentedEntity. Re-exports now surface shared EntityRef and AnyEntity from quent_events through a hidden events module.

Estimated code review effort: 4 (Complex) | ~50 minutes

Possibly related PRs

  • rapidsai/quent#400: Modifies any_event generation and Options configuration to extend the generator.
  • rapidsai/quent#418: Introduces quent-dynamic-attributes crate adoption in generated types and events re-exports.
  • rapidsai/quent#466: Refactors generic instrumentation runtime that this PR extends with event-only generation and InstrumentedEntity support.

Suggested labels: feature request

Suggested reviewers: joosthooz, dhruv9vats, mbrobbel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: event-only generation in instrumentation-build.
Description check ✅ Passed The description covers the change, related issue, and testing performed; the Screenshots section is not needed because this is not a UI change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/events/Cargo.toml`:
- Line 12: Move the quent-dynamic-attributes dependency definition into the
workspace’s [workspace.dependencies], preserving its local path there, and
update the crate-level dependency declaration to use workspace = true. Remove
the crate-local path declaration from the dependency entry.

In `@crates/events/src/entity_ref.rs`:
- Around line 17-42: Add focused tests for the public EntityRef component:
verify EntityRef::new preserves the target UUID and payload, confirm the default
T = () payload works, and add feature-gated serde coverage ensuring the phantom
_entity field is skipped during serialization/deserialization. Keep the tests
colocated with EntityRef and AnyEntity without changing their public API.

In `@crates/instrumentation-build/src/common.rs`:
- Around line 44-45: Update the path handling before the deduplication logic
using the existing derive-path processing symbols in common.rs: normalize
serde::Serialize and serde::Deserialize paths to the canonical configured form
before generating their token-string keys, so equivalent spellings retain only
one derive. Add a regression test covering both serde path spellings and verify
the generated derives compile without duplicates.

In `@crates/instrumentation-build/src/data_type.rs`:
- Around line 32-35: Replace the MAX_TYPE_DEPTH assertion in map_data_type with
a GenerateError variant for excessive nesting, change map_data_type to return
Result, and propagate that result through event, record, and handle generation.
Update the existing panic-focused test to assert the returned generation error
instead.

In `@crates/instrumentation-build/src/lib.rs`:
- Around line 200-201: Remove the opts.any_event/instrumentation validation in
the generation flow and delete the AnyEventRequiresInstrumentation error
variant. Update the existing test near the AnyEvent validation to cover
instrumentation: false with any_event: true, asserting that generated code uses
quent_events::Event-based AnyEvent output without instrumentation handles,
observers, or model requirements.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: accbb56d-6f58-4238-8de4-7411e9c9e8bb

📥 Commits

Reviewing files that changed from the base of the PR and between cd0a3ef and 89f7c6d.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
  • crates/instrumentation-build/example/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • crates/events/Cargo.toml
  • crates/events/src/entity_ref.rs
  • crates/events/src/lib.rs
  • crates/instrumentation-build/example/build.rs
  • crates/instrumentation-build/src/any_event.rs
  • crates/instrumentation-build/src/common.rs
  • crates/instrumentation-build/src/data_type.rs
  • crates/instrumentation-build/src/events.rs
  • crates/instrumentation-build/src/lib.rs
  • crates/instrumentation-build/src/records.rs
  • crates/instrumentation-build/src/runtime/handle.rs
  • crates/instrumentation-build/src/runtime/mod.rs
  • crates/instrumentation/src/entity.rs
  • crates/instrumentation/src/lib.rs
💤 Files with no reviewable changes (1)
  • crates/instrumentation-build/example/build.rs

Comment thread crates/events/Cargo.toml Outdated
Comment thread crates/instrumentation-build/src/common.rs
Comment thread crates/instrumentation-build/src/data_type.rs Outdated
Comment thread crates/instrumentation-build/src/lib.rs Outdated

@coderabbitai coderabbitai 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/events/Cargo.toml`:
- Line 12: Move the quent-dynamic-attributes dependency definition into the
workspace’s [workspace.dependencies], preserving its local path there, and
update the crate-level dependency declaration to use workspace = true. Remove
the crate-local path declaration from the dependency entry.

In `@crates/events/src/entity_ref.rs`:
- Around line 17-42: Add focused tests for the public EntityRef component:
verify EntityRef::new preserves the target UUID and payload, confirm the default
T = () payload works, and add feature-gated serde coverage ensuring the phantom
_entity field is skipped during serialization/deserialization. Keep the tests
colocated with EntityRef and AnyEntity without changing their public API.

In `@crates/instrumentation-build/src/common.rs`:
- Around line 44-45: Update the path handling before the deduplication logic
using the existing derive-path processing symbols in common.rs: normalize
serde::Serialize and serde::Deserialize paths to the canonical configured form
before generating their token-string keys, so equivalent spellings retain only
one derive. Add a regression test covering both serde path spellings and verify
the generated derives compile without duplicates.

In `@crates/instrumentation-build/src/data_type.rs`:
- Around line 32-35: Replace the MAX_TYPE_DEPTH assertion in map_data_type with
a GenerateError variant for excessive nesting, change map_data_type to return
Result, and propagate that result through event, record, and handle generation.
Update the existing panic-focused test to assert the returned generation error
instead.

In `@crates/instrumentation-build/src/lib.rs`:
- Around line 200-201: Remove the opts.any_event/instrumentation validation in
the generation flow and delete the AnyEventRequiresInstrumentation error
variant. Update the existing test near the AnyEvent validation to cover
instrumentation: false with any_event: true, asserting that generated code uses
quent_events::Event-based AnyEvent output without instrumentation handles,
observers, or model requirements.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: accbb56d-6f58-4238-8de4-7411e9c9e8bb

📥 Commits

Reviewing files that changed from the base of the PR and between cd0a3ef and 89f7c6d.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
  • crates/instrumentation-build/example/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • crates/events/Cargo.toml
  • crates/events/src/entity_ref.rs
  • crates/events/src/lib.rs
  • crates/instrumentation-build/example/build.rs
  • crates/instrumentation-build/src/any_event.rs
  • crates/instrumentation-build/src/common.rs
  • crates/instrumentation-build/src/data_type.rs
  • crates/instrumentation-build/src/events.rs
  • crates/instrumentation-build/src/lib.rs
  • crates/instrumentation-build/src/records.rs
  • crates/instrumentation-build/src/runtime/handle.rs
  • crates/instrumentation-build/src/runtime/mod.rs
  • crates/instrumentation/src/entity.rs
  • crates/instrumentation/src/lib.rs
💤 Files with no reviewable changes (1)
  • crates/instrumentation-build/example/build.rs
🛑 Comments failed to post (1)
crates/events/src/entity_ref.rs (1)

17-42: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add tests for the new entity-reference component.

EntityRef and AnyEntity are new public types, but this file has no tests. Add coverage for EntityRef::new, the default payload type, and serde behavior when the feature is enabled.

As per coding guidelines, “New Rust components must include accompanying tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/events/src/entity_ref.rs` around lines 17 - 42, Add focused tests for
the public EntityRef component: verify EntityRef::new preserves the target UUID
and payload, confirm the default T = () payload works, and add feature-gated
serde coverage ensuring the phantom _entity field is skipped during
serialization/deserialization. Keep the tests colocated with EntityRef and
AnyEntity without changing their public API.

Source: Coding guidelines

Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>

@coderabbitai coderabbitai 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.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
crates/instrumentation-build/src/lib.rs-157-158 (1)

157-158: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document TypeNestingTooDeep.

GenerateError::TypeNestingTooDeep is public through GenerateError. Add a doc comment that states when generation returns this variant.

As per path instructions, “New pub items need a doc comment and justified visibility; prefer pub(crate) or doc(hidden) when not part of the curated public API.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/instrumentation-build/src/lib.rs` around lines 157 - 158, Add a Rust
doc comment to the public GenerateError::TypeNestingTooDeep variant describing
the generation condition that returns it: type nesting exceeds the configured
maximum depth. Keep the existing error annotation and visibility unchanged.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Other comments:
In `@crates/instrumentation-build/src/lib.rs`:
- Around line 157-158: Add a Rust doc comment to the public
GenerateError::TypeNestingTooDeep variant describing the generation condition
that returns it: type nesting exceeds the configured maximum depth. Keep the
existing error annotation and visibility unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: c1e861b2-b303-4d99-8b99-ad6bd3407ef9

📥 Commits

Reviewing files that changed from the base of the PR and between 89f7c6d and 4f8f4d4.

📒 Files selected for processing (8)
  • Cargo.toml
  • crates/events/Cargo.toml
  • crates/instrumentation-build/src/common.rs
  • crates/instrumentation-build/src/data_type.rs
  • crates/instrumentation-build/src/events.rs
  • crates/instrumentation-build/src/lib.rs
  • crates/instrumentation-build/src/records.rs
  • crates/instrumentation-build/src/runtime/handle.rs

Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>

@joosthooz joosthooz 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.

Looks good, thanks!

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/instrumentation-build/src/runtime/mod.rs`:
- Around line 56-68: The public rename from Entity to InstrumentedEntity breaks
downstream users of quent_instrumentation::Entity. Add a compatibility re-export
alias, preferably pub use InstrumentedEntity as Entity, in the existing
quent_instrumentation API while preserving InstrumentedEntity for current code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: e941440d-9247-4afa-8e0f-8423019703c8

📥 Commits

Reviewing files that changed from the base of the PR and between 4f8f4d4 and bb3c219.

📒 Files selected for processing (8)
  • crates/instrumentation-build/src/common.rs
  • crates/instrumentation-build/src/lib.rs
  • crates/instrumentation-build/src/runtime/mod.rs
  • crates/instrumentation/src/entity.rs
  • crates/instrumentation/src/handle.rs
  • crates/instrumentation/src/lib.rs
  • crates/instrumentation/src/model.rs
  • integrations/nvtx/example/tests/thread_id.rs

Comment on lines +56 to +68
pub struct Handle<E: ::quent_instrumentation::InstrumentedEntity<Context = Context<#model>>> {
inner: ::quent_instrumentation::HandleInner<E>,
}

impl<E: ::quent_instrumentation::Entity<Context = Context<#model>>>
impl<E: ::quent_instrumentation::InstrumentedEntity<Context = Context<#model>>>
::core::convert::From<::quent_instrumentation::HandleInner<E>> for Handle<E>
{
fn from(inner: ::quent_instrumentation::HandleInner<E>) -> Self {
Self { inner }
}
}

impl<E: ::quent_instrumentation::Entity<Context = Context<#model>>> ::core::ops::Deref
impl<E: ::quent_instrumentation::InstrumentedEntity<Context = Context<#model>>> ::core::ops::Deref

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 4 \
  'quent_instrumentation::Entity|pub\s+(trait|type)\s+Entity\b|InstrumentedEntity' \
  crates/instrumentation crates/instrumentation-build

Repository: rapidsai/quent

Length of output: 13133


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- instrumentation public exports and trait definitions ---'
sed -n '1,80p' crates/instrumentation/src/lib.rs
sed -n '1,45p' crates/instrumentation/src/entity.rs

printf '%s\n' '--- repository references to the old and new names ---'
rg -n -C 3 \
  '\bquent_instrumentation::Entity\b|\bInstrumentedEntity\b|\bpub\s+(trait|type)\s+Entity\b' \
  --glob '!target/**' --glob '!dist/**' .

printf '%s\n' '--- generated runtime tests and implementation ---'
sed -n '45,125p' crates/instrumentation-build/src/runtime/mod.rs
sed -n '330,370p' crates/instrumentation-build/src/lib.rs

printf '%s\n' '--- recent file-level change summary ---'
git diff --stat

Repository: rapidsai/quent

Length of output: 19180


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- commit context ---'
git log --oneline -5 -- crates/instrumentation/src/entity.rs crates/instrumentation/src/lib.rs crates/instrumentation-build/src/runtime/mod.rs

printf '%s\n' '--- previous public API ---'
parent="$(git rev-parse HEAD^)"
for file in crates/instrumentation/src/entity.rs crates/instrumentation/src/lib.rs crates/instrumentation-build/src/runtime/mod.rs; do
  printf '\n--- %s at %s ---\n' "$file" "$parent"
  git show "$parent:$file" 2>/dev/null | sed -n '1,135p' || true
done

printf '%s\n' '--- compatibility and migration documentation ---'
rg -n -i -C 2 \
  'compatib|migrat|breaking|InstrumentedEntity|quent_instrumentation::Entity' \
  README.md docs crates --glob '!target/**' --glob '!dist/**' 2>/dev/null || true

Repository: rapidsai/quent

Length of output: 21349


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- refactor commit summaries ---'
git show --stat --oneline 89f7c6d 9406f2d

printf '%s\n' '--- instrumentation trait before and after the refactor ---'
for rev in 89f7c6d^ 89f7c6d 9406f2d^ 9406f2d; do
  printf '\n--- %s ---\n' "$rev"
  git show "$rev:crates/instrumentation/src/entity.rs" 2>/dev/null \
    | sed -n '1,35p' || true
  git show "$rev:crates/instrumentation/src/lib.rs" 2>/dev/null \
    | rg -n -C 2 'pub use .*entity|Entity|InstrumentedEntity' || true
done

printf '%s\n' '--- runtime generator trait references across the refactor ---'
for rev in 89f7c6d^ 89f7c6d 9406f2d^ 9406f2d; do
  printf '\n--- %s ---\n' "$rev"
  git show "$rev:crates/instrumentation-build/src/runtime/mod.rs" 2>/dev/null \
    | rg -n -C 2 'quent_instrumentation::(Entity|InstrumentedEntity)|impl .*Entity' || true
done

Repository: rapidsai/quent

Length of output: 11658


Preserve or document the Entity rename

quent_instrumentation::Entity was publicly exported before this change and is now absent. Downstream bounds and implementations using it will fail to compile. Add pub use InstrumentedEntity as Entity, or document the migration and add compatibility coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/instrumentation-build/src/runtime/mod.rs` around lines 56 - 68, The
public rename from Entity to InstrumentedEntity breaks downstream users of
quent_instrumentation::Entity. Add a compatibility re-export alias, preferably
pub use InstrumentedEntity as Entity, in the existing quent_instrumentation API
while preserving InstrumentedEntity for current code.

@johanpel

johanpel commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Just an audit failure fixed in #530

/merge

@johanpel

johanpel commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit d0cc2db into rapidsai:main Aug 4, 2026
19 of 20 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