From 60e69be133aeb2409acd03baa0a85ccac1e5e784 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sat, 27 Jul 2024 22:39:44 +0800 Subject: [PATCH 1/6] [doc] : add committer introduction doc --- home/blog/2024-07-27-new-committer.md | 36 ++++++++++++++++++ .../2024-07-27-new-committer.md | 37 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 home/blog/2024-07-27-new-committer.md create mode 100644 home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md diff --git a/home/blog/2024-07-27-new-committer.md b/home/blog/2024-07-27-new-committer.md new file mode 100644 index 00000000000..26bfc69bba6 --- /dev/null +++ b/home/blog/2024-07-27-new-committer.md @@ -0,0 +1,36 @@ +--- +title: Welcome to HertzBeat Community Committer! +author: linDong +author_title: linDong +author_url: https://github.com/Yanshuming1 +author_image_url: https://avatars.githubusercontent.com/u/30208283?v=4 +tags: [opensource, practice] +keywords: [open source monitoring system, alerting system] +--- + +![hertzBeathertzBeat](/img/blog/new-committer.png) + +> It's an honor for me to become a Committer of Apache Hertzbeat +## Personal introduction + +I graduated in 2023 and am currently working as a Java developer in an Internet company. + +## First met Apache Hertzbeat + +After graduation and working for half a year, I had the idea of getting involved in open source. However, when searching for open source projects on GitHub, I found that many communities were not very active, and the official documentation was not complete, making it quite difficult to start with the projects. Therefore, I put the matter of open source on hold for the time being. + +One day, I saw a post by Senior Xiaobao on a certain platform and was immediately intrigued. I then privately messaged Xiaobao to consult about open source matters. Senior Xiaobao was extremely enthusiastic and meticulous in explaining many aspects of open source to me and recommended the Hertzbeat project. + +## My first PR + +I downloaded the source code of Hertzbeat and compiled and tested it according to the documentation. Then, when clicking on the functions on the page, I discovered a bug in the front-end pop-up window. So, I submitted my first issue and successfully claimed this issue, thus starting my first PR. + +## Keep active in community + +After submitting the first PR, I continuously followed the issues in the Hertzbeat community and attempted to solve the existing problems. I have successively completed tasks such as specifying @people on WeChat, integrating AI, adding a PrestoDB monitor, modifying bugs, and contributing to the official website documentation. + +## Reward +After several months of contributing to open source, I have reaped a lot. I have learned the business logic in the code, code norms, some technical frameworks that I have never used before, and some algorithms. It can be said that I have benefited greatly. + +## Conclusion +Becoming a Committer of Apache Hertzbeat is a very meaningful thing for me. In the future, I will continue to contribute to the Apache Hertzbeat community. I also hope that Apache Hertzbeat can successfully graduate from the incubator and that the community will become better and better. \ No newline at end of file diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md new file mode 100644 index 00000000000..463a89d1a35 --- /dev/null +++ b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md @@ -0,0 +1,37 @@ +--- +title: 热烈欢迎 HertzBeat 小伙伴新晋社区 Committer! +author: linDong +author_title: linDong +author_url: https://github.com/Yanshuming1 +author_image_url: https://avatars.githubusercontent.com/u/131688897?v=4 +tags: [opensource, practice] +keywords: [open source monitoring system, alerting system] +--- + +![hertzBeat](/img/blog/new-committer.png) + +> 非常荣幸能成为Apache Hertzbeat的Committer +## 个人介绍 + +本人是2023年毕业,目前在一家互联网公司担任java开发工程师。 + +## 初识 Apache Hertzbeat +毕业之后,工作了半年,萌生出接触开源的想法。然而,在 GitHub 上搜索开源项目时,发现诸多社区活跃度欠佳,官方文档也不完善,致使项目上手难度颇大,因此开源之事暂且搁置。 +某天,在某平台看到小宝大佬的一个帖子,我瞬间兴趣盎然,随即私聊小宝,咨询开源相关事宜。小宝大佬极其热情且细致地为我讲解了不少开源方面的情况,并向我推荐了 Hertzbeat 这个项目。 + +## 第一个PR + +我down了 Hertzbeat 的源码,并按照文档进行编译和测试,然后在页面点击功能的时候发现了一个前端弹窗的bug,所以我提交了自己的第一个issue,并且我成功认领了此issue +于是开启了我的第一个PR。 + +## 持续贡献 + +在提交第一个 PR 之后,我持续关注 Hertzbeat 社区的 issue ,且尝试去解决当中存在的问题。相继完成了微信指定艾特人、接入 AI 、添加 PrestoDB 监控器、Bug 修改以及官网文档贡献等工作。 + +## 收获 + +经过几个月对开源的贡献,我收获满满,学习到了代码中的业务逻辑、代码规范,一些此前未曾使用过的技术框架,还有一些算法,可谓是获益良多。 + +## 结语 + +成为Apache Hertzbeat的Committer于我而言是很有意义对事情,今后我也会持续对Apache Hertzbeat社区贡献下去,也希望Apache Hertzbeat能顺利从孵化器毕业,希望社区越来越好。 \ No newline at end of file From 9b626b9326514c4ce460b6229fd8a0eba59a48b3 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sun, 28 Jul 2024 14:20:09 +0800 Subject: [PATCH 2/6] [doc] : add committer introduction doc --- .../{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} | 0 .../{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename home/blog/{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} (100%) rename home/i18n/zh-cn/docusaurus-plugin-content-blog/{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} (100%) diff --git a/home/blog/2024-07-27-new-committer.md b/home/blog/2024-07-28-new-committer.md similarity index 100% rename from home/blog/2024-07-27-new-committer.md rename to home/blog/2024-07-28-new-committer.md diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-28-new-committer.md similarity index 100% rename from home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md rename to home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-28-new-committer.md From 4054c4f751768a03c2eeb97da567726a5b765e04 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Tue, 8 Oct 2024 16:33:23 +0800 Subject: [PATCH 3/6] [improve]:Improve the way Ai is entered and requested --- .../manager/controller/AiController.java | 13 ++++---- .../pojo/dto/AiControllerRequestParam.java | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/AiControllerRequestParam.java diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java index 718d9c09410..fbff6a6eeb4 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java @@ -22,15 +22,13 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.hertzbeat.manager.config.AiProperties; +import org.apache.hertzbeat.manager.pojo.dto.AiControllerRequestParam; import org.apache.hertzbeat.manager.service.ai.AiService; import org.apache.hertzbeat.manager.service.ai.factory.AiServiceFactoryImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.codec.ServerSentEvent; import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Flux; /** @@ -55,12 +53,13 @@ public class AiController { * @param text request text * @return AI response */ - @GetMapping(path = "/get", produces = {TEXT_EVENT_STREAM_VALUE}) + @PostMapping(path = "/get", produces = {TEXT_EVENT_STREAM_VALUE}) @Operation(summary = "Artificial intelligence questions and Answers", description = "Artificial intelligence questions and Answers") - public Flux> requestAi(@Parameter(description = "Request text", example = "Who are you") @RequestParam("text") String text) { + public Flux> requestAi(@Parameter(description = "Request text", example = "Who are you") + @RequestBody AiControllerRequestParam requestParam) { Assert.notNull(aiServiceFactory, "please check that your type value is consistent with the documentation on the website"); AiService aiServiceImplBean = aiServiceFactory.getAiServiceImplBean(aiProperties.getType()); - return aiServiceImplBean.requestAi(text); + return aiServiceImplBean.requestAi(requestParam.getText()); } } diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/AiControllerRequestParam.java b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/AiControllerRequestParam.java new file mode 100644 index 00000000000..5a94031c537 --- /dev/null +++ b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/AiControllerRequestParam.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hertzbeat.manager.pojo.dto; + +import lombok.Data; + +/** + * AiControllerRequestParam + */ +@Data +public class AiControllerRequestParam { + + /** + * required parameter + */ + String text; +} \ No newline at end of file From 5a6f1c7c8ae83a8a0181cf7bc0bd6f740648838e Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Tue, 8 Oct 2024 16:35:22 +0800 Subject: [PATCH 4/6] [improve]:Improve the way Ai is entered and requested --- .../apache/hertzbeat/manager/controller/AiController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java index fbff6a6eeb4..601c359c25e 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java @@ -28,7 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.codec.ServerSentEvent; import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; /** From 28ca6e6fc4ccab45e18a0c02d9a1d60750eacd93 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Tue, 8 Oct 2024 17:06:56 +0800 Subject: [PATCH 5/6] [improve]:Improve the way Ai is entered and requested --- .../org/apache/hertzbeat/manager/controller/AiController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java index 601c359c25e..fb1a192b05b 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/controller/AiController.java @@ -53,7 +53,7 @@ public class AiController { /** * request AI - * @param text request text + * @param requestParam request text * @return AI response */ @PostMapping(path = "/get", produces = {TEXT_EVENT_STREAM_VALUE}) From c36da7fd9148d0686fbb78de7cf95e752fad9a53 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sat, 12 Oct 2024 17:20:33 +0800 Subject: [PATCH 6/6] [improve]:Improve the way Ai is entered and requested --- .../manager/controller/AiControllerTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/controller/AiControllerTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/controller/AiControllerTest.java index 1ff970887a7..e615953246d 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/controller/AiControllerTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/controller/AiControllerTest.java @@ -19,7 +19,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.apache.hertzbeat.manager.config.AiProperties; @@ -34,6 +33,7 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.ServerSentEvent; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import reactor.core.publisher.Flux; @@ -74,9 +74,12 @@ public void testRequestAi() throws Exception { when(aiService.requestAi(anyString())).thenReturn(responseFlux); when(aiProperties.getType()).thenReturn("alibabaAi"); - mockMvc.perform(get("/api/ai/get") - .param("text", "Who are you") - .accept(MediaType.TEXT_EVENT_STREAM)) + String requestBody = "{\"text\":\"Who are you\"}"; + + mockMvc.perform((MockMvcRequestBuilders.post("/api/ai/get") + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.TEXT_EVENT_STREAM))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.TEXT_EVENT_STREAM_VALUE)) .andExpect(content().string("data:response\n\n"));