Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending recording/publishing infra #2859

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rkeely
Copy link

@rkeely rkeely commented May 20, 2024

Seems I messed up the previous PR a bit. Had to create a new one and carry the context here.

This PR is to fulfill this #2809 (comment) and address comments from https://github.com/redis/lettuce/pull/2819

Extending individual events requires duplicating a lot of the functionality within the individual events and it makes these mutable.

I was looking more for an approach where we extend the recording/publishing infrastructure. In particular:

  • Add Event getSource() to RecordableEvent and make RecordableEvent extends Event
  • Capture the original event in JfrRecordableEvent and rework NoOpEventRecorder to create an event instance
  • Long-lived events would be published to EventBus (e.g. EventRecorder.RecordableEvent event = …; later: eventBus.publish(event).
  • Adopt JfrEventRecorder.publish(…) to check whether the given event is EventRecorder.RecordableEvent. If so, then we call record(…) on the event instead of jdk.jfr.Event jfrEvent = createEvent(…);
  • Retrofit DefaultEventBus to unwrap EventRecorder.RecordableEvent before emitting the event

This is more about getting the direction correct. Will supply more testing if the infra change looks good.

  • Add publish interface in EventRecorder
  • Allow DefaultEventBus to publish event through EventRecorder
  • Wrap source Event in RecordableEvent

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

* Add publish interface in EventRecorder
* Allow DefaultEventBus to publish event through EventRecorder
* Wrap source Event in JfrRecordableEvent
void record();

}
void publish(Event event);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the semantic difference between record(Event) and publish(Event)?

Such an arrangement asks for trouble because the methods are ambiguous without clear distinction.

RecordableEvent is part of the API, moving it around introduces a breaking change without good reason. All necessary changes are possible without breaking the public API.

Copy link
Author

@rkeely rkeely May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move RecordableEvent back to EventRecorder.

I added publish per #2819 (comment), specifically:

  • Adopt JfrEventRecorder.publish(…) to check whether the given event is EventRecorder.RecordableEvent. If so, then we call record(…) on the event instead of jdk.jfr.Event jfrEvent = createEvent(…);

Agreed that they create ambiguity. Should I combine the implementation of JfrEventRecorder.#record and JfrEventRecorder#publish into #record?

@tishun tishun added the status: waiting-for-feedback We need additional information before we can continue label May 22, 2024
@rkeely
Copy link
Author

rkeely commented Jun 2, 2024

@mp911de posted a new commits to address your last comment. Would you please take a look?
Still its only changing the infra, and if it looks good, I am thinking to make another change that actually publish/record those RecordableEvent through EventBus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants