你可以的,加油

向apm-server 请求时,返回EOF while reading metadata 是怎么回事?

Beats | 作者 wajika | 发布于2022年08月25日 | 阅读数:1104


from locust import HttpLocust, TaskSet, task, HttpUser, run_single_user
class QuickstartUser(HttpUser):
host = "http://192.168.10.182:8200"
@task()
def user_sign(self):
payload = "{\"metadata\": {\"service\": {\"name\": \"pa-os\",\"version\": \"0.0.1\",\"agent\": {\"name\": \"rum-js\",\"version\": \"5.1.1\"},\"language\": {\"name\": \"javascript\"}}} } {\"transaction\": {\"id\": \"4bfa932d89b48c4c\",\"trace_id\": \"a5273ad0008b9d0e39c373c777c6a3cc\",\"name\": \"pa-oswebsiteadmin/homePicture/getPictures\",\"type\": \"custom\",\"duration\": 298.7999999523163,\"context\": {\"page\": {\"referer\": \"https://pa-dev.xxx.cn/officialSite\",\"url\": \"https://pa-dev.xxx.cn/officialSite\"},\"custom\": {\"name\": \"\",\"userName\": \"\",\"pageName\": \"官网首页管理\",\"method\": \"get\",\"api\": \"getPictures\",\"responseStatus\": 200}},\"span_count\": {\"started\": 1},\"sampled\": true} } {\"span\": {\"id\": \"285b37e5a361c1d0\",\"transaction_id\": \"4bfa932d89b48c4c\",\"parent_id\": \"4bfa932d89b48c4c\",\"trace_id\": \"a5273ad0008b9d0e39c373c777c6a3cc\",\"name\": \"get/websiteadmin/homePicture/getPictures\",\"type\": \"external\",\"start\": 0.09999990463256836,\"duration\": 298.7000000476837}"
headers = {"Content-Type": "application/x-ndjson"}
with self.client.post("/intake/v2/rum/events",headers=headers , data=payload.encode('utf-8'), catch_response=True) as resp:
pass


if __name__ == "__main__":
run_single_user(QuickstartUser)
代码很简单,locust 发出一个请求,但是拿到的response是http400,消息“
EOF while reading metadata”,

b'{\n  "accepted": 0,\n  "errors": [\n    {\n      "message": "EOF while reading metadata",\n      "document": "{\\"metadata\\": {\\"service\\": {\\"name\\": \\"pa-os\\",\\"version\\": \\"0.0.1\\",\\"agent\\": {\\"name\\": \\"rum-js\\",\\"version\\": \\"5.1.1\\"},\\"language\\": {\\"name\\": \\"javascript\\"}}} } {\\"transaction\\": {\\"id\\": \\"4bfa932d89b48c4c\\",\\"trace_id\\": \\"a5273ad0008b9d0e39c373c777c6a3cc\\",\\"name\\": \\"pa-oswebsiteadmin/homePicture/getPictures\\",\\"type\\": \\"custom\\",\\"duration\\": 298.7999999523163,\\"context\\": {\\"page\\": {\\"referer\\": \\"https://pa-dev.xxx.cn/officialSite\\",\\"url\\": \\"https://pa-dev.xxx.cn/officialSite\\"},\\"custom\\": {\\"name\\": \\"\\",\\"userName\\": \\"\\",\\"pageName\\": \\"\xe5\xae\x98\xe7\xbd\x91\xe9\xa6\x96\xe9\xa1\xb5\xe7\xae\xa1\xe7\x90\x86\\",\\"method\\": \\"get\\",\\"api\\": \\"getPictures\\",\\"responseStatus\\": 200}},\\"span_count\\": {\\"started\\": 1},\\"sampled\\": true} } {\\"span\\": {\\"id\\": \\"285b37e5a361c1d0\\",\\"transaction_id\\": \\"4bfa932d89b48c4c\\",\\"parent_id\\": \\"4bfa932d89b48c4c\\",\\"trace_id\\": \\"a5273ad0008b9d0e39c373c777c6a3cc\\",\\"name\\": \\"get/websiteadmin/homePicture/getPictures\\",\\"type\\": \\"external\\",\\"start\\": 0.09999990463256836,\\"duration\\": 298.7000000476837}"\n    }\n  ]\n}\n'
已邀请:

要回复问题请先登录注册