欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

springboot的http.server.requests服務(wù)請(qǐng)求流程源碼

 更新時(shí)間:2023年12月01日 09:31:38   作者:codecraft  
這篇文章主要為大家介紹了springboot的http.server.requests服務(wù)請(qǐng)求流程源碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

本文主要研究一下springboot的http.server.requests

http.server.requests

org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java

public static class Server {
            private final ServerRequest request = new ServerRequest();
            /**
             * Maximum number of unique URI tag values allowed. After the max number of
             * tag values is reached, metrics with additional tag values are denied by
             * filter.
             */
            private int maxUriTags = 100;
            public ServerRequest getRequest() {
                return this.request;
            }
            public int getMaxUriTags() {
                return this.maxUriTags;
            }
            public void setMaxUriTags(int maxUriTags) {
                this.maxUriTags = maxUriTags;
            }
            public static class ServerRequest {
                /**
                 * Name of the metric for received requests.
                 */
                private String metricName = "http.server.requests";
                /**
                 * Whether the trailing slash should be ignored when recording metrics.
                 */
                private boolean ignoreTrailingSlash = true;
                //......
            }   
        }
MetricsProperties.Server.ServerRequest定義了http.server.requests這個(gè)metrics名

WebMvcMetricsAutoConfiguration

org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java

@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({ MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class,
        SimpleMetricsExportAutoConfiguration.class })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnClass(DispatcherServlet.class)
@ConditionalOnBean(MeterRegistry.class)
@EnableConfigurationProperties(MetricsProperties.class)
public class WebMvcMetricsAutoConfiguration {
    private final MetricsProperties properties;
    public WebMvcMetricsAutoConfiguration(MetricsProperties properties) {
        this.properties = properties;
    }
    @Bean
    @ConditionalOnMissingBean(WebMvcTagsProvider.class)
    public DefaultWebMvcTagsProvider webMvcTagsProvider(ObjectProvider<WebMvcTagsContributor> contributors) {
        return new DefaultWebMvcTagsProvider(this.properties.getWeb().getServer().getRequest().isIgnoreTrailingSlash(),
                contributors.orderedStream().collect(Collectors.toList()));
    }
    @Bean
    public FilterRegistrationBean<WebMvcMetricsFilter> webMvcMetricsFilter(MeterRegistry registry,
            WebMvcTagsProvider tagsProvider) {
        ServerRequest request = this.properties.getWeb().getServer().getRequest();
        WebMvcMetricsFilter filter = new WebMvcMetricsFilter(registry, tagsProvider, request.getMetricName(),
                request.getAutotime());
        FilterRegistrationBean<WebMvcMetricsFilter> registration = new FilterRegistrationBean<>(filter);
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
        registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);
        return registration;
    }
    @Bean
    @Order(0)
    public MeterFilter metricsHttpServerUriTagFilter() {
        String metricName = this.properties.getWeb().getServer().getRequest().getMetricName();
        MeterFilter filter = new OnlyOnceLoggingDenyMeterFilter(
                () -> String.format("Reached the maximum number of URI tags for '%s'.", metricName));
        return MeterFilter.maximumAllowableTags(metricName, "uri", this.properties.getWeb().getServer().getMaxUriTags(),
                filter);
    }
    @Bean
    public MetricsWebMvcConfigurer metricsWebMvcConfigurer(MeterRegistry meterRegistry,
            WebMvcTagsProvider tagsProvider) {
        return new MetricsWebMvcConfigurer(meterRegistry, tagsProvider);
    }
}
WebMvcMetricsAutoConfiguration定義了webMvcTagsProvider,可以接收WebMvcTagsContributor對(duì)tag進(jìn)行定制,還注冊(cè)了WebMvcMetricsFilter、MeterFilter、metricsWebMvcConfigurer

DefaultWebMvcTagsProvider

org/springframework/boot/actuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java

public class DefaultWebMvcTagsProvider implements WebMvcTagsProvider {
    private final boolean ignoreTrailingSlash;
    private final List<WebMvcTagsContributor> contributors;
    public DefaultWebMvcTagsProvider() {
        this(false);
    }
    /**
     * Creates a new {@link DefaultWebMvcTagsProvider} that will provide tags from the
     * given {@code contributors} in addition to its own.
     * @param contributors the contributors that will provide additional tags
     * @since 2.3.0
     */
    public DefaultWebMvcTagsProvider(List<WebMvcTagsContributor> contributors) {
        this(false, contributors);
    }
    public DefaultWebMvcTagsProvider(boolean ignoreTrailingSlash) {
        this(ignoreTrailingSlash, Collections.emptyList());
    }
    /**
     * Creates a new {@link DefaultWebMvcTagsProvider} that will provide tags from the
     * given {@code contributors} in addition to its own.
     * @param ignoreTrailingSlash whether trailing slashes should be ignored when
     * determining the {@code uri} tag.
     * @param contributors the contributors that will provide additional tags
     * @since 2.3.0
     */
    public DefaultWebMvcTagsProvider(boolean ignoreTrailingSlash, List<WebMvcTagsContributor> contributors) {
        this.ignoreTrailingSlash = ignoreTrailingSlash;
        this.contributors = contributors;
    }
    @Override
    public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler,
            Throwable exception) {
        Tags tags = Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, response, this.ignoreTrailingSlash),
                WebMvcTags.exception(exception), WebMvcTags.status(response), WebMvcTags.outcome(response));
        for (WebMvcTagsContributor contributor : this.contributors) {
            tags = tags.and(contributor.getTags(request, response, handler, exception));
        }
        return tags;
    }
    @Override
    public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) {
        Tags tags = Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, null, this.ignoreTrailingSlash));
        for (WebMvcTagsContributor contributor : this.contributors) {
            tags = tags.and(contributor.getLongRequestTags(request, handler));
        }
        return tags;
    }
}
DefaultWebMvcTagsProvider實(shí)現(xiàn)了WebMvcTagsProvider接口,其構(gòu)造器可以接收WebMvcTagsContributor,對(duì)tag進(jìn)行定制;默認(rèn)的tag為WebMvcTags.method(method)、WebMvcTags.uri(uri)、WebMvcTags.exception(exception)、WebMvcTags.status(status)、WebMvcTags.outcome(outcome)

WebMvcMetricsFilter

org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java

public class WebMvcMetricsFilter extends OncePerRequestFilter {
    private final MeterRegistry registry;
    private final WebMvcTagsProvider tagsProvider;
    private final String metricName;
    private final AutoTimer autoTimer;
    /**
     * Create a new {@link WebMvcMetricsFilter} instance.
     * @param registry the meter registry
     * @param tagsProvider the tags provider
     * @param metricName the metric name
     * @param autoTimer the auto-timers to apply or {@code null} to disable auto-timing
     * @since 2.2.0
     */
    public WebMvcMetricsFilter(MeterRegistry registry, WebMvcTagsProvider tagsProvider, String metricName,
            AutoTimer autoTimer) {
        this.registry = registry;
        this.tagsProvider = tagsProvider;
        this.metricName = metricName;
        this.autoTimer = autoTimer;
    }
    @Override
    protected boolean shouldNotFilterAsyncDispatch() {
        return false;
    }
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
            throws ServletException, IOException {
        TimingContext timingContext = TimingContext.get(request);
        if (timingContext == null) {
            timingContext = startAndAttachTimingContext(request);
        }
        try {
            filterChain.doFilter(request, response);
            if (!request.isAsyncStarted()) {
                // Only record when async processing has finished or never been started.
                // If async was started by something further down the chain we wait
                // until the second filter invocation (but we'll be using the
                // TimingContext that was attached to the first)
                Throwable exception = (Throwable) request.getAttribute(DispatcherServlet.EXCEPTION_ATTRIBUTE);
                record(timingContext, request, response, exception);
            }
        }
        catch (NestedServletException ex) {
            response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
            record(timingContext, request, response, ex.getCause());
            throw ex;
        }
        catch (ServletException | IOException | RuntimeException ex) {
            record(timingContext, request, response, ex);
            throw ex;
        }
    }
    //......
}
WebMvcMetricsFilter繼承了OncePerRequestFilter,其doFilterInternal方法通過TimingContext來維護(hù)timerSample,然后在filterChain.doFilter(request, response)之后進(jìn)行record

record

private void record(TimingContext timingContext, HttpServletRequest request, HttpServletResponse response,
            Throwable exception) {
        Object handler = getHandler(request);
        Set<Timed> annotations = getTimedAnnotations(handler);
        Timer.Sample timerSample = timingContext.getTimerSample();
        if (annotations.isEmpty()) {
            if (this.autoTimer.isEnabled()) {
                Builder builder = this.autoTimer.builder(this.metricName);
                timerSample.stop(getTimer(builder, handler, request, response, exception));
            }
        }
        else {
            for (Timed annotation : annotations) {
                Builder builder = Timer.builder(annotation, this.metricName);
                timerSample.stop(getTimer(builder, handler, request, response, exception));
            }
        }
    }
    private Timer getTimer(Builder builder, Object handler, HttpServletRequest request, HttpServletResponse response,
            Throwable exception) {
        return builder.tags(this.tagsProvider.getTags(request, response, handler, exception)).register(this.registry);
    }
record方法主要執(zhí)行timerSample.stop(getTimer(builder, handler, request, response, exception))

timerSample

micrometer-core-1.5.9.jar!/io/micrometer/core/instrument/Timer.class

public static class Sample {
        private Tags tags = Tags.empty();
        private final long startTime;
        private final Clock clock;
        Sample(Clock clock) {
            this.clock = clock;
            this.startTime = clock.monotonicTime();
        }
        public long stop(Timer timer) {
            long durationNs = this.clock.monotonicTime() - this.startTime;
            timer.record(durationNs, TimeUnit.NANOSECONDS);
            return durationNs;
        }
        @Incubating(
            since = "1.4.0"
        )
        public long stop(MeterRegistry registry, Builder timerBuilder) {
            return this.stop(timerBuilder.tags((Iterable)this.tags).register(registry));
        }
        @Incubating(
            since = "1.4.0"
        )
        public Sample tags(String... tags) {
            return this.tags((Iterable)Tags.of(tags));
        }
        @Incubating(
            since = "1.4.0"
        )
        public Sample tags(Iterable<Tag> tags) {
            this.tags = this.tags.and(tags);
            return this;
        }
    }
Timer.Sample的stop方法主要執(zhí)行timer.record(durationNs, TimeUnit.NANOSECONDS)

PrometheusTimer

io/micrometer/prometheus/PrometheusTimer.java

public class PrometheusTimer extends AbstractTimer {
    private static final CountAtBucket[] EMPTY_HISTOGRAM = new CountAtBucket[0];
    private final LongAdder count = new LongAdder();
    private final LongAdder totalTime = new LongAdder();
    private final TimeWindowMax max;
    private final HistogramFlavor histogramFlavor;
    @Nullable
    private final Histogram histogram;
    PrometheusTimer(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector, HistogramFlavor histogramFlavor) {
        super(id, clock,
                DistributionStatisticConfig.builder()
                        .percentilesHistogram(false)
                        .serviceLevelObjectives()
                        .build()
                        .merge(distributionStatisticConfig),
                pauseDetector, TimeUnit.SECONDS, false);
        this.histogramFlavor = histogramFlavor;
        this.max = new TimeWindowMax(clock, distributionStatisticConfig);
        if (distributionStatisticConfig.isPublishingHistogram()) {
            switch (histogramFlavor) {
                case Prometheus:
                    histogram = new TimeWindowFixedBoundaryHistogram(clock, DistributionStatisticConfig.builder()
                            .expiry(Duration.ofDays(1825)) // effectively never roll over
                            .bufferLength(1)
                            .build()
                            .merge(distributionStatisticConfig), true);
                    break;
                case VictoriaMetrics:
                    histogram = new FixedBoundaryVictoriaMetricsHistogram();
                    break;
                default:
                    histogram = null;
                    break;
            }
        } else {
            histogram = null;
        }
    }
    @Override
    protected void recordNonNegative(long amount, TimeUnit unit) {
        count.increment();
        long nanoAmount = TimeUnit.NANOSECONDS.convert(amount, unit);
        totalTime.add(nanoAmount);
        max.record(nanoAmount, TimeUnit.NANOSECONDS);
        if (histogram != null)
            histogram.recordLong(TimeUnit.NANOSECONDS.convert(amount, unit));
    }
    @Override
    public long count() {
        return count.longValue();
    }
    @Override
    public double totalTime(TimeUnit unit) {
        return TimeUtils.nanosToUnit(totalTime.doubleValue(), unit);
    }
    @Override
    public double max(TimeUnit unit) {
        return max.poll(unit);
    }
    public HistogramFlavor histogramFlavor() {
        return histogramFlavor;
    }
    /**
     * For Prometheus we cannot use the histogram counts from HistogramSnapshot, as it is based on a
     * rolling histogram. Prometheus requires a histogram that accumulates values over the lifetime of the app.
     *
     * @return Cumulative histogram buckets.
     */
    public CountAtBucket[] histogramCounts() {
        return histogram == null ? EMPTY_HISTOGRAM : histogram.takeSnapshot(0, 0, 0).histogramCounts();
    }
    @Override
    public HistogramSnapshot takeSnapshot() {
        HistogramSnapshot snapshot = super.takeSnapshot();
        if (histogram == null) {
            return snapshot;
        }
        return new HistogramSnapshot(snapshot.count(),
                snapshot.total(),
                snapshot.max(),
                snapshot.percentileValues(),
                histogramCounts(),
                snapshot::outputSummary);
    }
}
PrometheusTimer繼承了AbstractTimer,默認(rèn)histogram為null

PrometheusMeterRegistry

io/micrometer/prometheus/PrometheusMeterRegistry.java

protected io.micrometer.core.instrument.Timer newTimer(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector) {
        PrometheusTimer timer = new PrometheusTimer(id, clock, distributionStatisticConfig, pauseDetector, prometheusConfig.histogramFlavor());
        applyToCollector(id, (collector) ->
                addDistributionStatisticSamples(distributionStatisticConfig, collector, timer, tagValues(id), false));
        return timer;
    }
PrometheusMeterRegistry的newTimer創(chuàng)建的是PrometheusTimer,同時(shí)applyToCollector調(diào)用了addDistributionStatisticSamples

addDistributionStatisticSamples

private void addDistributionStatisticSamples(DistributionStatisticConfig distributionStatisticConfig, MicrometerCollector collector,
                                                 HistogramSupport histogramSupport, List<String> tagValues, boolean forLongTaskTimer) {
        collector.add(tagValues, (conventionName, tagKeys) -> {
            Stream.Builder<Collector.MetricFamilySamples.Sample> samples = Stream.builder();
            HistogramSnapshot histogramSnapshot = histogramSupport.takeSnapshot();
            ValueAtPercentile[] percentileValues = histogramSnapshot.percentileValues();
            CountAtBucket[] histogramCounts = histogramSnapshot.histogramCounts();
            double count = histogramSnapshot.count();
            if (percentileValues.length > 0) {
                List<String> quantileKeys = new LinkedList<>(tagKeys);
                quantileKeys.add("quantile");
                // satisfies https://prometheus.io/docs/concepts/metric_types/#summary
                for (ValueAtPercentile v : percentileValues) {
                    List<String> quantileValues = new LinkedList<>(tagValues);
                    quantileValues.add(Collector.doubleToGoString(v.percentile()));
                    samples.add(new Collector.MetricFamilySamples.Sample(
                            conventionName, quantileKeys, quantileValues, v.value(TimeUnit.SECONDS)));
                }
            }
            Collector.Type type = distributionStatisticConfig.isPublishingHistogram() ? Collector.Type.HISTOGRAM : Collector.Type.SUMMARY;
            if (histogramCounts.length > 0) {
                // Prometheus doesn't balk at a metric being BOTH a histogram and a summary
                type = Collector.Type.HISTOGRAM;
                List<String> histogramKeys = new LinkedList<>(tagKeys);
                String sampleName = conventionName + "_bucket";
                switch (prometheusConfig.histogramFlavor()) {
                    case Prometheus:
                        histogramKeys.add("le");
                        // satisfies https://prometheus.io/docs/concepts/metric_types/#histogram
                        for (CountAtBucket c : histogramCounts) {
                            final List<String> histogramValues = new LinkedList<>(tagValues);
                            histogramValues.add(Collector.doubleToGoString(c.bucket(TimeUnit.SECONDS)));
                            samples.add(new Collector.MetricFamilySamples.Sample(
                                    sampleName, histogramKeys, histogramValues, c.count()));
                        }
                        // the +Inf bucket should always equal `count`
                        final List<String> histogramValues = new LinkedList<>(tagValues);
                        histogramValues.add("+Inf");
                        samples.add(new Collector.MetricFamilySamples.Sample(
                                sampleName, histogramKeys, histogramValues, count));
                        break;
                    case VictoriaMetrics:
                        histogramKeys.add("vmrange");
                        for (CountAtBucket c : histogramCounts) {
                            final List<String> histogramValuesVM = new LinkedList<>(tagValues);
                            histogramValuesVM.add(FixedBoundaryVictoriaMetricsHistogram.getRangeTagValue(c.bucket()));
                            samples.add(new Collector.MetricFamilySamples.Sample(
                                    sampleName, histogramKeys, histogramValuesVM, c.count()));
                        }
                        break;
                    default:
                        break;
                }
            }
            samples.add(new Collector.MetricFamilySamples.Sample(
                    conventionName + (forLongTaskTimer ? "_active_count" : "_count"), tagKeys, tagValues, count));
            samples.add(new Collector.MetricFamilySamples.Sample(
                    conventionName + (forLongTaskTimer ? "_duration_sum" : "_sum"), tagKeys, tagValues, histogramSnapshot.total(TimeUnit.SECONDS)));
            return Stream.of(new MicrometerCollector.Family(type, conventionName, samples.build()),
                    new MicrometerCollector.Family(Collector.Type.GAUGE, conventionName + "_max", Stream.of(
                            new Collector.MetricFamilySamples.Sample(conventionName + "_max", tagKeys, tagValues,
                                    histogramSnapshot.max(getBaseTimeUnit())))));
        });
    }
addDistributionStatisticSamples會(huì)判斷isPublishingHistogram,是則發(fā)布HISTOGRAM,否則發(fā)布SUMMARY(默認(rèn)為否),之后給samples添加_count及_sum的sample,最后額外添加一個(gè)_max的gauge

示例

示例1

Timer timer = meterRegistry.timer("abc", "a", "b");
timer.record(Duration.of(100, ChronoUnit.SECONDS));

最后產(chǎn)生的metrics如下

# HELP abc_seconds_max  
# TYPE abc_seconds_max gauge
abc_seconds_max{a="b",} 0.0
# HELP abc_seconds  
# TYPE abc_seconds summary
abc_seconds_count{a="b",} 1.0
abc_seconds_sum{a="b",} 100.0

示例2

http.server.requests的prometheus指標(biāo)
# HELP http_server_requests_seconds_max
# TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{}
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{}
http_server_requests_seconds_sum{}

grafana展示

HTTP Server Requests Count

{
              "expr": "http_server_requests_seconds_count{instance=\"$instance\", application=\"$application\"}",
              "format": "time_series",
              "interval": "",
              "intervalFactor": 1,
              "legendFormat": "{{method}} [{{status}}] - {{uri}}",
              "refId": "A"
            }

HTTP Server Requests Sum

{
              "expr": "http_server_requests_seconds_sum{instance=\"$instance\", application=\"$application\"}",
              "format": "time_series",
              "interval": "",
              "intervalFactor": 1,
              "legendFormat": "{{method}} [{{status}}] - {{uri}}",
              "refId": "A"
            }

HTTP Server Requests Max

{
              "expr": "http_server_requests_seconds_max{instance=\"$instance\", application=\"$application\"}",
              "format": "time_series",
              "interval": "",
              "intervalFactor": 1,
              "legendFormat": "{{method}} [{{status}}] - {{uri}}",
              "refId": "A"
            }

Total Requests

{
          "expr": "sum(increase(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\"}[150s]))",
          "format": "time_series",
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "refId": "A"
        }

Request Count

{
          "expr": "irate(http_server_requests_seconds_count{instance=\"$instance\", application=\"$application\", uri!~\".*actuator.*\"}[5m])",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{method}} [{{status}}] - {{uri}} -{{reqPath}}",
          "refId": "A"
        }

Failed Requests

{
          "expr": "sum(increase(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\", uri=~\"$uri\", status!=\"200\"}[$__interval]))",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }

Req / sec

{
          "expr": "sum(irate(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\"}[1m]))",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "refId": "A"
        }

Requests per second

{
          "expr": "rate(http_server_requests_seconds_count{application=\"$application\", instance=\"$instance\"}[1m])",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{method}}-{{status}}-{{uri}}",
          "refId": "A"
        }

Top 10 Most Used API endpoints

{
          "expr": "topk(10, sum by(uri, method) (rate(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\"}[1m])))",
          "format": "time_series",
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "refId": "A"
        }

Error Rate

{
          "expr": "sum(increase(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\", uri=~\"$uri\", status!=\"200\"}[$__interval])) / sum(increase(http_server_requests_seconds_count{application=\"$application\", instance=~\"$instance\", uri=~\"$uri\"}[$__interval])) * 100",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }

Mean response time

{
          "expr": "rate(http_server_requests_seconds_sum{application=\"$application\", instance=\"$instance\"}[1m])/rate(http_server_requests_seconds_count{application=\"$application\", instance=\"$instance\"}[1m])",
          "format": "time_series",
          "instant": false,
          "intervalFactor": 1,
          "legendFormat": "{{method}}-{{status}}-{{uri}}",
          "refId": "A"
        }

Response Time

{
          "expr": "irate(http_server_requests_seconds_sum{instance=\"$instance\", application=\"$application\", exception=\"None\", uri!~\".*actuator.*\"}[5m]) / irate(http_server_requests_seconds_count{instance=\"$instance\", application=\"$application\", exception=\"None\", uri!~\".*actuator.*\"}[5m])",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{method}} [{{status}}] - {{uri}}",
          "refId": "A"
        }

Response time of 50%, 75%, 90%, 95% of requests

{
          "expr": "histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{application=\"$application\", instance=\"$instance\"}[1m])) by (le))",
          "format": "time_series",
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "95%",
          "refId": "A"
        },
        {
          "expr": "histogram_quantile(0.9, sum(rate(http_server_requests_seconds_bucket{application=\"$application\", instance=\"$instance\"}[1m])) by (le))",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "90%",
          "refId": "B"
        },
        {
          "expr": "histogram_quantile(0.75, sum(rate(http_server_requests_seconds_bucket{application=\"$application\", instance=\"$instance\"}[1m])) by (le))",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "75%",
          "refId": "C"
        },
        {
          "expr": "histogram_quantile(0.5, sum(rate(http_server_requests_seconds_bucket{application=\"$application\", instance=\"$instance\"}[1m])) by (le))",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "50%",
          "refId": "D"
        }

小結(jié)

springboot的WebMvcMetricsAutoConfiguration給mvc提供了http.server.requests指標(biāo),類型為timer,當(dāng)輸出到prometheus的時(shí)候,默認(rèn)是沒有開啟Histogram,輸出的是一個(gè)_max的gauge,以及summary類型(_count及_sum)。

以上就是springboot的http.server.requests請(qǐng)求流程源碼解讀的詳細(xì)內(nèi)容,更多關(guān)于springboot http.server.requests請(qǐng)求的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • iReport簡(jiǎn)單使用方法圖文教程

    iReport簡(jiǎn)單使用方法圖文教程

    iReport是一個(gè)能夠創(chuàng)建復(fù)雜報(bào)表的開源項(xiàng)目,它100%使用Java語(yǔ)言編寫,是目前全球最為流行的開源報(bào)表設(shè)計(jì)器,由于它豐富的圖形界面,你能夠很快的創(chuàng)建出任何一種你想要的報(bào)表
    2021-10-10
  • IDEA 中創(chuàng)建SpringBoot 父子模塊的實(shí)現(xiàn)

    IDEA 中創(chuàng)建SpringBoot 父子模塊的實(shí)現(xiàn)

    這篇文章主要介紹了IDEA 中創(chuàng)建SpringBoot 父子模塊的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Java 實(shí)戰(zhàn)項(xiàng)目之家居購(gòu)物商城系統(tǒng)詳解流程

    Java 實(shí)戰(zhàn)項(xiàng)目之家居購(gòu)物商城系統(tǒng)詳解流程

    讀萬(wàn)卷書不如行萬(wàn)里路,只學(xué)書上的理論是遠(yuǎn)遠(yuǎn)不夠的,只有在實(shí)戰(zhàn)中才能獲得能力的提升,本篇文章手把手帶你用Java實(shí)現(xiàn)一個(gè)家居購(gòu)物商城系統(tǒng),大家可以在過程中查缺補(bǔ)漏,提升水平
    2021-11-11
  • 基于java實(shí)現(xiàn)停車場(chǎng)管理系統(tǒng)

    基于java實(shí)現(xiàn)停車場(chǎng)管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了基于java實(shí)現(xiàn)停車場(chǎng)管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • SpringBoot + Mybatis-plus實(shí)戰(zhàn)之Mybatis-plus的一級(jí)緩存、二級(jí)緩存

    SpringBoot + Mybatis-plus實(shí)戰(zhàn)之Mybatis-plus的一級(jí)緩存、二級(jí)緩存

    這篇文章主要介紹了SpringBoot + Mybatis-plus實(shí)戰(zhàn)之Mybatis-plus的一級(jí)緩存、二級(jí)緩存,本文通過實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-12-12
  • Java并發(fā)編程之線程創(chuàng)建介紹

    Java并發(fā)編程之線程創(chuàng)建介紹

    這篇文章主要介紹了Java并發(fā)編程之線程創(chuàng)建,進(jìn)程是代碼在數(shù)據(jù)集合上的一次運(yùn)行活動(dòng),是系統(tǒng)進(jìn)行資源分配和調(diào)度的基本單位,線程則是一個(gè)實(shí)體,一個(gè)進(jìn)程中至少有一個(gè)線程,下文更多相關(guān)內(nèi)容需要的小伙伴可以參考一下
    2022-04-04
  • Java使用跳轉(zhuǎn)結(jié)構(gòu)實(shí)現(xiàn)隊(duì)列和棧流程詳解

    Java使用跳轉(zhuǎn)結(jié)構(gòu)實(shí)現(xiàn)隊(duì)列和棧流程詳解

    這篇文章主要介紹了Java使用跳轉(zhuǎn)結(jié)構(gòu)實(shí)現(xiàn)隊(duì)列和棧流程,連續(xù)結(jié)構(gòu)和跳轉(zhuǎn)結(jié)構(gòu)是數(shù)據(jù)結(jié)構(gòu)中常見的兩種基本數(shù)據(jù)結(jié)構(gòu),而我們本次的主角棧和隊(duì)列都 既可以使用使用跳轉(zhuǎn)結(jié)構(gòu)實(shí)現(xiàn)也可以使用連續(xù)結(jié)構(gòu)實(shí)現(xiàn)
    2023-04-04
  • Java并發(fā)編程總結(jié)——慎用CAS詳解

    Java并發(fā)編程總結(jié)——慎用CAS詳解

    下面小編就為大家?guī)硪黄狫ava并發(fā)編程總結(jié)——慎用CAS詳解。小編覺得挺不錯(cuò)的, 現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-06-06
  • Java 切割字符串的幾種方式集合

    Java 切割字符串的幾種方式集合

    這篇文章主要介紹了Java 切割字符串的幾種方式集合,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • 詳解Java線程池如何統(tǒng)計(jì)線程空閑時(shí)間

    詳解Java線程池如何統(tǒng)計(jì)線程空閑時(shí)間

    這篇文章主要和大家分享一個(gè)面試題:Java線程池是怎么統(tǒng)計(jì)線程空閑時(shí)間?文中的示例代碼講解詳細(xì),對(duì)我們掌握J(rèn)ava有一定幫助,需要的可以參考一下
    2022-11-11

最新評(píng)論