fix: match SET_TRACED_PROCESSORS payload to agent protocol
Payload now sends {processors: {id: "BOTH"}} map instead of
{routeId, processorIds[]} array. Tracing state keyed by application
name (global, not per-route) matching agent behavior.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -164,26 +164,26 @@ export default function ExchangeDetail() {
|
||||
const { toast } = useToast()
|
||||
const tracingStore = useTracingStore()
|
||||
const sendCommand = useSendGroupCommand()
|
||||
const appRoute = detail ? `${detail.applicationName}:${detail.routeId}` : ''
|
||||
const app = detail?.applicationName ?? ''
|
||||
|
||||
const handleToggleTracing = useCallback((processorId: string) => {
|
||||
if (!processorId || !detail?.applicationName || !detail?.routeId) return
|
||||
const newSet = tracingStore.toggleProcessor(appRoute, processorId)
|
||||
if (!processorId || !detail?.applicationName) return
|
||||
const newMap = tracingStore.toggleProcessor(app, processorId)
|
||||
sendCommand.mutate({
|
||||
group: detail.applicationName,
|
||||
type: 'set-traced-processors',
|
||||
payload: { routeId: detail.routeId, processorIds: Array.from(newSet) },
|
||||
payload: { processors: newMap },
|
||||
}, {
|
||||
onSuccess: (data) => {
|
||||
const action = newSet.has(processorId) ? 'enabled' : 'disabled'
|
||||
const action = processorId in newMap ? 'enabled' : 'disabled'
|
||||
toast({ title: `Tracing ${action}`, description: `${processorId} — sent to ${data?.targetCount ?? 0} agent(s)`, variant: 'success' })
|
||||
},
|
||||
onError: () => {
|
||||
tracingStore.toggleProcessor(appRoute, processorId)
|
||||
tracingStore.toggleProcessor(app, processorId)
|
||||
toast({ title: 'Command failed', description: 'Could not send tracing command', variant: 'error' })
|
||||
},
|
||||
})
|
||||
}, [detail, appRoute, tracingStore, sendCommand, toast])
|
||||
}, [detail, app, tracingStore, sendCommand, toast])
|
||||
|
||||
// Correlation chain
|
||||
const correlatedExchanges = useMemo(() => {
|
||||
@@ -346,7 +346,7 @@ export default function ExchangeDetail() {
|
||||
const pid = processorIds[index]
|
||||
if (!pid || !detail?.applicationName) return []
|
||||
return [{
|
||||
label: tracingStore.isTraced(appRoute, pid) ? 'Disable Tracing' : 'Enable Tracing',
|
||||
label: tracingStore.isTraced(app, pid) ? 'Disable Tracing' : 'Enable Tracing',
|
||||
onClick: () => handleToggleTracing(pid),
|
||||
disabled: sendCommand.isPending,
|
||||
}]
|
||||
@@ -365,7 +365,7 @@ export default function ExchangeDetail() {
|
||||
const pid = flowProcessorIds[index]
|
||||
if (!pid || !detail?.applicationName) return []
|
||||
return [{
|
||||
label: tracingStore.isTraced(appRoute, pid) ? 'Disable Tracing' : 'Enable Tracing',
|
||||
label: tracingStore.isTraced(app, pid) ? 'Disable Tracing' : 'Enable Tracing',
|
||||
onClick: () => handleToggleTracing(pid),
|
||||
disabled: sendCommand.isPending,
|
||||
}]
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
type CaptureMode = 'NONE' | 'INPUT' | 'OUTPUT' | 'BOTH'
|
||||
|
||||
interface TracingState {
|
||||
tracedProcessors: Record<string, Set<string>>
|
||||
isTraced: (appRoute: string, processorId: string) => boolean
|
||||
toggleProcessor: (appRoute: string, processorId: string) => Set<string>
|
||||
/** Key: applicationName → { processorId: captureMode } */
|
||||
tracedProcessors: Record<string, Record<string, CaptureMode>>
|
||||
isTraced: (app: string, processorId: string) => boolean
|
||||
/** Toggle processor tracing (BOTH on, remove on off). Returns the full map for the app. */
|
||||
toggleProcessor: (app: string, processorId: string) => Record<string, CaptureMode>
|
||||
}
|
||||
|
||||
export const useTracingStore = create<TracingState>((set, get) => ({
|
||||
tracedProcessors: {},
|
||||
|
||||
isTraced: (appRoute, processorId) =>
|
||||
get().tracedProcessors[appRoute]?.has(processorId) ?? false,
|
||||
isTraced: (app, processorId) =>
|
||||
processorId in (get().tracedProcessors[app] ?? {}),
|
||||
|
||||
toggleProcessor: (appRoute, processorId) => {
|
||||
const current = new Set(get().tracedProcessors[appRoute] ?? [])
|
||||
if (current.has(processorId)) current.delete(processorId)
|
||||
else current.add(processorId)
|
||||
toggleProcessor: (app, processorId) => {
|
||||
const current = { ...(get().tracedProcessors[app] ?? {}) }
|
||||
if (processorId in current) delete current[processorId]
|
||||
else current[processorId] = 'BOTH'
|
||||
set((state) => ({
|
||||
tracedProcessors: { ...state.tracedProcessors, [appRoute]: current },
|
||||
tracedProcessors: { ...state.tracedProcessors, [app]: current },
|
||||
}))
|
||||
return current
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user