-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ optimise log monitor with stracktrace #277
- Loading branch information
Showing
8 changed files
with
134 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule docs
updated
2 files
+7 −0 | src/3-slardar/3k-prop-function.md | |
+7 −0 | src/zh/3-slardar/3k-prop-function.md |
40 changes: 40 additions & 0 deletions
40
...slardar-webmvc/src/main/java/pro/fessional/wings/slardar/monitor/viewer/WebLogViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package pro.fessional.wings.slardar.monitor.viewer; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import pro.fessional.wings.silencer.spring.boot.ConditionalWingsEnabled; | ||
import pro.fessional.wings.slardar.spring.prop.SlardarMonitorProp; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author trydofor | ||
* @since 2021-07-20 | ||
*/ | ||
@Slf4j | ||
@RestController | ||
@ConditionalWingsEnabled(abs = LogConf.Key$enable) | ||
public class WebLogViewer extends LogViewer { | ||
|
||
@Autowired | ||
public WebLogViewer(SlardarMonitorProp prop) { | ||
super(prop.getView()); | ||
} | ||
|
||
@Operation(summary = "Alarm logs can be viewed in conjunction with alarm notifications when self-monitoring is enabled.", description = """ | ||
# Usage | ||
Pass the log id to view the log. | ||
## Params | ||
* @param id - log id, max 2k caches in 36H | ||
## Returns | ||
* @return {200 | string} log context or empty""") | ||
@GetMapping(value = "${" + LogConf.Key$mapping + "}") | ||
public void view(@RequestParam("id") String id, HttpServletResponse res) throws IOException { | ||
super.view(id, res.getOutputStream()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
wings/slardar/src/test/java/pro/fessional/wings/slardar/monitor/viewer/LogViewerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pro.fessional.wings.slardar.monitor.viewer; | ||
|
||
import io.qameta.allure.TmsLink; | ||
import lombok.Setter; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import pro.fessional.wings.slardar.spring.prop.SlardarMonitorProp; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* @author trydofor | ||
* @since 2024-07-23 | ||
*/ | ||
@SpringBootTest | ||
class LogViewerTest { | ||
|
||
@Setter(onMethod_ = { @Autowired }) | ||
protected SlardarMonitorProp slardarMonitorProp; | ||
|
||
@TmsLink("13128") | ||
@Test | ||
void canIgnoreHead() throws Exception { | ||
final LogViewer lv = new LogViewer(slardarMonitorProp.getView()); | ||
|
||
final Path tmp0 = Files.createTempFile("test-", null); | ||
tmp0.toFile().deleteOnExit(); | ||
Files.writeString(tmp0, """ | ||
2024-07-21 22:05:22.957 ERROR 10884 --- [kite-front] [XNIO-1 I/O-4] io.undertow.request : UT005071: Undertow request failed HttpServerExchange{ CONNECT api.ipify.org:443} | ||
java.lang.IllegalArgumentException: UT000068: Servlet path match failed | ||
at io.undertow.servlet.handlers.ServletPathMatchesData.getServletHandlerByPath(ServletPathMatchesData.java:83) ~[undertow-servlet-2.3.10.Final.jar!/:2.3.10.Final] | ||
""".stripIndent()); | ||
|
||
|
||
boolean b0 = lv.canIgnoreHead(tmp0.toAbsolutePath().toString()); | ||
Assertions.assertTrue(b0); | ||
|
||
final Path tmp1 = Files.createTempFile("test-", null); | ||
tmp1.toFile().deleteOnExit(); | ||
Files.writeString(tmp1, """ | ||
2024-07-21 22:05:22.957 ERROR 10884 --- [kite-front] [XNIO-1 I/O-4] io.undertow.request : UT005071: Undertow request failed HttpServerExchange{ CONNECT api.ipify.org:443} | ||
java.lang.IllegalArgumentException: UT000068: Servlet path match failed | ||
at io.undertow.servlet.handlers.ServletPathMatchesData.getServletHandlerByPath(ServletPathMatchesData.java:83) ~[undertow-servlet-2.3.10.Final.jar!/:2.3.10.Final] | ||
at io.undertow.servlet.handlers.ServletPathMatches.getServletHandlerByPath(ServletPathMatches.java:133) ~[undertow-servlet-2.3.10.Final.jar!/:2.3.10.Final] | ||
2024-07-23 01:33:05.446 ERROR 10884 --- [kite-front] [XNIO-1 task-4] p.f.w.w.e.DefaultExceptionResolver : unhandled exception, response default | ||
java.lang.NumberFormatException: For input string | ||
""".stripIndent()); | ||
|
||
|
||
boolean b1 = lv.canIgnoreHead(tmp1.toAbsolutePath().toString()); | ||
Assertions.assertFalse(b1); | ||
} | ||
} |