urlmapping.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. package dto
  2. import (
  3. "go-admin/app/observe/models"
  4. "go-admin/common/dto"
  5. common "go-admin/common/models"
  6. "strconv"
  7. "strings"
  8. )
  9. type UrlMappingListResp struct {
  10. Id int `json:"id"`
  11. AppId string `json:"app_id"`
  12. AppAlias string `json:"app_alias"`
  13. Name string `json:"name"`
  14. Method string `json:"method"`
  15. Url string `json:"url"`
  16. Level string `json:"level"`
  17. IsPerfectMatch string `json:"is_perfect_match"`
  18. Type string `json:"type"`
  19. Module string `json:"module"`
  20. Summary string `json:"summary"`
  21. ServiceName string `json:"service_name"`
  22. ServiceNameCN string `json:"service_name_cn"`
  23. Favor string `json:"favor"`
  24. UrlMappingBaseStats
  25. DurationStats DurationStats `json:"duration_stats"`
  26. }
  27. type DurationStats struct {
  28. Time []string `json:"time"`
  29. P50 []float64 `json:"p50"`
  30. P90 []float64 `json:"p90"`
  31. P99 []float64 `json:"p99"`
  32. // Max []float64 `json:"max"`
  33. // Min []float64 `json:"min"`
  34. // Avg []float64 `json:"avg"`
  35. }
  36. type DurationStat struct {
  37. Time string `json:"time"`
  38. Max float64 `json:"max"`
  39. Avg float64 `json:"avg"`
  40. P50 float64 `json:"p50"`
  41. P90 float64 `json:"p90"`
  42. P99 float64 `json:"p99"`
  43. // Min float64 `json:"min"`
  44. }
  45. type UrlMappingBaseStats struct {
  46. Kind string `json:"kind"`
  47. Total int64 `json:"total"`
  48. Rpm float64 `json:"rpm"`
  49. ErrorNum int64 `json:"error_num"`
  50. ErrorRate float64 `json:"error_rate"`
  51. Max float64 `json:"max"`
  52. Min float64 `json:"min"`
  53. Avg float64 `json:"avg"`
  54. P50 float64 `json:"p50"`
  55. P90 float64 `json:"p90"`
  56. P99 float64 `json:"p99"`
  57. }
  58. type UrlMappingDetailStats struct {
  59. Kind string `json:"kind"`
  60. StartMinute string `json:"start_minute"`
  61. Total int64 `json:"total"`
  62. ErrorNum int64 `json:"error_num"`
  63. Max float64 `json:"max"`
  64. Min float64 `json:"min"`
  65. Avg float64 `json:"avg"`
  66. P50 float64 `json:"p50"`
  67. P90 float64 `json:"p90"`
  68. P99 float64 `json:"p99"`
  69. }
  70. type UrlMappingGetPageReq struct {
  71. AppId string `form:"app_id"`
  72. Url string `form:"url"`
  73. ServiceName string `form:"service_name"`
  74. Level string `form:"level"`
  75. dto.Pagination `search:"-"`
  76. models.TimeRange
  77. // Favor string `form:"favor"`
  78. // UrlMappingOrder
  79. }
  80. type UrlMappingOrder struct {
  81. Id string `form:"idOrder" search:"type:order;column:id;table:ot_url_mapping"`
  82. AppId string `form:"appIdOrder" search:"type:order;column:app_id;table:ot_url_mapping"`
  83. Name string `form:"nameOrder" search:"type:order;column:name;table:ot_url_mapping"`
  84. Url string `form:"urlOrder" search:"type:order;column:url;table:ot_url_mapping"`
  85. Type string `form:"typeOrder" search:"type:order;column:type;table:ot_url_mapping"`
  86. Module string `form:"moduleOrder" search:"type:order;column:module;table:ot_url_mapping"`
  87. Summary string `form:"summaryOrder" search:"type:order;column:summary;table:ot_url_mapping"`
  88. Favor string `form:"favorOrder" search:"type:order;column:favor;table:ot_url_mapping"`
  89. CreatedAt string `form:"createdAtOrder" search:"type:order;column:created_at;table:ot_url_mapping"`
  90. UpdatedAt string `form:"updatedAtOrder" search:"type:order;column:updated_at;table:ot_url_mapping"`
  91. DeletedAt string `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:ot_url_mapping"`
  92. CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:ot_url_mapping"`
  93. UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:ot_url_mapping"`
  94. models.TimeRange
  95. }
  96. func (m *UrlMappingGetPageReq) GetNeedSearch() interface{} {
  97. return *m
  98. }
  99. type UrlMappingInsertReq struct {
  100. Id int `json:"-" comment:"主键id"` // 主键id
  101. AppId string `json:"app_id" comment:"应用id"`
  102. Name string `json:"name" comment:"url对应的名称"`
  103. Url string `json:"url" comment:"url"`
  104. Type string `json:"type" comment:"类型 0未知 1内部 2外部"`
  105. Module string `json:"module" comment:"所属模块"`
  106. Summary string `json:"summary" comment:"简要描述"`
  107. Favor string `json:"favor" comment:"收藏, 0未收藏 1已收藏"`
  108. common.ControlBy
  109. }
  110. func (s *UrlMappingInsertReq) Generate(model *models.UrlMapping) {
  111. if s.Id == 0 {
  112. model.ID = int64(s.Id)
  113. }
  114. appId, _ := strconv.Atoi(s.AppId)
  115. types, _ := strconv.Atoi(s.Type)
  116. favor, _ := strconv.Atoi(s.Favor)
  117. model.AppId = int64(appId)
  118. model.Name = s.Name
  119. model.Url = s.Url
  120. model.Type = int32(types)
  121. model.Module = s.Module
  122. model.Summary = s.Summary
  123. model.Favor = int32(favor)
  124. model.CreateBy = int64(s.CreateBy) // 添加这而,需要记录是被谁创建的
  125. }
  126. func (s *UrlMappingInsertReq) GetId() interface{} {
  127. return s.Id
  128. }
  129. type UrlMappingUpdateReq struct {
  130. Id int `uri:"id" comment:"主键id"` // 主键id
  131. AppId string `json:"app_id" comment:"应用id"`
  132. Name string `json:"name" comment:"url对应的名称"`
  133. Url string `json:"url" comment:"url"`
  134. Type string `json:"type" comment:"类型 0未知 1内部 2外部"`
  135. Module string `json:"module" comment:"所属模块"`
  136. Summary string `json:"summary" comment:"简要描述"`
  137. Favor string `json:"favor" comment:"收藏, 0未收藏 1已收藏"`
  138. common.ControlBy
  139. }
  140. func (s *UrlMappingUpdateReq) Generate(model *models.UrlMapping) {
  141. if s.Id == 0 {
  142. model.ID = int64(s.Id)
  143. }
  144. appId, _ := strconv.Atoi(s.AppId)
  145. types, _ := strconv.Atoi(s.Type)
  146. favor, _ := strconv.Atoi(s.Favor)
  147. model.AppId = int64(appId)
  148. model.Name = s.Name
  149. // model.Url = s.Url // url不可修改
  150. model.Type = int32(types)
  151. model.Module = s.Module
  152. model.Summary = s.Summary
  153. model.Favor = int32(favor)
  154. model.CreateBy = int64(s.CreateBy)
  155. }
  156. func (s *UrlMappingUpdateReq) GetId() interface{} {
  157. return s.Id
  158. }
  159. // OtUrlMappingGetReq 功能获取请求参数
  160. type UrlMappingGetReq struct {
  161. Id int `uri:"id"`
  162. }
  163. func (s *UrlMappingGetReq) GetId() interface{} {
  164. return s.Id
  165. }
  166. // UrlMappingGetDetailReq 获取业务映射详情列表参数
  167. type UrlMappingGetDetailReq struct {
  168. dto.Pagination `search:"-"`
  169. models.TimeRange
  170. // Id int `form:"id"`
  171. AppId int `form:"app_id"`
  172. Kind string `form:"kind"` // 字段已废弃, 使用Route代替
  173. Route string `form:"route"`
  174. Method string `form:"method"`
  175. ServiceName string `form:"service_name"`
  176. OnlyError string `form:"only_error"` // 为保持与其它地方一致,此处废弃
  177. OnlyException bool `form:"only_exception"`
  178. models.DurationRange
  179. models.SortInfo
  180. }
  181. type UrlMappingGetDetailResp struct {
  182. Datetime string `json:"datetime"`
  183. Timestamp int64 `json:"timestamp"` // 时间
  184. Route string `json:"route"` // 匹配到的具体的uri
  185. Target string `json:"target"` // 匹配到的具体的uri,包括后面的参数
  186. URL string `json:"url"` // 匹配到的完整的URL
  187. Flavor string `json:"flavor"` // http协议, 如1.1
  188. Host string `json:"host"` // http host
  189. Method string `json:"method"` // http方法,如GET、POST
  190. StatusCode int64 `json:"status_code"` // http 状态码
  191. Message string `json:"message"` // 信息,通常为错误信息
  192. TraceID string `json:"trace_id"` // TraceId
  193. SpanID string `json:"span_id"` // SpanId
  194. ServiceName string `json:"service_name"` // 服务名
  195. Duration int64 `json:"duration"` // 耗时
  196. // SpanDetail *models.Trace `json:"span_detail"`
  197. }
  198. // OtUrlMappingDeleteReq 功能删除请求参数
  199. type UrlMappingDeleteReq struct {
  200. Ids string `uri:"ids"`
  201. }
  202. type UrlMappingGetResp struct {
  203. AppId string `json:"app_id" comment:"应用id"`
  204. Name string `json:"name" comment:"url对应的名称"`
  205. Url string `json:"url" comment:"url"`
  206. Type string `json:"type" comment:"类型 0未知 1内部 2外部"`
  207. Module string `json:"module" comment:"所属模块"`
  208. Summary string `json:"summary" comment:"简要描述"`
  209. Favor string `json:"favor" comment:"收藏, 0未收藏 1已收藏"`
  210. }
  211. func (s *UrlMappingDeleteReq) GetIds() []string {
  212. ids := strings.Split(s.Ids, ",")
  213. return ids
  214. }
  215. type UrlMappingFavorReq struct {
  216. Id int `uri:"id"`
  217. Favor string `json:"favor"`
  218. }
  219. type UrlMappingSankeyReq struct {
  220. AppId string `form:"app_id"`
  221. models.AppPercentileRange
  222. models.TimeRange
  223. }
  224. type UrlMappingSankeyResp struct {
  225. Nodes []SankeyNode `json:"nodes"`
  226. Links []SankeyLink `json:"links"`
  227. }
  228. type SankeyNode struct {
  229. Name string `json:"name"`
  230. }
  231. type SankeyLink struct {
  232. Source string `json:"source"`
  233. Target string `json:"target"`
  234. Value int `json:"value"`
  235. }
  236. type UrlMappingGetFavorsReq struct {
  237. AppId string `form:"app_id"`
  238. models.TimeRange
  239. }
  240. type UrlMappingQualityReq struct {
  241. AppId string `form:"app_id"`
  242. UrlType string `form:"url_type"` // 类型 0未知 1内部 2外部
  243. models.TimeRange
  244. }
  245. type UrlMappingQualityResp struct {
  246. Buckets []string `json:"buckets"`
  247. Current CountsQuantileIndexes `json:"current"`
  248. Previous CountsQuantileIndexes `json:"previous"`
  249. }
  250. type CountsQuantileIndexes struct {
  251. Counts []float64 `json:"counts"`
  252. QuantileIndexes map[string]int `json:"quantile_indexes"`
  253. }
  254. type UrlMappingErrorsReq struct {
  255. AppId string `form:"app_id"`
  256. UrlType string `form:"url_type"` // 类型 0未知 1内部 2外部
  257. TimeType string `form:"time_type"` // minute hour day
  258. TimeValue int `form:"time_value"` // 数字,与time type相关联
  259. TimeBase int `form:"time_base"` // 时间基础,时间戳,以该时间为基础,统计TimeValue+TimeType时间段
  260. }
  261. type UrlMappingErrorsResp struct {
  262. Times []string `json:"times"`
  263. Totals []int64 `json:"totals"`
  264. }
  265. type UrlMappingSlowTopReq struct {
  266. AppId string `form:"app_id"`
  267. models.TimeRange
  268. Limit uint8 `form:"limit"`
  269. }
  270. type UrlMappingSlowTopResp struct {
  271. AppAlias string `json:"-"`
  272. Name string `json:"name"`
  273. Route string `json:"route"`
  274. Method string `json:"method"`
  275. ServiceName string `json:"service_name"`
  276. ServiceNameCN string `json:"service_name_cn"`
  277. ErrorRate float64 `json:"error_rate"`
  278. Duration float64 `json:"duration"`
  279. DurationStats DurationStats `json:"duration_stats"`
  280. }
  281. type UrlMappingSubDigitsReq struct {
  282. ID int64 `form:"id"`
  283. AppAlias string `form:"app_alias"`
  284. models.TimeRange
  285. }
  286. type UrlMappingSubDigitsResp struct {
  287. Total int64 `json:"total"`
  288. ErrorRate float64 `json:"error_rate"`
  289. QPM float64 `json:"qpm"`
  290. MedianDuration float64 `json:"median_duration"`
  291. MaxDuration float64 `json:"max_duration"`
  292. }
  293. type UrlMappingSubListReq struct {
  294. // ID int64 `form:"id"`
  295. AppAlias string `form:"app_alias"`
  296. ServiceName string `form:"service_name"`
  297. Url string `form:"url"`
  298. BizHash string `form:"biz_hash"`
  299. models.TimeRange
  300. dto.Pagination `search:"-"`
  301. }
  302. type UrlMappingSubListResp struct {
  303. ID int64 `json:"id"`
  304. Name string `json:"name"`
  305. Route string `json:"route"`
  306. Method string `json:"method"`
  307. ServiceName string `json:"service_name"`
  308. ServiceNameCN string `json:"service_name_cn"`
  309. Favor int `json:"favor"`
  310. Module string `json:"module"`
  311. Summary string `json:"summary"`
  312. AppAlias string `json:"app_alias"`
  313. Total int64 `json:"total"`
  314. ErrorRate float64 `json:"error_rate"`
  315. DurationStats DurationStats `json:"duration_stats"`
  316. }
  317. type UrlMappingChartReq struct {
  318. models.TimeRange
  319. AppAlias string `form:"app_alias"`
  320. ServiceName string `form:"service_name"`
  321. Method string `form:"method"`
  322. Route string `form:"route"`
  323. Type string `form:"type"` // request_trend 请求量; latency 时延; status_trend 状态请求量
  324. }
  325. type UrlMappingChartResp struct {
  326. Times []string `json:"times"`
  327. Values map[string][]float64 `json:"values"`
  328. }
  329. type UrlMappingBaseInfoReq struct {
  330. AppAlias string `form:"app_alias"`
  331. ServiceName string `form:"service_name"`
  332. Url string `form:"url"`
  333. Method string `form:"method"`
  334. }
  335. type UrlMappingBaseInfoResp struct {
  336. ID int64 `json:"id"`
  337. Route string `json:"route"`
  338. Method string `json:"method"`
  339. AppAlias string `json:"app_alias"`
  340. AppName string `json:"app_name"`
  341. ServiceName string `json:"service_name"`
  342. ServiceNameCn string `json:"service_name_cn"`
  343. // BizID int64 `json:"biz_id"`
  344. // BizNodeID int64 `json:"biz_node_id"`
  345. }
  346. type UrlMappingMatchReq struct {
  347. AppAlias string `form:"app_alias"`
  348. ServiceName string `form:"service_name"`
  349. Url string `form:"url"`
  350. Method string `form:"method"`
  351. dto.Pagination
  352. }
  353. type UrlMappingMatchResp struct {
  354. AppAlias string `form:"app_alias"`
  355. ServiceName string `form:"service_name"`
  356. Route string `form:"route"`
  357. Method string `form:"method"`
  358. }