@Override
    public void onEvent(Event event) {
        Set<NacosTraceSubscriber> subscribers = interestedEvents.get(event.getClass());
        if (null == subscribers) {
            return;
        }
        TraceEvent traceEvent = (TraceEvent) event;
        for (NacosTraceSubscriber each : subscribers) {
            if (null != each.executor()) {
                each.executor().execute(() -> onEvent0(each, traceEvent));
            } else {
                onEvent0(each, traceEvent);
            }
        }
    }
@Test
    void testOnEvent() {
        // Test RegisterInstanceTraceEvent.
        RegisterInstanceTraceEvent registerInstanceTraceEvent = new RegisterInstanceTraceEvent(1L, "", true, "", "", "", "", 1);
        doThrow(new RuntimeException("test")).when(mockInstanceSubscriber).onEvent(registerInstanceTraceEvent);
        combinedTraceSubscriber.onEvent(registerInstanceTraceEvent);
        verify(mockInstanceSubscriber, times(1)).onEvent(registerInstanceTraceEvent);
        verify(mockServiceSubscriber, never()).onEvent(registerInstanceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(registerInstanceTraceEvent);
        // Test DeregisterInstanceTraceEvent.
        DeregisterInstanceTraceEvent deregisterInstanceTraceEvent = new DeregisterInstanceTraceEvent(1L, "", true,
                DeregisterInstanceReason.REQUEST, "", "", "", "", 1);
        combinedTraceSubscriber.onEvent(deregisterInstanceTraceEvent);
        verify(mockInstanceSubscriber, times(1)).onEvent(deregisterInstanceTraceEvent);
        verify(mockServiceSubscriber, never()).onEvent(deregisterInstanceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(deregisterInstanceTraceEvent);
        // Test UpdateInstanceTraceEvent.
        UpdateInstanceTraceEvent updateInstanceTraceEvent = new UpdateInstanceTraceEvent(1L, "", "", "", "", "", 123, null);
        combinedTraceSubscriber.onEvent(updateInstanceTraceEvent);
        verify(mockInstanceSubscriber, times(1)).onEvent(updateInstanceTraceEvent);
        verify(mockServiceSubscriber, never()).onEvent(updateInstanceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(updateInstanceTraceEvent);
        // Test RegisterServiceTraceEvent.
        RegisterServiceTraceEvent registerServiceTraceEvent = new RegisterServiceTraceEvent(1L, "", "", "");
        combinedTraceSubscriber.onEvent(registerServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(registerServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(registerServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(registerServiceTraceEvent);
        // Test DeregisterServiceTraceEvent.
        DeregisterServiceTraceEvent deregisterServiceTraceEvent = new DeregisterServiceTraceEvent(1L, "", "", "");
        combinedTraceSubscriber.onEvent(deregisterServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(deregisterServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(deregisterServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(deregisterServiceTraceEvent);
        // Test SubscribeServiceTraceEvent.
        SubscribeServiceTraceEvent subscribeServiceTraceEvent = new SubscribeServiceTraceEvent(1L, "", "", "", "");
        combinedTraceSubscriber.onEvent(subscribeServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(subscribeServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(subscribeServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(subscribeServiceTraceEvent);
        // Test UnsubscribeServiceTraceEvent.
        UnsubscribeServiceTraceEvent unsubscribeServiceTraceEvent = new UnsubscribeServiceTraceEvent(1L, "", "", "", "");
        combinedTraceSubscriber.onEvent(unsubscribeServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(unsubscribeServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(unsubscribeServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(unsubscribeServiceTraceEvent);
        // Test UpdateServiceTraceEvent.
        UpdateServiceTraceEvent updateServiceTraceEvent = new UpdateServiceTraceEvent(1L, "", "", "", null);
        combinedTraceSubscriber.onEvent(updateServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(updateServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(updateServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(updateServiceTraceEvent);
        // Test PushServiceTraceEvent.
        PushServiceTraceEvent pushServiceTraceEvent = new PushServiceTraceEvent(1L, 1L, 1L, 1L, "", "", "", "", 1);
        combinedTraceSubscriber.onEvent(pushServiceTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(pushServiceTraceEvent);
        verify(mockServiceSubscriber, times(1)).onEvent(pushServiceTraceEvent);
        verify(mockOtherSubscriber, never()).onEvent(pushServiceTraceEvent);
        // Test HealthStateChangeTraceEvent.
        HealthStateChangeTraceEvent healthStateChangeTraceEvent = new HealthStateChangeTraceEvent(1L, "", "", "", "", 8867, true, "");
        combinedTraceSubscriber.onEvent(healthStateChangeTraceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(healthStateChangeTraceEvent);
        verify(mockServiceSubscriber, never()).onEvent(healthStateChangeTraceEvent);
        verify(mockOtherSubscriber, times(1)).onEvent(healthStateChangeTraceEvent);
        // Test TraceEvent.
        TraceEvent traceEvent = new TraceEvent("", 1L, "", "", "");
        combinedTraceSubscriber.onEvent(traceEvent);
        verify(mockInstanceSubscriber, never()).onEvent(traceEvent);
        verify(mockServiceSubscriber, never()).onEvent(traceEvent);
        verify(mockOtherSubscriber, never()).onEvent(traceEvent);
    }