proxy-wasm-rust-sdk icon indicating copy to clipboard operation
proxy-wasm-rust-sdk copied to clipboard

How to test prometheus ABI

Open shit-hub opened this issue 5 years ago • 0 comments

  • hello @PiotrSikora , when I use metric's interface to test prometheus function, I found that the return value of get_metric() is alway 0. And prometheus can not receive the metric counter data normally. The code is shown below.

lazy_static! { static ref SCP_REQ_METRIC_ID: Mutex = Mutex::new(define_metric(MetricType::Counter, "http_request").unwrap()); } pub fn get_metric_id() -> u32 { let scp_req_metric_id = SCP_REQ_METRIC_ID.lock().unwrap(); *scp_req_metric_id }

impl HttpContext for Limiter { fn on_http_request_headers(&mut self, _: usize) -> Action { info!("=====on_http_request_headers====="); increment_metric(get_metric_id(), 1).unwrap(); info!("---new metric_id={:?}", get_metric_id()); let get_return_value = get_metric(get_metric_id()).unwrap(); info!("---get_return_value={:?}", get_return_value); ...... ......

  • Out put information:
    wasm log rate-limit.default rate_limit_handle: =====on_http_request_headers=====
    wasm log rate-limit.default rate_limit_handle: ---new metric_id=4
    wasm log rate-limit.default rate_limit_handle: ---get metric ok, return_value=0
    wasm log rate-limit.default rate_limit_handle: ---get_return_value=0

Originally posted by @czh-123-rust in https://github.com/proxy-wasm/proxy-wasm-rust-sdk/issues/4#issuecomment-676055879

shit-hub avatar Aug 24 '20 00:08 shit-hub