@@ -108,6 +108,9 @@ func AddStep(ctx context.Context, step netdata.Step) {
108
108
return
109
109
}
110
110
tctx := tctxmanager .GetTraceContext (ctx )
111
+ if tctx == nil {
112
+ return
113
+ }
111
114
tctx .Profile .Add (step )
112
115
}
113
116
@@ -117,6 +120,9 @@ func AddMessageStep(ctx context.Context, message string) {
117
120
return
118
121
}
119
122
tctx := tctxmanager .GetTraceContext (ctx )
123
+ if tctx == nil {
124
+ return
125
+ }
120
126
121
127
step := netdata .NewMessageStep (message , util .MillisToNow (tctx .StartTime ))
122
128
tctx .Profile .Add (step )
@@ -128,6 +134,9 @@ func AddHashedMessageStep(ctx context.Context, message string, value, elapsed in
128
134
return
129
135
}
130
136
tctx := tctxmanager .GetTraceContext (ctx )
137
+ if tctx == nil {
138
+ return
139
+ }
131
140
132
141
step := netdata .NewHashedMessageStep (netio .SendHashedMessage (message ), util .MillisToNow (tctx .StartTime ))
133
142
step .Value = value
@@ -141,6 +150,9 @@ func AddPMessageStep(ctx context.Context, level netdata.PMessageLevel, message s
141
150
return
142
151
}
143
152
tctx := tctxmanager .GetTraceContext (ctx )
153
+ if tctx == nil {
154
+ return
155
+ }
144
156
145
157
step := netdata .NewPMessageStep (util .MillisToNow (tctx .StartTime ))
146
158
step .SetMessage (netio .SendHashedMessage (message ), params ... )
@@ -182,6 +194,11 @@ func getRemoteIp(req *http.Request) string {
182
194
ip = headerIp
183
195
}
184
196
}
197
+ return ip
198
+ }
199
+
200
+ func normalizeIp (ip string ) string {
201
+
185
202
return strings .Split (ip , ":" )[0 ]
186
203
}
187
204
@@ -334,7 +351,7 @@ func startService(ctx context.Context, serviceName, remoteAddr string) (context.
334
351
335
352
tctx .ServiceName = serviceName
336
353
tctx .ServiceHash = netio .SendServiceName (serviceName )
337
- tctx .RemoteIp = remoteAddr
354
+ tctx .RemoteIp = normalizeIp ( remoteAddr )
338
355
return newCtx , tctx
339
356
}
340
357
0 commit comments