All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.freefair.spring.okhttp.autoconfigure.metrics.OkHttpMetricsProperties Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package io.freefair.spring.okhttp.autoconfigure.metrics;

import io.micrometer.core.instrument.binder.okhttp3.OkHttpConnectionPoolMetrics;
import io.micrometer.core.instrument.binder.okhttp3.OkHttpMetricsEventListener;
import lombok.Data;
import okhttp3.Request;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Lars Grefer
 * @see OkHttpMetricsEventListener
 * @see OkHttpMetricsAutoConfiguration
 */
@Data
@ConfigurationProperties("okhttp.metrics")
public class OkHttpMetricsProperties {

    private boolean enabled = true;

    /**
     * Name for the metrics.
     */
    private String name = "okhttp";

    /**
     * Whether to include the {@code host} tag.
     *
     * @see OkHttpMetricsEventListener.Builder#includeHostTag(boolean)
     */
    private boolean includeHostTag = true;

    /**
     * Tag keys for {@link Request#tag()} or {@link Request#tag(Class)}.
     *
     * @see OkHttpMetricsEventListener.Builder#requestTagKeys(Iterable)
     */
    private List requestTagKeys = new ArrayList<>();

    /**
     * @see OkHttpMetricsEventListener.Builder#tags(Iterable)
     */
    private Map tags = new HashMap<>();

    @NestedConfigurationProperty
    private final ConnectionPoolMetricsProperties pool = new ConnectionPoolMetricsProperties();

    /**
     * @see OkHttpConnectionPoolMetrics
     */
    @Data
    public static class ConnectionPoolMetricsProperties {

        private boolean enabled = true;

        /**
         * @see OkHttpConnectionPoolMetrics#namePrefix
         */
        private String namePrefix = "okhttp.pool";

        /**
         * @see OkHttpConnectionPoolMetrics#tags
         */
        private Map tags = new HashMap<>();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy