@@ -149,7 +149,7 @@ func AddPMessageStep(ctx context.Context, level netdata.PMessageLevel, message s
149149 tctx .Profile .Add (step )
150150}
151151
152- func StartHttpService (ctx context.Context , req http.Request ) (newCtx context.Context ) {
152+ func StartHttpService (ctx context.Context , req * http.Request ) (newCtx context.Context ) {
153153 defer common .ReportScouterPanic ()
154154 if ctx == nil {
155155 return context .Background ()
@@ -174,7 +174,7 @@ func StartHttpService(ctx context.Context, req http.Request) (newCtx context.Con
174174 return newCtx
175175}
176176
177- func getRemoteIp (req http.Request ) string {
177+ func getRemoteIp (req * http.Request ) string {
178178 ip := req .RemoteAddr
179179 if ac .TraceHttpClientIpHeaderKey != "" {
180180 headerIp := req .Header .Get (ac .TraceHttpClientIpHeaderKey )
@@ -185,9 +185,20 @@ func getRemoteIp(req http.Request) string {
185185 return strings .Split (ip , ":" )[0 ]
186186}
187187
188- func EndHttpService (ctx context.Context , req http.Request , res http.Response ) {
189- //TODO body (of specific service) profile from req.body
188+ func EndHttpService (ctx context.Context , req * http.Request , res * http.Response ) {
190189 common .ReportScouterPanic ()
190+ //TODO body (of specific service) profile from req.body
191+
192+ if res != nil {
193+ if ctx == nil {
194+ return
195+ }
196+ tctx := tctxmanager .GetTraceContext (ctx )
197+ if tctx == nil || tctx .Closed {
198+ return
199+ }
200+ tctx .Status = int32 (res .StatusCode )
201+ }
191202 endAnyService (ctx )
192203}
193204
@@ -454,7 +465,7 @@ func EndMethod(ctx context.Context, step *netdata.MethodStep) {
454465 tctx .Profile .Pop (step )
455466}
456467
457- func profileHttpHeaders (r http.Request , tctx * netio.TraceContext ) {
468+ func profileHttpHeaders (r * http.Request , tctx * netio.TraceContext ) {
458469 startTime := util .MillisToNow (tctx .StartTime )
459470 if ac .ProfileHttpHeaderEnabled {
460471 notAll := len (ac .ProfileHttpHeaderKeys ) > 0
0 commit comments