@@ -190,6 +190,20 @@ func (s *CallLogStore) Clear() {
190190 _ = clearCallLogDB (s .db )
191191}
192192
193+ // DeleteSession removes all call log rows for a grouped session key (kind-sessionId).
194+ func (s * CallLogStore ) DeleteSession (sessionKey string ) (int64 , error ) {
195+ if s == nil || s .db == nil {
196+ return 0 , errors .New ("call log store unavailable" )
197+ }
198+ kind , sessionID , ok := parseCallLogSessionKey (sessionKey )
199+ if ! ok {
200+ return 0 , errors .New ("invalid session key" )
201+ }
202+ s .mu .Lock ()
203+ defer s .mu .Unlock ()
204+ return deleteCallLogsBySession (s .db , kind , sessionID )
205+ }
206+
193207func shouldRecordCallLog (path string ) bool {
194208 p := strings .TrimSpace (path )
195209 if p == "" {
@@ -214,9 +228,9 @@ func isProbeMethod(method string) bool {
214228}
215229
216230// shouldUseCallLog decides whether a request gets a full call-log trace.
217- // GET/HEAD probes (connectivity checks, invalid paths) go to system logs instead .
231+ // Invalid ingress paths and GET/HEAD probes (except GET /v1/models) are excluded .
218232func shouldUseCallLog (r * http.Request , ingress provider.Ingress , pathOK bool ) bool {
219- if r == nil {
233+ if r == nil || ! pathOK {
220234 return false
221235 }
222236 path := r .URL .EscapedPath ()
@@ -229,7 +243,7 @@ func shouldUseCallLog(r *http.Request, ingress provider.Ingress, pathOK bool) bo
229243 if ! isProbeMethod (r .Method ) {
230244 return true
231245 }
232- return pathOK && isModelsPath (ingress .PathSuffix )
246+ return isModelsPath (ingress .PathSuffix )
233247}
234248
235249func startRequestTraceIfNeeded (store * CallLogStore , r * http.Request , ingress provider.Ingress , pathOK bool ) * requestTrace {
@@ -239,11 +253,24 @@ func startRequestTraceIfNeeded(store *CallLogStore, r *http.Request, ingress pro
239253 return startRequestTrace (store , r )
240254}
241255
242- func logProxyProbeIfNeeded (r * http.Request , trace * requestTrace , status int , detail string ) {
243- if trace != nil || r == nil || ! isProbeMethod (r .Method ) {
256+ func logProxyProbeIfNeeded (r * http.Request , trace * requestTrace , pathOK bool , status int , detail string ) {
257+ if trace != nil || r == nil || pathOK {
258+ return
259+ }
260+ if isHostLevelLegacyV1Path (inboundRequestPath (r )) {
261+ return
262+ }
263+ if ! isProbeMethod (r .Method ) {
244264 return
245265 }
246- syslog .LogProxyProbe (r .Method , inboundRequestURL (r ), status , detail )
266+ syslog .LogProxyProbe (r .Method , inboundRequestPath (r ), status , detail )
267+ }
268+
269+ // isHostLevelLegacyV1Path matches bare /v1/... requests (no /{providerId} prefix).
270+ // Connectivity fallbacks used to hit these against the local proxy; they are not logged.
271+ func isHostLevelLegacyV1Path (path string ) bool {
272+ parts := strings .Split (strings .Trim (strings .TrimSpace (path ), "/" ), "/" )
273+ return len (parts ) >= 2 && strings .EqualFold (parts [0 ], "v1" )
247274}
248275
249276type requestTrace struct {
@@ -278,7 +305,7 @@ func startRequestTrace(store *CallLogStore, r *http.Request) *requestTrace {
278305 }
279306}
280307
281- func inboundRequestURL (r * http.Request ) string {
308+ func inboundRequestPath (r * http.Request ) string {
282309 if r == nil || r .URL == nil {
283310 return ""
284311 }
@@ -287,8 +314,16 @@ func inboundRequestURL(r *http.Request) string {
287314 path = r .URL .Path
288315 }
289316 if r .URL .RawQuery != "" {
290- path = path + "?" + r .URL .RawQuery
317+ return path + "?" + r .URL .RawQuery
318+ }
319+ return path
320+ }
321+
322+ func inboundRequestURL (r * http.Request ) string {
323+ if r == nil || r .URL == nil {
324+ return ""
291325 }
326+ path := inboundRequestPath (r )
292327 host := strings .TrimSpace (r .Host )
293328 if host == "" {
294329 host = strings .TrimSpace (r .URL .Host )
0 commit comments