pub struct WasmStdoutMetricsAdapter { /* private fields */ }Expand description
Basic WASM stdout adapter for metrics (correlation-focused)
Implementations§
Source§impl WasmStdoutMetricsAdapter
impl WasmStdoutMetricsAdapter
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/basic_metrics_demo.rs (line 11)
7fn main() -> ObservabilityResult<()> {
8 println!("🎯 Basic MetricsPort Demo");
9
10 // Create simple metrics adapter
11 let metrics_adapter = WasmStdoutMetricsAdapter::new();
12
13 println!("\n📊 Testing simple metrics emission:");
14
15 // Test counter
16 metrics_adapter.emit_counter_simple("requests_total", 1.0)?;
17
18 // Test histogram
19 metrics_adapter.emit_histogram_simple("request_duration_ms", 150.0)?;
20
21 // Test gauge
22 metrics_adapter.emit_gauge_simple("active_connections", 5.0)?;
23
24 println!("\n🔄 Testing unified adapter (logs + metrics correlation):");
25
26 // Create unified adapter for correlation
27 let unified_adapter = UnifiedWasmStdoutAdapter::new();
28
29 // Test correlated metrics
30 unified_adapter.emit_counter_simple("llm_requests", 1.0)?;
31 unified_adapter.emit_histogram_simple("llm_response_time_ms", 2500.0)?;
32
33 println!("\n📈 Testing MetricsEntry with trace context:");
34
35 // Create metrics with trace context for correlation
36 let trace_context = TraceContext {
37 trace_id: "trace-123456".to_string(),
38 span_id: "span-789".to_string(),
39 parent_span_id: Some("parent-456".to_string()),
40 };
41
42 let counter_metric = create_counter_metric("a2a_messages_sent", 3.0)
43 .with_trace_context(trace_context.clone())
44 .with_source(
45 Some("a2a_jsonrpc_core".to_string()),
46 Some("message_handler".to_string()),
47 Some("send_request".to_string()),
48 );
49
50 println!("Metric with context: {}", counter_metric.to_json());
51
52 let histogram_metric = create_histogram_metric("template_render_duration_us", 1250.0)
53 .with_trace_context(trace_context)
54 .with_source(
55 Some("template_engines".to_string()),
56 Some("sailfish_renderer".to_string()),
57 Some("render_template".to_string()),
58 );
59
60 println!("Metric with context: {}", histogram_metric.to_json());
61
62 println!("\n✅ Basic metrics demo completed!");
63
64 Ok(())
65}pub fn disabled() -> Self
Trait Implementations§
Source§impl Default for WasmStdoutMetricsAdapter
impl Default for WasmStdoutMetricsAdapter
Source§impl MetricsPort for WasmStdoutMetricsAdapter
impl MetricsPort for WasmStdoutMetricsAdapter
Source§fn emit_counter_simple(&self, name: &str, value: f64) -> ObservabilityResult<()>
fn emit_counter_simple(&self, name: &str, value: f64) -> ObservabilityResult<()>
Emit a simple counter metric
Source§fn emit_histogram_simple(
&self,
name: &str,
value: f64,
) -> ObservabilityResult<()>
fn emit_histogram_simple( &self, name: &str, value: f64, ) -> ObservabilityResult<()>
Emit a simple histogram/timing metric
Source§fn emit_gauge_simple(&self, name: &str, value: f64) -> ObservabilityResult<()>
fn emit_gauge_simple(&self, name: &str, value: f64) -> ObservabilityResult<()>
Emit a simple gauge metric
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Check if metrics collection is enabled
Source§fn emit_metrics_batch(
&self,
entries: &[MetricsEntry],
) -> ObservabilityResult<()>
fn emit_metrics_batch( &self, entries: &[MetricsEntry], ) -> ObservabilityResult<()>
Batch emit multiple metrics (optional, has default implementation)
Auto Trait Implementations§
impl Freeze for WasmStdoutMetricsAdapter
impl RefUnwindSafe for WasmStdoutMetricsAdapter
impl Send for WasmStdoutMetricsAdapter
impl Sync for WasmStdoutMetricsAdapter
impl Unpin for WasmStdoutMetricsAdapter
impl UnsafeUnpin for WasmStdoutMetricsAdapter
impl UnwindSafe for WasmStdoutMetricsAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more