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

Modify EventHandle to be created for every event and support internal and external origination times #3546

Merged
merged 8 commits into from
Nov 1, 2023

Conversation

kkondaka
Copy link
Collaborator

Description

Modify EventHandle to be created for every event and support internal and external origination times.

  1. Moved DefaultEvent handle to data-prepper-api from data-prepper-core
  2. Added API to get/set acknowledgementset, and get/set external origination times
  3. EventHandle is now created by default with internal origination time when JacksonEvent is created

Partially resolves #3494

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • [ X] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [X ] Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@kkondaka kkondaka force-pushed the event-handle-changes branch 2 times, most recently from 0e382c6 to 310bb2e Compare October 25, 2023 22:19
Krishna Kondaka added 3 commits October 25, 2023 22:21
… and external origination times

Signed-off-by: Krishna Kondaka <[email protected]>
Signed-off-by: Krishna Kondaka <[email protected]>
Signed-off-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka force-pushed the event-handle-changes branch from 310bb2e to 5e144bd Compare October 25, 2023 22:21
Krishna Kondaka added 2 commits October 25, 2023 23:31
Signed-off-by: Krishna Kondaka <[email protected]>
Signed-off-by: Krishna Kondaka <[email protected]>

@Override
public void release(boolean result) {
System.out.println("======release called==="+result);
Copy link
Member

Choose a reason for hiding this comment

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

Should remove this print statement

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops. Yes

}

public static Event fromMessage(String message) {
return JacksonEvent.builder()
JacksonEvent event = JacksonEvent.builder()
Copy link
Member

Choose a reason for hiding this comment

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

What does this change accomplish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not needed. I was trying something. undid the change. Thanks!

Comment on lines 152 to 156
/*
lenient().doAnswer(a -> {
return null;
}).when(eventHandle).release(any(Boolean.class));
*/
Copy link
Member

Choose a reason for hiding this comment

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

Extra comment

Copy link
Member

Choose a reason for hiding this comment

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

Please delete commented out code.

s3SinkService.output(records);

final List<EventHandle> eventHandles = records.stream().map(Record::getData).map(Event::getEventHandle).collect(Collectors.toList());
//final List<EventHandle> eventHandles = records.stream().map(Record::getData).map(Event::getEventHandle).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

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

Extra comment

return this.internalOriginationTime;
}

@Override
Copy link
Member

Choose a reason for hiding this comment

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

For the next PR let's scope down and first only implement internal end to end latency metric. For ddb use case we could potentially use this value for external (https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html#DDB-Type-streams_StreamRecord-ApproximateCreationDateTime), so we may not need to make any hasty decisions on users configuring this time. @dlvenable What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

If I understand your proposal, the Source will set this value on the Event. We don't need to let the user configure this in the pipeline. But, we could in the future. Right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. Will only implement internal latency for now in the OpenSearchSink and S3 Sink

import java.time.Instant;
import java.io.Serializable;

public class DefaultEventHandle implements EventHandle, Serializable {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this package protected? I'd really like to avoid this getting used as it will be hard to clean-up in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By "package protected" you mean make this as
protected class DefaultEventHandle implements EventHandle, Serializable?

* @param acknowledgementSet acknowledgementSet to be set in the event handle
* @since 2.6
*/
void setAcknowledgementSet(final AcknowledgementSet acknowledgementSet);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to expose all of this? It might make sense to have a different interface for internal use. Say InternalEventHandle. Then DefaultEventHandle can implement that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I understand this suggestion. Are you suggesting we have InternalEventHandle and EventHandle separately?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we'd have two interfaces:

public interface InterfaceEventHandle {
...
// methods that data-prepper-core calls are here.
}

And we implement it as:

class DefaultEventHandle implements EventHandle, InternalEventHandle
{
...
}

In data-prepper, core we'd need a cast: InternalEventHandle internalEventHandle = (InternalEventHandle) eventHandle.

This would be a good indication that somebody is doing something they shouldn't if we see it outside of data-prepper-core.

Comment on lines 152 to 156
/*
lenient().doAnswer(a -> {
return null;
}).when(eventHandle).release(any(Boolean.class));
*/
Copy link
Member

Choose a reason for hiding this comment

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

Please delete commented out code.

s3SinkService.output(records);

for (EventHandle eventHandle : eventHandles) {
System.out.println("==2====EventHandle=="+eventHandle+"==="+acknowledgementSet);
Copy link
Member

Choose a reason for hiding this comment

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

Please remove println usage.

* @param externalOriginationTime externalOriginationTime to be set in the event handle
* @since 2.6
*/
void setExternalOriginationTime(final Instant externalOriginationTime);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should set the origination time on the EventMetadata. The EventHandle can then get this data from the EventMetadata.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Internal origination time is set in EventMetadata and EventHandle gets it from it. Do you want the external origination time also set in the EventMetadata?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, add this to EventMetadata.

The EventHandle can also hold a reference to the time in there.

dlvenable
dlvenable previously approved these changes Nov 1, 2023
graytaylor0
graytaylor0 previously approved these changes Nov 1, 2023
Signed-off-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka dismissed stale reviews from graytaylor0 and dlvenable via 53b1787 November 1, 2023 18:12
Signed-off-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka merged commit 7869eb7 into opensearch-project:main Nov 1, 2023
57 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.5 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.5 2.5
# Navigate to the new working tree
cd .worktrees/backport-2.5
# Create a new branch
git switch --create backport/backport-3546-to-2.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7869eb7aac41965adc9a3eab4f85d4121f7b41b9
# Push it to GitHub
git push --set-upstream origin backport/backport-3546-to-2.5
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.5

Then, create a pull request where the base branch is 2.5 and the compare/head branch is backport/backport-3546-to-2.5.

@kkondaka kkondaka deleted the event-handle-changes branch May 13, 2024 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sink level metric for end to end latency
4 participants