Skip to main content

WasmStdoutMetricsAdapter

Struct WasmStdoutMetricsAdapter 

Source
pub struct WasmStdoutMetricsAdapter { /* private fields */ }
Expand description

Basic WASM stdout adapter for metrics (correlation-focused)

Implementations§

Source§

impl WasmStdoutMetricsAdapter

Source

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}
Source

pub fn disabled() -> Self

Trait Implementations§

Source§

impl Default for WasmStdoutMetricsAdapter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MetricsPort for WasmStdoutMetricsAdapter

Source§

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<()>

Emit a simple histogram/timing metric
Source§

fn emit_gauge_simple(&self, name: &str, value: f64) -> ObservabilityResult<()>

Emit a simple gauge metric
Source§

fn is_enabled(&self) -> bool

Check if metrics collection is enabled
Source§

fn emit_metrics_batch( &self, entries: &[MetricsEntry], ) -> ObservabilityResult<()>

Batch emit multiple metrics (optional, has default implementation)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more