Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/codegen/src/cxx_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ fn emit_context_bridge(
);
inner.block_on(async {
let (#(#build_fields,)*) = #q::tokio::try_join!(
#(inner.observer::<#build_event_tys>(options.clone()),)*
#(inner.observer::<#build_event_tys>(&options),)*
)
.map_err(|e| e.to_string())?;
Ok::<_, String>((#(#build_wraps(#build_fields),)*))
Expand Down
2 changes: 1 addition & 1 deletion crates/codegen/src/pyo3_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ fn emit_context(
);
inner.block_on(async {
let (#(#build_fields,)*) = #q::tokio::try_join!(
#(inner.observer::<#build_event_tys>(options.clone()),)*
#(inner.observer::<#build_event_tys>(&options),)*
)
.map_err(|err| pyo3::exceptions::PyRuntimeError::new_err(err.to_string()))?;
Ok::<_, pyo3::PyErr>((#(#build_wraps(#build_fields),)*))
Expand Down
3 changes: 2 additions & 1 deletion crates/instrumentation-build/example/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions crates/instrumentation-build/example/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// Schema -> generated Rust instrumentation source.
let opts = Options {
// To just print the events in this example, we'll be using the callback
// exporter. This exporter takes a type-erased event, so in order to
// simplify downcasting back to a statically-typed event, this features
// enables the generation of the "AnyEvent" helper type (see main.rs).
// This is typically left false when using "real" exporters.
any_event: true,
..Default::default()
// Generate `DemoEvent`, which lets one typed callback receive events
// from every entity in the model.
umbrella_event: true,
..Options::default()
};
let GenerateInfo { path, warnings } = generate(&parsed.schema, &opts)?;

Expand Down
19 changes: 8 additions & 11 deletions crates/instrumentation-build/example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

use quent_instrumentation::{EventCallback, ExporterOptions};
use quent_instrumentation::EventCallback;

use crate::demo::{Connection, Context, Demo, Handle, Observer, Query, Server, Uuid};
use crate::demo::{Connection, Context, Demo, DemoEvent, Handle, Observer, Query, Server, Uuid};

#[allow(unused)]
mod demo {
include!(concat!(env!("OUT_DIR"), "/demo.rs"));
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
// The context owns the exporter and exposes one observer per entity type.
let context: Context<Demo> = Context::try_new(Some(debug_printing_exporter()))?;
// The context builds one exporter pipeline per entity event type and
// exposes the corresponding typed observers.
let context: Context<Demo> = Context::try_new(println_exporter())?;

// `observer.handle()` creates a fresh entity instance to events emit for.
let mut server = context.observer::<Server>().handle();
Expand Down Expand Up @@ -71,11 +72,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

/// Return an exporter that debug-prints each emitted event's payload.
fn debug_printing_exporter() -> ExporterOptions {
ExporterOptions::Callback(EventCallback::new(|recorded| {
if let Some(event) = demo::AnyEvent::from_any(recorded.event.as_ref()) {
println!("{event:?}");
}
}))
/// Return a callback that debug-prints each emitted event.
fn println_exporter() -> EventCallback<DemoEvent> {
EventCallback::new(|event| println!("{event:?}"))
}
148 changes: 0 additions & 148 deletions crates/instrumentation-build/src/any_event.rs

This file was deleted.

Loading