12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package apis
- import (
- "go-admin/app/observe/service"
- "go-admin/app/observe/service/dto"
- "go-admin/utils"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- type Trace struct {
- utils.OtApi
- }
- // List Traces列表
- func (t Trace) List(c *gin.Context) {
- req := new(dto.TraceListReq)
- svc := new(service.Trace)
- if err := t.Init(c, req, &svc.OtService); err != nil {
- return
- }
- result := make([]dto.TraceListResp, 0)
- var count int64
- if err := svc.GetPage(c, req, &result, &count); err != nil {
- t.Error(http.StatusInternalServerError, err, err.Error())
- return
- }
- t.PageOK(result, int(count), req.PageIndex, req.PageSize, "success")
- }
- // Detail Trace详情,即span列表,用于树型图展示
- func (t Trace) Detail(c *gin.Context) {
- req := new(dto.TraceDetailReq)
- svc := new(service.Trace)
- if err := t.Init(c, req, &svc.OtService); err != nil {
- return
- }
- result := new(dto.TraceDetailResp)
- if err := svc.GetSpans(c, req, result); err != nil {
- t.Error(http.StatusInternalServerError, err, err.Error())
- return
- }
- t.OK(result, "ok")
- }
- func (t Trace) Graph(c *gin.Context) {
- param := new(dto.TraceGraphReq)
- svc := new(service.Trace)
- err := t.MakeContext(c).MakeDB().Bind(param).MakeService(&svc.OtService).Errors
- if err != nil {
- t.Error(http.StatusInternalServerError, err, err.Error())
- return
- }
- result := new(dto.TraceGraphResp)
- if err := svc.GetTraceGraph(c, param, result); err != nil {
- t.Error(http.StatusInternalServerError, err, err.Error())
- return
- }
- t.OK(result, "ok")
- }
- func (t Trace) DBSlowTop(c *gin.Context) {
- req := new(dto.TraceDBSlowTopReq)
- svc := new(service.Trace)
- if err := t.Init(c, req, &svc.OtService); err != nil {
- return
- }
- resp := make([]dto.TraceDBSlowTopResp, 0)
- if err := svc.DBSlowTop(req, &resp); err != nil {
- t.Error(http.StatusInternalServerError, err, err.Error())
- return
- }
- t.OK(resp, "success")
- }
|