Java Code Examples for io.perfmark.PerfMark#startTask()
The following examples show how to use
io.perfmark.PerfMark#startTask() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 6 votes |
@Override public void onNext(O outMesg) { boolean stopped = false; PerfMark.startTask(filter.filterName(), "onNextAsync"); try { PerfMark.linkIn(onNextLinkOut.get()); addPerfMarkTags(inMesg); recordFilterCompletion(SUCCESS, filter, startTime, inMesg, snapshot); if (outMesg == null) { outMesg = filter.getDefaultOutput(inMesg); } stopped = true; PerfMark.stopTask(filter.filterName(), "onNextAsync"); resumeInBindingContext(outMesg, filter.filterName()); } catch (Exception e) { decrementConcurrency(); handleException(inMesg, filter.filterName(), e); } finally { if (!stopped) { PerfMark.stopTask(filter.filterName(), "onNextAsync"); } } }
Example 2
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 6 votes |
protected final void invokeNextStage(final O zuulMesg, final HttpContent chunk) { if (nextStage != null) { PerfMark.startTask(getClass().getName(), "invokeNextStageChunk"); try { addPerfMarkTags(zuulMesg); nextStage.filter(zuulMesg, chunk); } finally { PerfMark.stopTask(getClass().getName(), "invokeNextStageChunk"); } } else { //Next stage is Netty channel handler PerfMark.startTask(getClass().getName(), "fireChannelReadChunk"); try { addPerfMarkTags(zuulMesg); getChannelHandlerContext(zuulMesg).fireChannelRead(chunk); } finally { PerfMark.stopTask(getClass().getName(), "fireChannelReadChunk"); } } }
Example 3
Source File: NettyServerHandler.java From grpc-java with Apache License 2.0 | 6 votes |
@Override protected void onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, StreamException http2Ex) { logger.log(Level.WARNING, "Stream Error", cause); NettyServerStream.TransportState serverStream = serverStream( connection().stream(Http2Exception.streamId(http2Ex))); Tag tag = serverStream != null ? serverStream.tag() : PerfMark.createTag(); PerfMark.startTask("NettyServerHandler.onStreamError", tag); try { if (serverStream != null) { serverStream.transportReportStatus(Utils.statusFromThrowable(cause)); } // TODO(ejona): Abort the stream by sending headers to help the client with debugging. // Delegate to the base class to send a RST_STREAM. super.onStreamError(ctx, outbound, cause, http2Ex); } finally { PerfMark.stopTask("NettyServerHandler.onStreamError", tag); } }
Example 4
Source File: ServerCallImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void closed(Status status) { PerfMark.startTask("ServerStreamListener.closed", call.tag); try { closedInternal(status); } finally { PerfMark.stopTask("ServerStreamListener.closed", call.tag); } }
Example 5
Source File: ZuulEndPointRunner.java From zuul with Apache License 2.0 | 5 votes |
@Override protected void resume(final HttpResponseMessage zuulMesg) { PerfMark.startTask(getClass().getSimpleName(), "resume"); try { if (zuulMesg.getContext().isCancelled()) { return; } invokeNextStage(zuulMesg); } finally { PerfMark.stopTask(getClass().getSimpleName(), "resume"); } }
Example 6
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable ex) { PerfMark.startTask(filter.filterName(), "onErrorAsync"); try { PerfMark.linkIn(onErrorLinkOut.get()); decrementConcurrency(); recordFilterCompletion(FAILED, filter, startTime, inMesg, snapshot); final O outMesg = handleFilterException(inMesg, filter, ex); resumeInBindingContext(outMesg, filter.filterName()); } catch (Exception e) { handleException(inMesg, filter.filterName(), e); } finally { PerfMark.stopTask(filter.filterName(), "onErrorAsync"); } }
Example 7
Source File: NettyClientStream.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void cancel(Status status) { PerfMark.startTask("NettyClientStream$Sink.cancel"); try { writeQueue.enqueue(new CancelClientStreamCommand(transportState(), status), true); } finally { PerfMark.stopTask("NettyClientStream$Sink.cancel"); } }
Example 8
Source File: NettyClientStream.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void writeHeaders(Metadata headers, byte[] requestPayload) { PerfMark.startTask("NettyClientStream$Sink.writeHeaders"); try { writeHeadersInternal(headers, requestPayload); } finally { PerfMark.stopTask("NettyClientStream$Sink.writeHeaders"); } }
Example 9
Source File: ServerCallImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void close(Status status, Metadata trailers) { PerfMark.startTask("ServerCall.close", tag); try { closeInternal(status, trailers); } finally { PerfMark.stopTask("ServerCall.close", tag); } }
Example 10
Source File: NettyServerHandler.java From grpc-java with Apache License 2.0 | 5 votes |
private void cancelStream(ChannelHandlerContext ctx, CancelServerStreamCommand cmd, ChannelPromise promise) { PerfMark.startTask("NettyServerHandler.cancelStream", cmd.stream().tag()); PerfMark.linkIn(cmd.getLink()); try { // Notify the listener if we haven't already. cmd.stream().transportReportStatus(cmd.reason()); // Terminate the stream. encoder().writeRstStream(ctx, cmd.stream().id(), Http2Error.CANCEL.code(), promise); } finally { PerfMark.stopTask("NettyServerHandler.cancelStream", cmd.stream().tag()); } }
Example 11
Source File: AsyncSink.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void write(Buffer source, long byteCount) throws IOException { checkNotNull(source, "source"); if (closed) { throw new IOException("closed"); } PerfMark.startTask("AsyncSink.write"); try { synchronized (lock) { buffer.write(source, byteCount); if (writeEnqueued || flushEnqueued || buffer.completeSegmentByteCount() <= 0) { return; } writeEnqueued = true; } serializingExecutor.execute(new WriteRunnable() { final Link link = PerfMark.linkOut(); @Override public void doRun() throws IOException { PerfMark.startTask("WriteRunnable.runWrite"); PerfMark.linkIn(link); Buffer buf = new Buffer(); try { synchronized (lock) { buf.write(buffer, buffer.completeSegmentByteCount()); writeEnqueued = false; } sink.write(buf, buf.size()); } finally { PerfMark.stopTask("WriteRunnable.runWrite"); } } }); } finally { PerfMark.stopTask("AsyncSink.write"); } }
Example 12
Source File: ServerCallImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void sendHeaders(Metadata headers) { PerfMark.startTask("ServerCall.sendHeaders", tag); try { sendHeadersInternal(headers); } finally { PerfMark.stopTask("ServerCall.sendHeaders", tag); } }
Example 13
Source File: PerfMarkUtil.java From perfmark with Apache License 2.0 | 5 votes |
public static <T> T recordTaskResult(String taskName, Tag tag, Supplier<T> cmd) { PerfMark.startTask(taskName, tag); try { return cmd.get(); } finally { PerfMark.stopTask(taskName, tag); } }
Example 14
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void start(Listener<RespT> observer, Metadata headers) { PerfMark.startTask("ClientCall.start", tag); try { startInternal(observer, headers); } finally { PerfMark.stopTask("ClientCall.start", tag); } }
Example 15
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
private Action0 onCompletedStarted(Link onCompletedLinkIn) { return () -> { PerfMark.startTask(filter.filterName(), "onCompleted"); try { PerfMark.linkIn(onCompletedLinkIn); onCompletedLinkOut.compareAndSet(null, PerfMark.linkOut()); } finally { PerfMark.stopTask(filter.filterName(), "onCompleted"); } }; }
Example 16
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void request(int numMessages) { PerfMark.startTask("ClientCall.request", tag); try { checkState(stream != null, "Not started"); checkArgument(numMessages >= 0, "Number requested must be non-negative"); stream.request(numMessages); } finally { PerfMark.stopTask("ClientCall.request", tag); } }
Example 17
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public void headersRead(final Metadata headers) { PerfMark.startTask("ClientStreamListener.headersRead", tag); final Link link = PerfMark.linkOut(); final class HeadersRead extends ContextRunnable { HeadersRead() { super(context); } @Override public void runInContext() { PerfMark.startTask("ClientCall$Listener.headersRead", tag); PerfMark.linkIn(link); try { runInternal(); } finally { PerfMark.stopTask("ClientCall$Listener.headersRead", tag); } } private void runInternal() { if (closed) { return; } try { observer.onHeaders(headers); } catch (Throwable t) { Status status = Status.CANCELLED.withCause(t).withDescription("Failed to read headers"); stream.cancel(status); close(status, new Metadata()); } } } try { callExecutor.execute(new HeadersRead()); } finally { PerfMark.stopTask("ClientStreamListener.headersRead", tag); } }
Example 18
Source File: PerfMarkUtil.java From perfmark with Apache License 2.0 | 4 votes |
@MustBeClosed public static TaskRecorder recordTask(String taskName) { PerfMark.startTask(taskName); return () -> PerfMark.stopTask(taskName); }
Example 19
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public void onReady() { if (method.getType().clientSendsOneMessage()) { return; } PerfMark.startTask("ClientStreamListener.onReady", tag); final Link link = PerfMark.linkOut(); final class StreamOnReady extends ContextRunnable { StreamOnReady() { super(context); } @Override public void runInContext() { PerfMark.startTask("ClientCall$Listener.onReady", tag); PerfMark.linkIn(link); try { runInternal(); } finally { PerfMark.stopTask("ClientCall$Listener.onReady", tag); } } private void runInternal() { try { observer.onReady(); } catch (Throwable t) { Status status = Status.CANCELLED.withCause(t).withDescription("Failed to call onReady."); stream.cancel(status); close(status, new Metadata()); } } } try { callExecutor.execute(new StreamOnReady()); } finally { PerfMark.stopTask("ClientStreamListener.onReady", tag); } }
Example 20
Source File: WriteQueue.java From grpc-java with Apache License 2.0 | 4 votes |
/** * Process the queue of commands and dispatch them to the stream. This method is only * called in the event loop */ private void flush() { PerfMark.startTask("WriteQueue.periodicFlush"); try { QueuedCommand cmd; int i = 0; boolean flushedOnce = false; while ((cmd = queue.poll()) != null) { cmd.run(channel); if (++i == DEQUE_CHUNK_SIZE) { i = 0; // Flush each chunk so we are releasing buffers periodically. In theory this loop // might never end as new events are continuously added to the queue, if we never // flushed in that case we would be guaranteed to OOM. PerfMark.startTask("WriteQueue.flush0"); try { channel.flush(); } finally { PerfMark.stopTask("WriteQueue.flush0"); } flushedOnce = true; } } // Must flush at least once, even if there were no writes. if (i != 0 || !flushedOnce) { PerfMark.startTask("WriteQueue.flush1"); try { channel.flush(); } finally { PerfMark.stopTask("WriteQueue.flush1"); } } } finally { PerfMark.stopTask("WriteQueue.periodicFlush"); // Mark the write as done, if the queue is non-empty after marking trigger a new write. scheduled.set(false); if (!queue.isEmpty()) { scheduleFlush(); } } }