当前位置: 首页>>代码示例>>Java>>正文


Java EndpointMetricsHandler类代码示例

本文整理汇总了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();
}
 
开发者ID:Nike-Inc,项目名称:riposte-microservice-template,代码行数:11,代码来源:AppServerConfigTest.java

示例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();
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:65,代码来源:MetricsConfigurationHelper.java


注:本文中的com.nike.riposte.metrics.codahale.EndpointMetricsHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。