Class StatsRegistry
http.<prefix>.downstream_rq_total,
cluster.<name>.upstream_cx_connect_ms, ...), each with the tags its name carries (TagExtractor), for StatsFormatter and StatsdSink to show.
Metrics are made once and then kept: the proxy resolves its own when it starts, per
listener, per cluster and per connection, and keeps them in fields, so counting a request is an
add to a LongAdder, never a lookup by name. Registering a
name again returns the metric already there (of the same kind, or an IllegalArgumentException is thrown). Nothing here takes a lock of its own.
NOOP is the registry of a proxy without metrics (the default): its metrics do
nothing and it keeps none, so the proxy counts unconditionally at no cost. Enable metrics with
HttpProxyServerBootstrap.withMetrics(boolean), or with a registry of
your own, HttpProxyServerBootstrap.withStats(StatsRegistry).
The registry also bounds how many metrics the proxy makes for things whose number is not
fixed: the clusters requests go to (StatsRegistry.Builder.maxClusters, StatsRegistry.Builder.clusterOverflow,
StatsRegistry.Builder.perHostClusters) and the stats scripts make (StatsRegistry.Builder.maxScriptStats).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSettings for aStatsRegistry.static enumWhat happens to a new cluster onceStatsRegistry.Builder.maxClustersclusters have stats. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StatsRegistryA registry whose metrics do nothing and that keeps none; the default of every proxy.static final StringThe name of the cluster that clusters overStatsRegistry.Builder.maxClustersshare. -
Method Summary
Modifier and TypeMethodDescriptionstatic StatsRegistry.Builderbuilder()Returns a builder with the default settings.Returns what happens to clusters beyondmaxClusters().The counter namedname, made the first time.The counter namedname, made the first time withhelp.counter(String name, String help, LongSupplier value) A counter namednamewhose count is read fromvalue, for counts kept elsewhere (such asHttpCache.stats()); it cannot be added to.static StatsRegistrycreate()Returns a registry with the default settings.booleanenabled()Returns whether this registry keeps metrics; false only forNOOP.The gauge namedname, made the first time.The gauge namedname, made the first time withhelp.gauge(String name, String help, LongSupplier value) A gauge namednamewhose value is read fromvalue, for values kept elsewhere (a pool's size, the heap's); it cannot be changed through the gauge.The metric namedname, if registered.The histogram namedname, made the first time with the registry's bounds (StatsRegistry.Builder.histogramBounds, Envoy's by default).The histogram namedname, made the first time withhelpand the registry's bounds.The histogram namedname, made the first time withhelpandbounds.double[]Returns a copy of the bucket bounds of histograms registered without bounds of their own.intReturns how many clusters may have stats of their own.intReturns how many stats scripts may make.metrics()Returns the metrics, sorted by flat name.booleanReturns whether a direct connection's cluster is its server (host_port) rather thandirect.prefix()Returns the prefix of exported names, without separator:envoyby default, as inenvoy_cluster_upstream_rq_total(Prometheus) andenvoy.cluster.direct...(statsd).booleanForgets the metric namedname: it is shown no more, and registering the name again makes a new one.The scope of metrics namedprefix.<name>, which makes at mostmaxStatsof them: for metrics whose names come from outside, such as scripts'.intsize()Returns how many metrics there are.Returns what takes the tags out of flat names.toString()
-
Field Details
-
NOOP
A registry whose metrics do nothing and that keeps none; the default of every proxy. -
OTHER_CLUSTER
The name of the cluster that clusters overStatsRegistry.Builder.maxClustersshare.- See Also:
-
-
Method Details
-
create
Returns a registry with the default settings.- Returns:
- a registry with the default settings
-
builder
Returns a builder with the default settings.- Returns:
- a builder with the default settings
-
enabled
public boolean enabled()Returns whether this registry keeps metrics; false only forNOOP.- Returns:
- whether this registry keeps metrics; false only for
NOOP
-
prefix
Returns the prefix of exported names, without separator:envoyby default, as inenvoy_cluster_upstream_rq_total(Prometheus) andenvoy.cluster.direct...(statsd).- Returns:
- the prefix of exported names, without separator:
envoyby default, as inenvoy_cluster_upstream_rq_total(Prometheus) andenvoy.cluster.direct...(statsd)
-
tagExtractor
Returns what takes the tags out of flat names.- Returns:
- what takes the tags out of flat names
-
maxClusters
public int maxClusters()Returns how many clusters may have stats of their own.- Returns:
- how many clusters may have stats of their own
-
clusterOverflow
Returns what happens to clusters beyondmaxClusters().- Returns:
- what happens to clusters beyond
maxClusters()
-
perHostClusters
public boolean perHostClusters()Returns whether a direct connection's cluster is its server (host_port) rather thandirect.- Returns:
- whether a direct connection's cluster is its server (
host_port) rather thandirect
-
maxScriptStats
public int maxScriptStats()Returns how many stats scripts may make.- Returns:
- how many stats scripts may make
-
histogramBounds
public double[] histogramBounds()Returns a copy of the bucket bounds of histograms registered without bounds of their own.- Returns:
- a copy of the bucket bounds of histograms registered without bounds of their own
-
counter
The counter namedname, made the first time.- Parameters:
name- the flat name- Returns:
- the counter
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
counter
The counter namedname, made the first time withhelp.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELP- Returns:
- the counter
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
counter
A counter namednamewhose count is read fromvalue, for counts kept elsewhere (such asHttpCache.stats()); it cannot be added to.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELPvalue- reads the count; called whenever the metrics are shown- Returns:
- the counter (the one already registered under
name, if any) - Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
gauge
The gauge namedname, made the first time.- Parameters:
name- the flat name- Returns:
- the gauge
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
gauge
The gauge namedname, made the first time withhelp.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELP- Returns:
- the gauge
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
gauge
A gauge namednamewhose value is read fromvalue, for values kept elsewhere (a pool's size, the heap's); it cannot be changed through the gauge.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELPvalue- reads the value; called whenever the metrics are shown- Returns:
- the gauge (the one already registered under
name, if any) - Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
histogram
The histogram namedname, made the first time with the registry's bounds (StatsRegistry.Builder.histogramBounds, Envoy's by default).- Parameters:
name- the flat name- Returns:
- the histogram
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
histogram
The histogram namedname, made the first time withhelpand the registry's bounds.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELP- Returns:
- the histogram
- Throws:
IllegalArgumentException- if the name is not valid, or names a metric of another kind
-
histogram
The histogram namedname, made the first time withhelpandbounds.- Parameters:
name- the flat namehelp- a one-line description for Prometheus's# HELPbounds- the buckets' upper bounds, ascending and finite- Returns:
- the histogram (the one already registered under
name, with its bounds, if any) - Throws:
IllegalArgumentException- if the name is not valid, names a metric of another kind, or the bounds are not ascending and finite
-
scope
The scope of metrics namedprefix.<name>, which makes at mostmaxStatsof them: for metrics whose names come from outside, such as scripts'. The same prefix gives the same scope (with the limit it was first asked with).- Parameters:
prefix- the names' prefix, without the dotmaxStats- how many metrics the scope may make- Returns:
- the scope
- Throws:
IllegalArgumentException- if the prefix is not a valid name or the limit is negative
-
get
The metric namedname, if registered.- Parameters:
name- the flat name- Returns:
- the metric, or null
-
remove
Forgets the metric namedname: it is shown no more, and registering the name again makes a new one. Whoever holds the old one may still use it, to no effect.- Parameters:
name- the flat name- Returns:
- whether there was such a metric
-
metrics
Returns the metrics, sorted by flat name.- Returns:
- the metrics, sorted by flat name
-
size
public int size()Returns how many metrics there are.- Returns:
- how many metrics there are
-
toString
-