1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// macros.rs
// Copyright © 2024-2026 RustLogs (RLG). All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
//! Convenience macros for span tracking, latency profiling, and MCP notifications.
//!
//! All macros dispatch through the lock-free [`ENGINE`](crate::engine::ENGINE).
/// Execute a block within an OTLP-tagged span.
///
/// Emits an OTLP log with a generated `span_id`, increments the active
/// span counter, runs `$block`, then decrements. Returns the block's value.
/// Measure wall-clock latency of a block and emit a Logfmt metric.
///
/// Captures `Instant::now()` before the block, computes elapsed
/// microseconds after, and fires a Logfmt log with `latency_us`.
/// Emit an MCP-formatted state transition notification.
///
/// Use for AI agent orchestration where state changes must be
/// machine-readable via JSON-RPC 2.0 notification semantics.