/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName * - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn ("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartEpochTimeMilliIfKnown(), event.getStartTimeNano(), event.getEndTimeNano())); }
/** * Convenient method to end the client execution without logging the awsRequestMetrics. */ private void endClientExecution(AWSRequestMetrics awsRequestMetrics, RequestConfig requestConfig, Request<?> request, Response<?> response) { if (request != null) { awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector metricCollector = findRequestMetricCollector(requestConfig); metricCollector.collectMetrics(request, response); awsRequestMetrics.log(); } }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method * in a try-finally block. * * @param loggingAwsRequestMetrics deprecated and ignored */ protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, @Deprecated boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector c = findRequestMetricCollector( request.getOriginalRequest().getRequestMetricCollector()); c.collectMetrics(request, response); awsRequestMetrics.log(); } }
publishProgress(listener, ProgressEventType.CLIENT_REQUEST_SUCCESS_EVENT); awsRequestMetrics.endEvent(AwsClientSideMonitoringMetrics.ApiCallLatency); awsRequestMetrics.getTimingInfo().endTiming(); afterResponse(response); return response;
/** * Convenient method to end the client execution without logging the awsRequestMetrics. */ private void endClientExecution(AWSRequestMetrics awsRequestMetrics, RequestConfig requestConfig, Request<?> request, Response<?> response) { if (request != null) { awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector metricCollector = findRequestMetricCollector(requestConfig); metricCollector.collectMetrics(request, response); awsRequestMetrics.log(); } }
/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName * - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn ("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartEpochTimeMilliIfKnown(), event.getStartTimeNano(), event.getEndTimeNano())); }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method * in a try-finally block. * * @param loggingAwsRequestMetrics deprecated and ignored */ protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, @Deprecated boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector c = findRequestMetricCollector( request.getOriginalRequest().getRequestMetricCollector()); c.collectMetrics(request, response); awsRequestMetrics.log(); } }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method in a * try-finally block. * * @param loggingAwsRequestMetrics true to LOG the awsRequestMetrics; false * otherwise. * @deprecated metrics is deprecated */ @Deprecated protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); final RequestMetricCollector c = findRequestMetricCollector(request); c.collectMetrics(request, response); } if (loggingAwsRequestMetrics) { awsRequestMetrics.log(); } }
/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartTimeNano(), event.getEndTimeNano())); }
response = executeHelper(request, responseHandler, errorResponseHandler, executionContext); final TimingInfo timingInfo = awsRequestMetrics.getTimingInfo().endTiming(); afterResponse(request, requestHandler2s, response, timingInfo); return response;
publishProgress(listener, ProgressEventType.CLIENT_REQUEST_SUCCESS_EVENT); awsRequestMetrics.endEvent(AwsClientSideMonitoringMetrics.ApiCallLatency); awsRequestMetrics.getTimingInfo().endTiming(); afterResponse(response); return response;
@Test public void startEndTimingIfKnown() { // Start timing final long startTimeNano = System.nanoTime(); final long startTimeMilli = System.currentTimeMillis(); TimingInfo ti = TimingInfo.startTimingFullSupport(); assertTrue(ti.isStartEpochTimeMilliKnown()); assertTrue(ti.getStartTimeNano() >= startTimeNano); assertTrue(ti.getStartEpochTimeMilliIfKnown().longValue() >= startTimeMilli); // End time is not known assertFalse(ti.isEndTimeKnown()); assertNull(ti.getEndTimeNanoIfKnown()); assertNull(ti.getEndEpochTimeMilliIfKnown()); assertNull(ti.getTimeTakenMillisIfKnown()); // End timing ti.endTiming(); assertTrue(ti.isEndTimeKnown()); assertTrue(ti.getEndTimeNanoIfKnown().longValue() >= startTimeNano); assertTrue(ti.getEndEpochTimeMilliIfKnown().longValue() >= startTimeMilli); assertTrue(ti.getEndEpochTimeMilli() == ti.getEndEpochTimeMilliIfKnown().longValue()); assertTrue(ti.getTimeTakenMillisIfKnown().longValue() >= 0); }
/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName * - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn ("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartTimeNano(), event.getEndTimeNano())); }
/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartTimeNano(), event.getEndTimeNano())); }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method in a * try-finally block. * * @param loggingAwsRequestMetrics true to LOG the awsRequestMetrics; false * otherwise. * @deprecated metrics is deprecated */ @Deprecated protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); final RequestMetricCollector c = findRequestMetricCollector(request); c.collectMetrics(request, response); } if (loggingAwsRequestMetrics) { awsRequestMetrics.log(); } }
/** * Convenient method to end the client execution without logging the awsRequestMetrics. */ private void endClientExecution(AWSRequestMetrics awsRequestMetrics, RequestConfig requestConfig, Request<?> request, Response<?> response) { if (request != null) { awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector metricCollector = findRequestMetricCollector(requestConfig); metricCollector.collectMetrics(request, response); awsRequestMetrics.log(); } }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method * in a try-finally block. * * @param loggingAwsRequestMetrics deprecated and ignored */ protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, @Deprecated boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); RequestMetricCollector c = findRequestMetricCollector( request.getOriginalRequest().getRequestMetricCollector()); c.collectMetrics(request, response); awsRequestMetrics.log(); } }
/** * Common routine to end a client AWS request/response execution and collect * the request metrics. Caller of this routine is responsible for starting * the event for {@link Field#ClientExecuteTime} and call this method in a * try-finally block. * * @param loggingAwsRequestMetrics true to LOG the awsRequestMetrics; false * otherwise. * @deprecated metrics is deprecated */ @Deprecated protected final void endClientExecution( AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, boolean loggingAwsRequestMetrics) { if (request != null) { awsRequestMetrics.endEvent(Field.ClientExecuteTime); awsRequestMetrics.getTimingInfo().endTiming(); final RequestMetricCollector c = findRequestMetricCollector(request); c.collectMetrics(request, response); } if (loggingAwsRequestMetrics) { awsRequestMetrics.log(); } }
@Test public void startEndTiming() { // Start timing final long startTimeNano = System.nanoTime(); final long startTimeMilli = System.currentTimeMillis(); TimingInfo[] tis = { TimingInfo.startTimingFullSupport(), TimingInfo.startTiming() }; for (TimingInfo ti : tis) { assertTrue(ti.isStartEpochTimeMilliKnown()); assertTrue(ti.getStartTimeNano() >= startTimeNano); assertTrue(ti.getStartEpochTimeMilli() >= startTimeMilli); // End time is not known assertFalse(ti.isEndTimeKnown()); assertTrue(ti.getEndTimeNano() == UNKNOWN); assertTrue(ti.getEndEpochTimeMilli() == UNKNOWN); assertTrue(ti.getEndTime() == ti.getEndEpochTimeMilli()); assertTrue(ti.getTimeTakenMillis() == UNKNOWN); assertTrue(ti.getElapsedTimeMillis() == UNKNOWN); // End timing ti.endTiming(); assertTrue(ti.isEndTimeKnown()); assertTrue(ti.getEndTimeNano() >= startTimeNano); assertTrue(ti.getEndEpochTimeMilli() >= startTimeMilli); assertTrue(ti.getEndTime() == ti.getEndEpochTimeMilli()); assertTrue(ti.getTimeTakenMillis() >= 0); assertTrue(ti.getElapsedTimeMillis() >= 0); } }
/** * End an event which was previously started. Once ended, log how much time * the event took. It is illegal to end an Event that was not started. It is * good practice to endEvent in a finally block. See Also startEvent. * * @param eventName - The name of the event to start */ @Override public void endEvent(String eventName) { TimingInfo event = eventsBeingProfiled.get(eventName); /* Somebody tried to end an event that was not started. */ if (event == null) { LogFactory.getLog(getClass()).warn("Trying to end an event which was never started: " + eventName); return; } event.endTiming(); this.timingInfo.addSubMeasurement( eventName, TimingInfo.unmodifiableTimingInfo( event.getStartTimeNano(), event.getEndTimeNano())); }