(st *httpStatInfo)
| 81 | } |
| 82 | |
| 83 | func (mux *TarsHttpMux) reportHttpStat(st *httpStatInfo) { |
| 84 | if mux.cfg == nil || StatReport == nil { |
| 85 | return |
| 86 | } |
| 87 | cfg := mux.cfg |
| 88 | var statInfo = statf.StatMicMsgHead{} |
| 89 | statInfo.MasterName = "http_client" |
| 90 | statInfo.MasterIp = st.reqAddr |
| 91 | |
| 92 | statInfo.TarsVersion = cfg.Version |
| 93 | statInfo.SlaveName = cfg.AppName |
| 94 | statInfo.SlaveIp = cfg.IP // from server |
| 95 | statInfo.SlavePort = cfg.Port |
| 96 | statInfo.InterfaceName = st.pattern |
| 97 | if cfg.SetId != "" { |
| 98 | setList := strings.Split(cfg.SetId, ".") |
| 99 | statInfo.SlaveSetName = setList[0] |
| 100 | statInfo.SlaveSetArea = setList[1] |
| 101 | statInfo.SlaveSetID = setList[2] |
| 102 | //被调也要加上set信息 |
| 103 | statInfo.SlaveName = fmt.Sprintf("%s.%s%s%s", statInfo.SlaveName, setList[0], setList[1], setList[2]) |
| 104 | } |
| 105 | |
| 106 | var statBody = statf.StatMicMsgBody{} |
| 107 | exceptionChecker := mux.cfg.ExceptionStatusChecker |
| 108 | if exceptionChecker == nil { |
| 109 | // if nil, use default |
| 110 | exceptionChecker = DefaultExceptionStatusChecker |
| 111 | } |
| 112 | if exceptionChecker(st.statusCode) { |
| 113 | statBody.ExecCount = 1 // 异常 |
| 114 | } else { |
| 115 | statBody.Count = 1 |
| 116 | statBody.TotalRspTime = st.costTime |
| 117 | statBody.MaxRspTime = int32(st.costTime) |
| 118 | statBody.MinRspTime = int32(st.costTime) |
| 119 | } |
| 120 | |
| 121 | ReportStatBase(&statInfo, &statBody, true) |
| 122 | } |
| 123 | |
| 124 | // SetConfig sets the cfg tho the TarsHttpMux. |
| 125 | func (mux *TarsHttpMux) SetConfig(cfg *TarsHttpConf) { |
no test coverage detected