如何在蝗虫中调用GRPC python客户端? [英] How to invoke a GRPC python client in locust?

查看:135
本文介绍了如何在蝗虫中调用GRPC python客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在蝗虫中调用GRPC python客户端.

Is there any way to invoke GRPC python client in locust.

当我运行代码locust -f 1.py时,将生成输出.但是统计数据不起作用.他们闲着.

The output is generated when I run the code locust -f 1.py. But the stats are not working. They are idle.

用户蜂拥而至,但所有数据的统计信息均处于闲置状态

users are swarming, but the stats are idle for everything

推荐答案

建立自己的客户时,您需要报告样本来刺槐自己(因为否则它将如何知道您的所作所为?)

When you build your own client you need to report samples to locust yourself (because how would it otherwise know what you had done?)

https://docs.locust.io/en/stable /testing-other-systems.html

要报告示例,您需要执行以下操作(如果从TaskSet调用它-如果您已经在User类中,请跳过.user部分):

To report a sample, you need to do something like this (if you're calling this from a TaskSet - if you are already in the User class, skip the .user part):

self.user.environment.events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)

在1.0之前的蝗虫中,您会做类似的事情:

In pre-1.0 locust you'd do something like:

from locust import events,
events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)

这篇关于如何在蝗虫中调用GRPC python客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆