Closed holmes1412 closed 2 years ago
Basic Usage:
RPCMetricsPull filter; class ExampleServiceImpl : public Example::Service { public: void Echo(EchoRequest *req, EchoResponse *resp, RPCContext *ctx) override { filter.histogram("echo_request_size")->observe(req->ByteSizeLong()); } }; int main() { // ... filter.init(8080); /* export port for prometheus */ filter.create_histogram("echo_request_size", "Echo request size", {1, 10, 100}); server.add_filter(&filter); // ... filter.deinit(); return 0; }
Screen Output:
[@gdylj_35_53 tutorial]# ./srpc_pb_client message: "Hi back" message: "Hi back" ^C [@gdylj_35_53 srpc_1412_metrics]# curl localhost:8080/metrics # HELP total_request_count total request count # TYPE total_request_count gauge total_request_count 2.000000 # HELP total_request_method request method statistics # TYPE total_request_method counter total_request_method{method="Echo",service="Example"} 2.000000 # HELP total_request_latency request latency nano seconds # TYPE total_request_latency summary total_request_latency{quantile="0.500000"} 645078.500000 total_request_latency{quantile="0.900000"} 645078.500000 total_request_latency_sum 1290157.000000 total_request_latency_count 2 # HELP echo_request_size Echo request size # TYPE echo_request_size histogram echo_request_size_bucket{le="1.000000"}0 echo_request_size_bucket{le="10.000000"}0 echo_request_size_bucket{le="100.000000"}2 echo_request_size_bucket{le="+Inf"} 2 echo_request_size_sum 40.000000 echo_request_size_count 2
Basic Usage:
Screen Output: