Expand description
Procedural macros for the obs SDK.
Phase-1 surface (impl-plan task 1.9):
Event(#[derive(Event)]) — emitsEventSchemaimpl,EventSchemaErasedimpl,linkme::distributed_sliceregistration, typed builder, and the const-eval lint block (L001/L002/L003/L011).emit— terseobs::emit!(MyEvent { … })shorthand.scope— placeholder (full impl in Phase 3 task 3.3).
See spec 12 § 1.2 (Rust-first authoring) and spec 13 § 2 (obs::scope!).
Macros§
- context
obs::context!(name = value, ...)— likeobs::scope!but without the per-scope tail buffer. Spec 13 § 2.2.- emit
- Function-like emit macro:
obs::emit!(MyEvent { field: value })orobs::emit!(WARN, MyEvent { field: value })to escalate. - forensic
obs::forensic!(site = "...", message = "...", { "k" => v, ... })— emergency escape hatch. Always emits, regardless of sampling. Spec 13 § 8.- include_
schemas obs::include_schemas!("myapp.v1")— wire up every fileobs-buildemits into the user’s crate. Expands to fourinclude!calls underOUT_DIR/obs/. Spec 12 § 3.1.- scope
obs::scope!(name = value, ...)— push anobs::scope!frame onto the active task’s scope stack. Returns aScopeGuardthat pops the frame on drop and flushes the tail-on-error buffer when>= ERRORwas observed inside.
Attribute Macros§
- instrument
#[obs::instrument]— wraps a function body in anobs::scope!and emits oneObsFnExecutedevent on exit (default) or two (ObsFnEntered+ObsFnExecuted) whenenter = true.- test
#[obs::test]— drop-in replacement for#[test]/#[tokio::test]that installs anInMemoryObserveron the current thread (sync) or current task (async) for the duration of the test. The body’s emits land in a thread-local / task-local handle thatobs::test::assert_emitted!reads.
Derive Macros§
- Event
- Derive macro for the Rust-first authoring path.