class JfrEventRecorder implements EventRecorder {

    private final Map<Class<?>, Constructor<?>> constructorMap = new HashMap<>();

    @Override
    public void record(Event event) {

        LettuceAssert.notNull(event, "Event must not be null");

        jdk.jfr.Event jfrEvent = createEvent(event);

        if (jfrEvent != null) {
            jfrEvent.commit();
        }
    }

    @Override
    public RecordableEvent start(Event event) {

        LettuceAssert.notNull(event, "Event must not be null");

        jdk.jfr.Event jfrEvent = createEvent(event);

        if (jfrEvent != null) {
            jfrEvent.begin();
            return new JfrRecordableEvent(jfrEvent);
        }

        return NoOpEventRecorder.INSTANCE;
    }

    private Constructor<?> getEventConstructor(Event event) throws NoSuchMethodException {

        Constructor<?> constructor;

        synchronized (constructorMap) {
            constructor = constructorMap.get(event.getClass());
        }

        if (constructor == null) {

            String jfrClassName = event.getClass().getPackage().getName() + ".Jfr" + event.getClass().getSimpleName();

            Class<?> eventClass = LettuceClassUtils.findClass(jfrClassName);

            if (eventClass == null) {
                constructor = Object.class.getConstructor();
            } else {
                constructor = eventClass.getDeclaredConstructors()[0];
                constructor.setAccessible(true);
            }

            synchronized (constructorMap) {
                constructorMap.put(event.getClass(), constructor);
            }
        }

        return constructor;
    }

    private jdk.jfr.Event createEvent(Event event) {<FILL_FUNCTION_BODY>}

    static class JfrRecordableEvent implements RecordableEvent {

        private final jdk.jfr.Event jfrEvent;

        public JfrRecordableEvent(jdk.jfr.Event jfrEvent) {
            this.jfrEvent = jfrEvent;
        }

        @Override
        public void record() {
            jfrEvent.end();
            jfrEvent.commit();
        }

    }

}


        try {
            Constructor<?> constructor = getEventConstructor(event);

            if (constructor.getDeclaringClass() == Object.class) {
                return null;
            }

            return (jdk.jfr.Event) constructor.newInstance(event);

        } catch (ReflectiveOperationException e) {
            throw new IllegalStateException(e);
        }
    
<no_super_class>