core: remove scopeid overloads of perfmark

This commit is contained in:
Carl Mastrangelo 2019-04-24 15:07:43 -07:00 committed by GitHub
parent ea70de601c
commit 4b2e60a06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 293 deletions

View File

@ -183,12 +183,11 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
@Override
public void start(Listener<RespT> observer, Metadata headers) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ClientCall.start");
PerfMark.taskStart(tag, "ClientCall.start");
try {
startInternal(observer, headers);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -386,12 +385,11 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
@Override
public void cancel(@Nullable String message, @Nullable Throwable cause) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ClientCall.cancel");
PerfMark.taskStart(tag, "ClientCall.cancel");
try {
cancelInternal(message, cause);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -426,12 +424,11 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
@Override
public void halfClose() {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ClientCall.halfClose");
PerfMark.taskStart(tag, "ClientCall.halfClose");
try {
halfCloseInternal();
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -445,12 +442,11 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
@Override
public void sendMessage(ReqT message) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ClientCall.sendMessage");
PerfMark.taskStart(tag, "ClientCall.sendMessage");
try {
sendMessageInternal(message);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -512,7 +508,6 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
private class ClientStreamListenerImpl implements ClientStreamListener {
private final Listener<RespT> observer;
private boolean closed;
private final long listenerScopeId = PerfTag.allocateNumericId();
public ClientStreamListenerImpl(Listener<RespT> observer) {
this.observer = checkNotNull(observer, "observer");
@ -530,8 +525,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
if (closed) {
return;
}
PerfMark.taskStart(
listenerScopeId, Thread.currentThread().getName(), tag, "ClientCall.headersRead");
PerfMark.taskStart(tag, "ClientCall.headersRead");
try {
observer.onHeaders(headers);
} catch (Throwable t) {
@ -540,7 +534,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
stream.cancel(status);
close(status, new Metadata());
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
}
@ -561,11 +555,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
GrpcUtil.closeQuietly(producer);
return;
}
PerfMark.taskStart(
listenerScopeId,
Thread.currentThread().getName(),
tag,
"ClientCall.messagesAvailable");
PerfMark.taskStart(tag, "ClientCall.messagesAvailable");
try {
InputStream message;
while ((message = producer.next()) != null) {
@ -584,7 +574,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
stream.cancel(status);
close(status, new Metadata());
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
}
@ -637,12 +627,11 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
// We intentionally don't keep the status or metadata from the server.
return;
}
PerfMark.taskStart(
listenerScopeId, Thread.currentThread().getName(), tag, "ClientCall.closed");
PerfMark.taskStart(tag, "ClientCall.closed");
try {
close(savedStatus, savedTrailers);
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
}
@ -659,8 +648,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
@Override
public final void runInContext() {
PerfMark.taskStart(
listenerScopeId, Thread.currentThread().getName(), tag, "ClientCall.onReady");
PerfMark.taskStart(tag, "ClientCall.onReady");
try {
observer.onReady();
} catch (Throwable t) {
@ -669,7 +657,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
stream.cancel(status);
close(status, new Metadata());
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
}

View File

@ -90,12 +90,11 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
@Override
public void sendHeaders(Metadata headers) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ServerCall.sendHeaders");
PerfMark.taskStart(tag, "ServerCall.sendHeaders");
try {
sendHeadersInternal(headers);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -140,12 +139,11 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
@Override
public void sendMessage(RespT message) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ServerCall.sendMessage");
PerfMark.taskStart(tag, "ServerCall.sendMessage");
try {
sendMessageInternal(message);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -194,12 +192,11 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
@Override
public void close(Status status, Metadata trailers) {
PerfMark.taskStart(
tag.getNumericTag(), Thread.currentThread().getName(), tag, "ServerCall.close");
PerfMark.taskStart(tag, "ServerCall.close");
try {
closeInternal(status, trailers);
} finally {
PerfMark.taskEnd(tag.getNumericTag(), Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -263,7 +260,6 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
private final ServerCallImpl<ReqT, ?> call;
private final ServerCall.Listener<ReqT> listener;
private final Context.CancellableContext context;
private final long listenerScopeId = PerfTag.allocateNumericId();
public ServerStreamListenerImpl(
ServerCallImpl<ReqT, ?> call, ServerCall.Listener<ReqT> listener,
@ -292,11 +288,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
return;
}
PerfMark.taskStart(
listenerScopeId,
Thread.currentThread().getName(),
call.tag,
"ServerCall.messagesAvailable");
PerfMark.taskStart(call.tag, "ServerCall.messagesAvailable");
InputStream message;
try {
while ((message = producer.next()) != null) {
@ -313,7 +305,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
MoreThrowables.throwIfUnchecked(t);
throw new RuntimeException(t);
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -323,26 +315,18 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
return;
}
PerfMark.taskStart(
listenerScopeId,
Thread.currentThread().getName(),
call.tag,
"ServerCall.halfClosed");
PerfMark.taskStart(call.tag, "ServerCall.halfClosed");
try {
listener.onHalfClose();
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@Override
public void closed(Status status) {
PerfMark.taskStart(
listenerScopeId,
Thread.currentThread().getName(),
call.tag,
"ServerCall.closed");
PerfMark.taskStart(call.tag, "ServerCall.closed");
try {
try {
if (status.isOk()) {
@ -358,7 +342,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
}
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
@ -367,15 +351,11 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
if (call.cancelled) {
return;
}
PerfMark.taskStart(
listenerScopeId,
Thread.currentThread().getName(),
call.tag,
"ServerCall.closed");
PerfMark.taskStart(call.tag, "ServerCall.closed");
try {
listener.onReady();
} finally {
PerfMark.taskEnd(listenerScopeId, Thread.currentThread().getName());
PerfMark.taskEnd();
}
}
}

View File

@ -42,23 +42,6 @@ public final class PerfMark {
*/
public static void taskStart(PerfTag tag, @CompileTimeConstant String taskName) {}
/**
* Start a Task with a Tag to identify it; a task represents some work that spans some time, and
* you are interested in both its start time and end time.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* #taskStart(String)} or {@link PerfTag#create(String)}.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static void taskStart(
long scopeId, String scopeName, PerfTag tag, @CompileTimeConstant String taskName) {}
/**
* Start a Task; a task represents some work that spans some time, and you are interested in both
* its start time and end time.
@ -68,19 +51,6 @@ public final class PerfMark {
*/
public static void taskStart(@CompileTimeConstant String taskName) {}
/**
* Start a Task; a task represents some work that spans some time, and you are interested in both
* its start time and end time.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static void taskStart(
long scopeId, String scopeName, @CompileTimeConstant String taskName) {}
/**
* Start a Task with a Tag to identify it and with a time threshold; a task represents some work
* that spans some time, and you are interested in both its start time and end time.
@ -101,33 +71,6 @@ public final class PerfMark {
public static void taskStartWithMinPeriod(
PerfTag tag, long minPeriodNanos, @CompileTimeConstant String taskName) {}
/**
* Start a Task with a Tag to identify it and with a time threshold; a task represents some work
* that spans some time, and you are interested in both its start time and end time.
*
* <p>Sometimes, you may be interested in only events that take more than a certain time
* threshold. In such cases, you can use this method. A Task that takes less than the specified
* threshold, along with all its sub-tasks, events, and additional tags will be discarded.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* #taskStartWithMinPeriod(long, String)} or {@link PerfTag#create(String)}.
* @param minPeriodNanos Tasks that takes less than the specified time period, in nanosecond, will
* be discarded, along with its sub-tasks, events, and additional tags.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static void taskStartWithMinPeriod(
long scopeId,
String scopeName,
PerfTag tag,
long minPeriodNanos,
@CompileTimeConstant String taskName) {}
/**
* Start a Task with time threshold. A task represents some work that spans some time, and you are
* interested in both its start time and end time.
@ -144,37 +87,9 @@ public final class PerfMark {
public static void taskStartWithMinPeriod(
long minPeriodNanos, @CompileTimeConstant String taskName) {}
/**
* Start a Task with time threshold. A task represents some work that spans some time, and you are
* interested in both its start time and end time.
*
* <p>Sometimes, you may be interested in only events that take more than a certain time
* threshold. In such cases, you can use this method. A task that takes less than the specified
* threshold, along with all its sub-tasks, events, and additional tags will be discarded.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param minPeriodNanos Tasks that takes less than the specified time period, in nanosecond, will
* be discarded, along with its sub-tasks, events, and additional tags.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static void taskStartWithMinPeriod(
long scopeId, String scopeName, long minPeriodNanos, @CompileTimeConstant String taskName) {}
/** End a Task. See {@link #taskStart(PerfTag, String)}. */
public static void taskEnd() {}
/**
* End a Task. See {@link #taskStart(PerfTag, String)}.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
*/
public static void taskEnd(long scopeId, String scopeName) {}
/**
* Start a Task with a Tag to identify it in a try-with-resource statement; a task represents some
* work that spans some time, and you are interested in both its start time and end time.
@ -192,27 +107,6 @@ public final class PerfMark {
return AUTO_DO_NOTHING;
}
/**
* Start a Task with a Tag to identify it in a try-with-resource statement; a task represents some
* work that spans some time, and you are interested in both its start time and end time.
*
* <p>Use this in a try-with-resource statement so that task will end automatically.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* #task(String)} or {@link PerfTag#create(String)}.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static PerfMarkTask task(
long scopeId, String scopeName, PerfTag tag, @CompileTimeConstant String taskName) {
return AUTO_DO_NOTHING;
}
/**
* Start a Task it in a try-with-resource statement; a task represents some work that spans some
* time, and you are interested in both its start time and end time.
@ -226,23 +120,6 @@ public final class PerfMark {
return AUTO_DO_NOTHING;
}
/**
* Start a Task it in a try-with-resource statement; a task represents some work that spans some
* time, and you are interested in both its start time and end time.
*
* <p>Use this in a try-with-resource statement so that task will end automatically.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static PerfMarkTask task(
long scopeId, String scopeName, @CompileTimeConstant String taskName) {
return AUTO_DO_NOTHING;
}
/**
* Start a Task with a Tag to identify it, and with time threshold, in a try-with-resource
* statement; a task represents some work that spans some time, and you are interested in both its
@ -268,38 +145,6 @@ public final class PerfMark {
return AUTO_DO_NOTHING;
}
/**
* Start a Task with a Tag to identify it, and with time threshold, in a try-with-resource
* statement; a task represents some work that spans some time, and you are interested in both its
* start time and end time.
*
* <p>Use this in a try-with-resource statement so that task will end automatically.
*
* <p>Sometimes, you may be interested in only events that take more than a certain time
* threshold. In such cases, you can use this method. A task that takes less than the specified
* threshold, along with all its sub-tasks, events, and additional tags will be discarded.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* #taskWithMinPeriod(long, String)} or {@link PerfTag#create(String)}.
* @param minPeriodNanos Tasks that takes less than the specified time period, in nanosecond, will
* be discarded, along with its sub-tasks, events, and additional tags.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static PerfMarkTask taskWithMinPeriod(
long scopeId,
String scopeName,
PerfTag tag,
long minPeriodNanos,
@CompileTimeConstant String taskName) {
return AUTO_DO_NOTHING;
}
/**
* Start a Task with time threshold in a try-with-resource statement; a task represents some work
* that spans some time, and you are interested in both its start time and end time.
@ -320,29 +165,6 @@ public final class PerfMark {
return AUTO_DO_NOTHING;
}
/**
* Start a Task with time threshold in a try-with-resource statement; a task represents some work
* that spans some time, and you are interested in both its start time and end time.
*
* <p>Use this in a try-with-resource statement so that task will end automatically.
*
* <p>Sometimes, you may be interested in only events that take more than a certain time
* threshold. In such cases, you can use this method. A task that takes less than the specified
* threshold, along with all its sub-tasks, events, and additional tags will be discarded.
*
* @param scopeId The scope of the task. The scope id is used to join task starting and ending
* across threads. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param minPeriodNanos Tasks that takes less than the specified time period, in nanosecond, will
* be discarded, along with its sub-tasks, events, and additional tags.
* @param taskName The name of the task. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this task.
*/
public static PerfMarkTask taskWithMinPeriod(
long scopeId, String scopeName, long minPeriodNanos, @CompileTimeConstant String taskName) {
return AUTO_DO_NOTHING;
}
static final PerfMarkTask AUTO_DO_NOTHING = new PerfMarkTask() {
@Override
public void close() {}
@ -363,25 +185,6 @@ public final class PerfMark {
*/
public static void event(PerfTag tag, @CompileTimeConstant String eventName) {}
/**
* Records an Event with a Tag to identify it.
*
* <p>An Event is different from a Task in that you don't care how much time it spanned. You are
* interested in only the time it happened.
*
* @param scopeId The scope of the event. The scope id is used to associated the event with a
* particular scope. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* #event(String)} or {@link PerfTag#create(String)}.
* @param eventName The name of the event. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this event.
*/
public static void event(
long scopeId, String scopeName, PerfTag tag, @CompileTimeConstant String eventName) {}
/**
* Records an Event.
*
@ -393,20 +196,6 @@ public final class PerfMark {
*/
public static void event(@CompileTimeConstant String eventName) {}
/**
* Records an Event.
*
* <p>An Event is different from a Task in that you don't care how much time it spanned. You are
* interested in only the time it happened.
*
* @param scopeId The scope of the event. The scope id is used to associate the event with a
* particular scope. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param eventName The name of the event. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this event.
*/
public static void event(long scopeId, String scopeName, @CompileTimeConstant String eventName) {}
/**
* Add an additional tag to the last task that was started.
*
@ -422,24 +211,4 @@ public final class PerfMark {
* Otherwise, instrumentation result will show "(invalid name)" for this tag.
*/
public static void tag(PerfTag tag, @CompileTimeConstant String tagName) {}
/**
* Add an additional tag to the last task that was started.
*
* <p>A tag is different from an Event or a task in that clients don't care about the time at
* which this tag is added. Instead, it allows clients to associate an additional tag to the
* current Task.
*
* @param scopeId The scope of the tag. The scope id is used to associate a tag with a particular
* scope. The scope id must be a positive number.
* @param scopeName The name of the scope.
* @param tag a Tag object associated with the task. See {@link PerfTag} for description. Don't
* use 0 for the {@code numericTag} of the Tag object. 0 is reserved to represent that a task
* does not have a numeric tag associated. In this case, you are encouraged to use {@link
* PerfTag#create(String)}.
* @param tagName The name of the tag. <b>This parameter must be a compile-time constant!</b>
* Otherwise, instrumentation result will show "(invalid name)" for this tag.
*/
public static void tag(
long scopeId, String scopeName, PerfTag tag, @CompileTimeConstant String tagName) {}
}