本文整理汇总了Java中com.nike.riposte.metrics.codahale.EndpointMetricsHandler类的典型用法代码示例。如果您正苦于以下问题:Java EndpointMetricsHandler类的具体用法?Java EndpointMetricsHandler怎么用?Java EndpointMetricsHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EndpointMetricsHandler类属于com.nike.riposte.metrics.codahale包,在下文中一共展示了EndpointMetricsHandler类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructor_calls_initEndpointAndServerConfigMetrics_on_metricsListener
import com.nike.riposte.metrics.codahale.EndpointMetricsHandler; //导入依赖的package包/类
@Test
public void constructor_calls_initEndpointAndServerConfigMetrics_on_metricsListener() {
// given
AppServerConfig asc = new AppServerConfig(configForTesting);
// expect
EndpointMetricsHandler emh = ((CodahaleMetricsListener) asc.metricsListener()).getEndpointMetricsHandler();
assertThat(emh).isInstanceOf(EndpointMetricsHandlerDefaultImpl.class);
assertThat(((EndpointMetricsHandlerDefaultImpl)emh).getEndpointRequestsTimers()).isNotEmpty();
}
示例2: generateCodahaleMetricsListenerWithSignalFxSupport
import com.nike.riposte.metrics.codahale.EndpointMetricsHandler; //导入依赖的package包/类
public CodahaleMetricsListener generateCodahaleMetricsListenerWithSignalFxSupport(
SignalFxReporterFactory signalFxReporterFactory,
CodahaleMetricsCollector metricsCollector,
MetricDimensionConfigurator<Timer> customRequestTimerDimensionConfigurator,
ExtraRequestLogicHandler extraRequestLogicHandler
) {
MetricRegistry metricRegistry = metricsCollector.getMetricRegistry();
// Use the identity function if customRequestTimerDimensionConfigurator is null.
if (customRequestTimerDimensionConfigurator == null)
customRequestTimerDimensionConfigurator = METRIC_DIMENSION_CONFIGURATOR_IDENTITY;
// Create the SignalFxEndpointMetricsHandler with the customRequestTimerDimensionConfigurator and
// extraRequestLogicHandler specifics.
EndpointMetricsHandler endpointMetricsHandler = new SignalFxEndpointMetricsHandler(
signalFxReporterFactory.getReporter(metricRegistry).getMetricMetadata(),
metricRegistry,
// Use a rolling window reservoir with the same window as the reporting frequency,
// to prevent the dashboards from producing false or misleading data.
new SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder(signalFxReporterFactory.getInterval(),
signalFxReporterFactory.getTimeUnit()),
// Do the default request latency timer dimensions, chained with customRequestTimerDimensionConfigurator
// for any custom logic desired.
DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR
.chainedWith(customRequestTimerDimensionConfigurator)
) {
@Override
public void handleRequest(RequestInfo<?> requestInfo, ResponseInfo<?> responseInfo,
HttpProcessingState httpState,
int responseHttpStatusCode, int responseHttpStatusCodeXXValue,
long requestElapsedTimeMillis) {
// Do the normal endpoint stuff.
super.handleRequest(requestInfo, responseInfo, httpState, responseHttpStatusCode,
responseHttpStatusCodeXXValue,
requestElapsedTimeMillis);
// Do any extra logic (if desired).
if (extraRequestLogicHandler != null) {
extraRequestLogicHandler.handleExtraRequestLogic(
requestInfo, responseInfo, httpState, responseHttpStatusCode, responseHttpStatusCodeXXValue,
requestElapsedTimeMillis
);
}
}
};
return CodahaleMetricsListener
.newBuilder(metricsCollector)
.withEndpointMetricsHandler(endpointMetricsHandler)
// The metric names should be basic with no prefix - SignalFx dimensions do the job normally covered
// by metric name prefixes.
.withServerStatsMetricNamingStrategy(CodahaleMetricsListener.MetricNamingStrategy.defaultNoPrefixImpl())
.withServerConfigMetricNamingStrategy(CodahaleMetricsListener.MetricNamingStrategy.defaultNoPrefixImpl())
// Histograms should use a rolling window reservoir with the same window as the reporting frequency,
// otherwise the dashboards will produce false or misleading data.
.withRequestAndResponseSizeHistogramSupplier(
() -> new Histogram(
new SlidingTimeWindowReservoir(signalFxReporterFactory.getInterval(),
signalFxReporterFactory.getTimeUnit())
)
)
.build();
}