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

Add support for operation tracing #1075

Merged

Conversation

arunkumarchacko
Copy link
Contributor

No description provided.

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

1 similar comment
@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@@ -0,0 +1,21 @@
/*
* Copyright 2013 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 2023

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

throws IOException {
try {
String traceName = this.traceContext + "(size=1)";
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the significance of (size=1) is it the batchSize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the control reaches here, the batchsize will be 1. Hence adding that context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we follow the same format then as in L-245 i.e. batchSize= instead of size=1?

Or if it is intentionally different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

storageOptions.getMaxRequestsPerBatch(),
resourceIds.size(),
storageOptions.getBatchThreads(),
"batchGetItemInfo");
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be traceContext which we prepared above ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -227,7 +242,10 @@ private void flushPendingRequests() throws IOException {
responseFutures.add(
requestsExecutor.submit(
() -> {
batch.execute();
String tc = String.format("%s(batchSize=%s)", this.traceContext, batch.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:shouldn't this be traceName instead of tc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


ThreadTraceEvent endEvent() {
ThreadTraceEvent result = new ThreadTraceEvent(EventType.END, name);
result.setTimeTaken(result.timeStamp - timeStamp);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it even capturing anything? result will be created in L163 and time taken is getting updated just immediately which will be tending to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is finding the difference of result with the timestamp of "this" event, which might have happened in past.

Copy link
Contributor

Choose a reason for hiding this comment

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

mind using this for timestamp?

Copy link
Contributor

Choose a reason for hiding this comment

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

why we need a separate event(i.e. END) for it? why can't we maintain a state of an operation to be either Started Completed, Merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I understood the comment. Start indicate when the operation started and End indicates when the operation has ended. Merged is a special kind of event which merges two consecutive start-end event pairs to one.


ThreadTraceEvent endEvent() {
ThreadTraceEvent result = new ThreadTraceEvent(EventType.END, name);
result.setTimeTaken(result.timeStamp - timeStamp);
Copy link
Contributor

Choose a reason for hiding this comment

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

mind using this for timestamp?

}
}

public void markEnd() {
Copy link
Contributor

Choose a reason for hiding this comment

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

via this function we are updating the type of the event which gives a feeling that EventType defined above is not actually the type but the state of an event. Which is very confusing.

also function says markEnd and inside we are updating the type to MERGED which is also adding to the confusion.

What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are merging the events to reduce the number of events. Added a comment.


ThreadTraceEvent endEvent() {
ThreadTraceEvent result = new ThreadTraceEvent(EventType.END, name);
result.setTimeTaken(result.timeStamp - timeStamp);
Copy link
Contributor

Choose a reason for hiding this comment

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

why we need a separate event(i.e. END) for it? why can't we maintain a state of an operation to be either Started Completed, Merged?

throws IOException {
try {
String traceName = this.traceContext + "(size=1)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we follow the same format then as in L-245 i.e. batchSize= instead of size=1?

Or if it is intentionally different?

}
}

public void markEnd() {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. shouldn't we verify that this is of type START before updating the type to MERGED?
  2. Shouldn't we capture the endtime as well just for completeness purposes and maybe pass the endTime as an argument to this function.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. This will always be start since it is created in the constructor.
  2. If we use endtime, we still need to subtract to find the time taken. We are more interested in the time taken by the operation. endTime can be derived from startTime and timeTaken. There is no value in duplicating the same information.

int eventsSize = events.size();
if (eventsSize != 0) {
ThreadTraceEvent lastEvent = events.get(eventsSize - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

One doubt: why we need to match it with the most recent event(or last) in array? We have reference to the startEvent and now an End is been invoked on it. Why not just go ahead and update the type of START event to be of type MERGED instead off creating an END type event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For eg. op1.start -> op2.start -> op2.end ->op1.end It is good to know the tree structure of the operations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have these intensions captured somewhere. It's will be hard to follow later on.

}

ThreadTraceEvent endEvent() {
ThreadTraceEvent result = new ThreadTraceEvent(EventType.END, name);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this.name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We usually add "this" in the construction.

return new ThreadTraceEvent(EventType.START, name);
}

private ThreadTraceEvent(EventType type, String name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would name suffice or do we need a unique id too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name already has some uniqueness. Basically it will be the context followed by current milliseconds.


int eventsSize = events.size();
if (eventsSize != 0) {
ThreadTraceEvent lastEvent = events.get(eventsSize - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have these intensions captured somewhere. It's will be hard to follow later on.

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

3 similar comments
@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

3 similar comments
@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko
Copy link
Contributor Author

/gcbrun

@arunkumarchacko arunkumarchacko merged commit 831bc38 into GoogleCloudDataproc:master Dec 14, 2023
1 of 2 checks passed
@arunkumarchacko arunkumarchacko deleted the tracing_master branch December 14, 2023 09:22
arunkumarchacko added a commit to arunkumarchacko/hadoop-connectors that referenced this pull request Dec 19, 2023
arunkumarchacko added a commit to arunkumarchacko/hadoop-connectors that referenced this pull request Jan 3, 2024
arunkumarchacko added a commit that referenced this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants