Prometheus client for Julia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
50 KiB

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Prometheus.jl · Prometheus.jl</title><meta name="title" content="Prometheus.jl · Prometheus.jl"/><meta property="og:title" content="Prometheus.jl · Prometheus.jl"/><meta property="twitter:title" content="Prometheus.jl · Prometheus.jl"/><meta name="description" content="Documentation for Prometheus.jl."/><meta property="og:description" content="Documentation for Prometheus.jl."/><meta property="twitter:description" content="Documentation for Prometheus.jl."/><meta property="og:url" content="https://fredrikekre.github.io/Prometheus.jl/v1/"/><meta property="twitter:url" content="https://fredrikekre.github.io/Prometheus.jl/v1/"/><link rel="canonical" href="https://fredrikekre.github.io/Prometheus.jl/v1/"/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><div class="docs-main" style="margin: auto; padding-right: 0;"><header class="docs-navbar"><div class="docs-right" style="margin-left: auto;"><a class="docs-navbar-link" href="https://github.com/fredrikekre/Prometheus.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/fredrikekre/Prometheus.jl/blob/master/docs/src/index.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a></div></header><article class="content" id="documenter-page"><h1 id="Prometheus.jl"><a class="docs-heading-anchor" href="#Prometheus.jl">Prometheus.jl</a><a id="Prometheus.jl-1"></a><a class="docs-heading-anchor-permalink" href="#Prometheus.jl" title="Permalink"></a></h1><h2 id="Introduction"><a class="docs-heading-anchor" href="#Introduction">Introduction</a><a id="Introduction-1"></a><a class="docs-heading-anchor-permalink" href="#Introduction" title="Permalink"></a></h2><p>This package is a Julia client for <a href="https://prometheus.io/">Prometheus</a>. If you are not familiar with Prometheus it is recommended to browse the <a href="https://prometheus.io/docs/introduction/overview/">upstream documentation</a>. The documentation here focuses on the Julia client.</p><p>Two of the basic concepts of a Prometheus client are <a href="#Registries">Registries</a> and <a href="#Collectors">Collectors</a>. Registries are collections of collectors, and the collectors are the units responsible to record and capture metrics. Client libraries implement a default registry which all collectors implicity register with, so for basic usage there is no need to interact with a registry (see <a href="#Default-registry">Default registry</a>).</p><p>The third important concept is <a href="#Exposition">Exposition</a> of the collected metrics. Typically metrics are exposed over a HTTP server, as in the <a href="#Quickstart">Quickstart</a>-example just below. See the section about <a href="#Exposition">Exposition</a> for more details and examples on how metrics can be exposed.</p><h2 id="Quickstart"><a class="docs-heading-anchor" href="#Quickstart">Quickstart</a><a id="Quickstart-1"></a><a class="docs-heading-anchor-permalink" href="#Quickstart" title="Permalink"></a></h2><ol><li><p>Install Prometheus.jl and <a href="https://github.com/JuliaWeb/HTTP.jl">HTTP.jl</a> using the package manager:</p><pre><code class="nohighlight hljs">pkg&gt; add Prometheus HTTP</code></pre></li><li><p>Paste the following code into a Julia REPL.</p><pre><code class="language-julia hljs"># Load the packages
using Prometheus, HTTP
# Create a Counter metric
const request_counter = Prometheus.Counter(&quot;request_count&quot;, &quot;Number of handled requests&quot;)
# Start a HTTP server on localhost port 8000 to server the metrics
server = HTTP.listen!(8000) do http
Prometheus.inc(request_counter) # Increment the request counter
return Prometheus.expose(http) # Expose the metrics
end</code></pre></li><li><p>Visit <a href="http://localhost:8000">http://localhost:8000</a> in your browser. You will see something like the following</p><pre><code class="nohighlight hljs"># HELP gc_alloc_bytes_total Total number of allocated bytes
# TYPE gc_alloc_bytes_total counter
gc_alloc_bytes_total 365578814
[...]
# HELP request_count Number of handled requests
# TYPE request_count counter
request_count 1</code></pre><p>The output contains some default metrics related to the running process, as well as the request counter that we added ourselves. Every time you refresh, the counter will increment its value. <code>close(server)</code> will shutdown the server.</p></li></ol><h2 id="Collectors"><a class="docs-heading-anchor" href="#Collectors">Collectors</a><a id="Collectors-1"></a><a class="docs-heading-anchor-permalink" href="#Collectors" title="Permalink"></a></h2><p>This section documents the collectors that are currently supported. This include the &quot;basic&quot; collectors (<a href="#Counter">Counter</a>, <a href="#Gauge">Gauge</a>, <a href="#Histogram">Histogram</a>, <a href="#Summary">Summary</a>) as well as some custom collectors (<a href="#GCCollector">GCCollector</a>, <a href="#ProcessCollector">ProcessCollector</a>). There is also a section on how to implement your own collector, see <a href="#Custom-collectors">Custom collectors</a>.</p><p>Upstream documentation:</p><ul><li><a href="https://prometheus.io/docs/concepts/metric_types/">https://prometheus.io/docs/concepts/metric_types/</a></li><li><a href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#metrics">https://prometheus.io/docs/instrumenting/writing_clientlibs/#metrics</a></li></ul><h3 id="Counter"><a class="docs-heading-anchor" href="#Counter">Counter</a><a id="Counter-1"></a><a class="docs-heading-anchor-permalink" href="#Counter" title="Permalink"></a></h3><p>Quoting the <a href="https://prometheus.io/docs/concepts/metric_types/#counter">upstream documentation</a>:</p><blockquote><p>A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart. For example, you can use a counter to represent the number of requests served, tasks completed, or errors.</p><p>Do not use a counter to expose a value that can decrease. For example, do not use a counter for the number of currently running processes; instead use a gauge.</p></blockquote><h4 id="Counter-API-reference"><a class="docs-heading-anchor" href="#Counter-API-reference">Counter API reference</a><a id="Counter-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#Counter-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.Counter-Tuple{String, String}" href="#Prometheus.Counter-Tuple{String, String}"><code>Prometheus.Counter</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.Counter(name, help; registry=DEFAULT_REGISTRY)</code></pre><p>Construct a Counter collector.</p><p><strong>Arguments</strong></p><ul><li><code>name :: String</code>: the name of the counter metric.</li><li><code>help :: String</code>: the documentation for the counter metric.</li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. If not specified the default registry is used. Pass <code>registry = nothing</code> to skip registration.</li></ul><p><strong>Methods</strong></p><ul><li><a href="#Prometheus.inc-Tuple{Prometheus.Counter, Real}"><code>Prometheus.inc</code></a>: increment the counter.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L159-L175">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.inc-Tuple{Prometheus.Counter, Real}" href="#Prometheus.inc-Tuple{Prometheus.Counter, Real}"><code>Prometheus.inc</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.inc(counter::Counter, v::Real = 1)</code></pre><p>Increment the value of the counter with <code>v</code>. The value defaults to <code>v = 1</code>.</p><p>Throw a <code>Prometheus.ArgumentError</code> if <code>v &lt; 0</code> (a counter must not decrease).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L182-L188">source</a></section></article><h3 id="Gauge"><a class="docs-heading-anchor" href="#Gauge">Gauge</a><a id="Gauge-1"></a><a class="docs-heading-anchor-permalink" href="#Gauge" title="Permalink"></a></h3><p>Quoting the <a href="https://prometheus.io/docs/concepts/metric_types/#gauge">upstream documentation</a>:</p><blockquote><p>A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.</p><p>Gauges are typically used for measured values like temperatures or current memory usage, but also &quot;counts&quot; that can go up and down, like the number of concurrent requests.</p></blockquote><h4 id="Gauge-API-reference"><a class="docs-heading-anchor" href="#Gauge-API-reference">Gauge API reference</a><a id="Gauge-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#Gauge-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.Gauge-Tuple{String, String}" href="#Prometheus.Gauge-Tuple{String, String}"><code>Prometheus.Gauge</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.Gauge(name, help; registry=DEFAULT_REGISTRY)</code></pre><p>Construct a Gauge collector.</p><p><strong>Arguments</strong></p><ul><li><code>name :: String</code>: the name of the gauge metric.</li><li><code>help :: String</code>: the documentation for the gauge metric.</li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. If not specified the default registry is used. Pass <code>registry = nothing</code> to skip registration.</li></ul><p><strong>Methods</strong></p><ul><li><a href="#Prometheus.inc-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.inc</code></a>: increment the value of the gauge.</li><li><a href="#Prometheus.dec-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.dec</code></a>: decrement the value of the gauge.</li><li><a href="#Prometheus.set-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.set</code></a>: set the value of the gauge.</li><li><a href="#Prometheus.set_to_current_time-Tuple{Prometheus.Gauge}"><code>Prometheus.set_to_current_time</code></a>: set the value of the gauge to the current unixtime.</li><li><a href="#Prometheus.@time"><code>Prometheus.@time</code></a>: time a section and set the value of the the gauge to the elapsed time.</li><li><a href="#Prometheus.@inprogress"><code>Prometheus.@inprogress</code></a>: Track number of inprogress operations; increment the gauge when entering the section, decrement it when leaving.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L233-L258">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.inc-Tuple{Prometheus.Gauge, Real}" href="#Prometheus.inc-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.inc</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.inc(gauge::Gauge, v::Real = 1)</code></pre><p>Increment the value of the gauge with <code>v</code>. <code>v</code> defaults to <code>v = 1</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L265-L270">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.dec-Tuple{Prometheus.Gauge, Real}" href="#Prometheus.dec-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.dec</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.dec(gauge::Gauge, v::Real = 1)</code></pre><p>Decrement the value of the gauge with <code>v</code>. <code>v</code> defaults to <code>v = 1</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L276-L281">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.set-Tuple{Prometheus.Gauge, Real}" href="#Prometheus.set-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.set</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.set(gauge::Gauge, v::Real)</code></pre><p>Set the value of the gauge to <code>v</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L287-L291">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.set_to_current_time-Tuple{Prometheus.Gauge}" href="#Prometheus.set_to_current_time-Tuple{Prometheus.Gauge}"><code>Prometheus.set_to_current_time</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.set_to_current_time(gauge::Gauge)</code></pre><p>Set the value of the gauge to the current unixtime in seconds.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L297-L301">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.@time" href="#Prometheus.@time"><code>Prometheus.@time</code></a><span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia hljs">Prometheus.@time collector expr</code></pre><p>Time the evaluation of <code>expr</code> and send the elapsed time in seconds to <code>collector</code>. The specific action depends on the type of collector:</p><ul><li><code>collector :: Gauge</code>: set the value of the gauge to the elapsed time (<a href="#Prometheus.set-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.set</code></a>)</li><li><code>collector :: Histogram</code> and <code>collector :: Summary</code>: add the elapsed time as an observation (<a href="#Prometheus.observe-Tuple{Prometheus.Histogram, Real}"><code>Prometheus.observe</code></a>)</li></ul><p>The expression to time, <code>expr</code>, can be a single expression (for example a function call), or a code block (<code>begin</code>, <code>let</code>, etc), e.g.</p><pre><code class="language-julia hljs">Prometheus.@time collector &lt;expr&gt;
Prometheus.@time collector begin
&lt;expr&gt;
end</code></pre><p>It is also possible to apply the macro to a function <em>definition</em>, i.e.</p><pre><code class="language-julia hljs">Prometheus.@time collector function time_this(args...)
# function body
end</code></pre><p>to time every call to this function (covering all call sites).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L512-L540">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.@inprogress" href="#Prometheus.@inprogress"><code>Prometheus.@inprogress</code></a><span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia hljs">Prometheus.@inprogress collector expr</code></pre><p>Track the number of concurrent in-progress evaluations of <code>expr</code>. From the builtin collectors this is only applicable to the <a href="#Gauge"><code>Gauge</code></a> – the value of the gauge is incremented with 1 when entering the section, and decremented with 1 when exiting the section.</p><p>The expression, <code>expr</code>, can be a single expression (for example a function call), or a code block (<code>begin</code>, <code>let</code>, etc), e.g.</p><pre><code class="language-julia hljs">Prometheus.@inprogress collector &lt;expr&gt;
Prometheus.@inprogress collector begin
&lt;expr&gt;
end</code></pre><p>It is also possible to apply the macro to a function <em>definition</em>, i.e.</p><pre><code class="language-julia hljs">Prometheus.@inprogress collector function track_this(args...)
# function body
end</code></pre><p>to track number of concurrent in-progress calls (covering all call sites).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L549-L574">source</a></section></article><h3 id="Histogram"><a class="docs-heading-anchor" href="#Histogram">Histogram</a><a id="Histogram-1"></a><a class="docs-heading-anchor-permalink" href="#Histogram" title="Permalink"></a></h3><p>Quoting the <a href="https://prometheus.io/docs/concepts/metric_types/#histogram">upstream documentation</a>:</p><blockquote><p>A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.</p></blockquote><h4 id="Histogram-API-reference"><a class="docs-heading-anchor" href="#Histogram-API-reference">Histogram API reference</a><a id="Histogram-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#Histogram-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.Histogram-Tuple{String, String}" href="#Prometheus.Histogram-Tuple{String, String}"><code>Prometheus.Histogram</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.Histogram(name, help; buckets=DEFAULT_BUCKETS, registry=DEFAULT_REGISTRY)</code></pre><p>Construct a Histogram collector.</p><p><strong>Arguments</strong></p><ul><li><code>name :: String</code>: the name of the histogram metric.</li><li><code>help :: String</code>: the documentation for the histogram metric.</li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>buckets :: Vector{Float64}</code>: the upper bounds for the histogram buckets. The buckets must be sorted. <code>Inf</code> will be added as a last bucket if not already included. The default buckets are <code>DEFAULT_BUCKETS = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, Inf]</code>.</li><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. If not specified the default registry is used. Pass <code>registry = nothing</code> to skip registration.</li></ul><p><strong>Methods</strong></p><ul><li><a href="#Prometheus.observe-Tuple{Prometheus.Histogram, Real}"><code>Prometheus.observe</code></a>: add an observation to the histogram.</li><li><a href="#Prometheus.@time"><code>Prometheus.@time</code></a>: time a section and add the elapsed time as an observation.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L360-L380">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.observe-Tuple{Prometheus.Histogram, Real}" href="#Prometheus.observe-Tuple{Prometheus.Histogram, Real}"><code>Prometheus.observe</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.observe(histogram::Histogram, v::Real)</code></pre><p>Add the observed value <code>v</code> to the histogram. This increases the sum and count of the histogram with <code>v</code> and <code>1</code>, respectively, and increments the counter for all buckets containing <code>v</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L390-L396">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.@time-index" href="#Prometheus.@time-index"><code>Prometheus.@time</code></a><span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia hljs">Prometheus.@time collector expr</code></pre><p>Time the evaluation of <code>expr</code> and send the elapsed time in seconds to <code>collector</code>. The specific action depends on the type of collector:</p><ul><li><code>collector :: Gauge</code>: set the value of the gauge to the elapsed time (<a href="#Prometheus.set-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.set</code></a>)</li><li><code>collector :: Histogram</code> and <code>collector :: Summary</code>: add the elapsed time as an observation (<a href="#Prometheus.observe-Tuple{Prometheus.Histogram, Real}"><code>Prometheus.observe</code></a>)</li></ul><p>The expression to time, <code>expr</code>, can be a single expression (for example a function call), or a code block (<code>begin</code>, <code>let</code>, etc), e.g.</p><pre><code class="language-julia hljs">Prometheus.@time collector &lt;expr&gt;
Prometheus.@time collector begin
&lt;expr&gt;
end</code></pre><p>It is also possible to apply the macro to a function <em>definition</em>, i.e.</p><pre><code class="language-julia hljs">Prometheus.@time collector function time_this(args...)
# function body
end</code></pre><p>to time every call to this function (covering all call sites).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L512-L540">source</a></section></article><h3 id="Summary"><a class="docs-heading-anchor" href="#Summary">Summary</a><a id="Summary-1"></a><a class="docs-heading-anchor-permalink" href="#Summary" title="Permalink"></a></h3><p>Quoting the <a href="https://prometheus.io/docs/concepts/metric_types/#summary">upstream documentation</a>:</p><blockquote><p>Similar to a histogram, a summary samples observations (usually things like request durations and response sizes). While it also provides a total count of observations and a sum of all observed values, it calculates configurable quantiles over a sliding time window.</p></blockquote><h4 id="Summary-API-reference"><a class="docs-heading-anchor" href="#Summary-API-reference">Summary API reference</a><a id="Summary-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#Summary-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.Summary-Tuple{String, String}" href="#Prometheus.Summary-Tuple{String, String}"><code>Prometheus.Summary</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.Summary(name, help; registry=DEFAULT_REGISTRY)</code></pre><p>Construct a Summary collector.</p><p><strong>Arguments</strong></p><ul><li><code>name :: String</code>: the name of the summary metric.</li><li><code>help :: String</code>: the documentation for the summary metric.</li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. If not specified the default registry is used. Pass <code>registry = nothing</code> to skip registration.</li></ul><p><strong>Methods</strong></p><ul><li><a href="#Prometheus.observe-Tuple{Prometheus.Summary, Real}"><code>Prometheus.observe</code></a>: add an observation to the summary.</li><li><a href="#Prometheus.@time"><code>Prometheus.@time</code></a>: time a section and add the elapsed time as an observation.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L457-L475">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.observe-Tuple{Prometheus.Summary, Real}" href="#Prometheus.observe-Tuple{Prometheus.Summary, Real}"><code>Prometheus.observe</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.observe(summary::Summary, v::Real)</code></pre><p>Add the observed value <code>v</code> to the summary. This increases the sum and count of the summary with <code>v</code> and <code>1</code>, respectively.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L482-L487">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.@time-index-2" href="#Prometheus.@time-index-2"><code>Prometheus.@time</code></a><span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia hljs">Prometheus.@time collector expr</code></pre><p>Time the evaluation of <code>expr</code> and send the elapsed time in seconds to <code>collector</code>. The specific action depends on the type of collector:</p><ul><li><code>collector :: Gauge</code>: set the value of the gauge to the elapsed time (<a href="#Prometheus.set-Tuple{Prometheus.Gauge, Real}"><code>Prometheus.set</code></a>)</li><li><code>collector :: Histogram</code> and <code>collector :: Summary</code>: add the elapsed time as an observation (<a href="#Prometheus.observe-Tuple{Prometheus.Histogram, Real}"><code>Prometheus.observe</code></a>)</li></ul><p>The expression to time, <code>expr</code>, can be a single expression (for example a function call), or a code block (<code>begin</code>, <code>let</code>, etc), e.g.</p><pre><code class="language-julia hljs">Prometheus.@time collector &lt;expr&gt;
Prometheus.@time collector begin
&lt;expr&gt;
end</code></pre><p>It is also possible to apply the macro to a function <em>definition</em>, i.e.</p><pre><code class="language-julia hljs">Prometheus.@time collector function time_this(args...)
# function body
end</code></pre><p>to time every call to this function (covering all call sites).</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L512-L540">source</a></section></article><h3 id="GCCollector"><a class="docs-heading-anchor" href="#GCCollector">GCCollector</a><a id="GCCollector-1"></a><a class="docs-heading-anchor-permalink" href="#GCCollector" title="Permalink"></a></h3><p>A collector that exports metrics about allocations and garbage collection (for example number of allocations, number of bytes allocated, time spent in garbage collection, etc). These metrics have the <code>julia_gc_</code> prefix in their name.</p><p>A <code>GCCollector</code> is registered automatically with the default registry, see <a href="#Default-registry">Default registry</a> for more details.</p><h4 id="GCCollector-API-reference"><a class="docs-heading-anchor" href="#GCCollector-API-reference">GCCollector API reference</a><a id="GCCollector-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#GCCollector-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.GCCollector-Tuple{}" href="#Prometheus.GCCollector-Tuple{}"><code>Prometheus.GCCollector</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.GCCollector(; registry=DEFAULT_REGISTRY)</code></pre><p>Create a collector that exports metrics about allocations and garbage collection.</p><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. The default registry is used by default. Pass <code>registry = nothing</code> to skip registration.</li></ul><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>A <code>GCCollector</code> is registered automatically with the default registry. If necessary it can be removed by calling</p><pre><code class="language-julia hljs">Prometheus.unregister(Prometheus.DEFAULT_REGISTRY, Prometheus.GC_COLLECTOR)</code></pre></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/gc_collector.jl#L17-L33">source</a></section></article><h3 id="ProcessCollector"><a class="docs-heading-anchor" href="#ProcessCollector">ProcessCollector</a><a id="ProcessCollector-1"></a><a class="docs-heading-anchor-permalink" href="#ProcessCollector" title="Permalink"></a></h3><p>A collector that exports metrics about a running process, for example CPU seconds and metrics about I/O operations. Metrics from this collector have the <code>process_</code> prefix in their name. This collector is only available on Linux since it requires the <code>/proc</code> file system.</p><p>A <code>ProcessCollector</code> for the current process is registered automatically with the default registry, see <a href="#Default-registry">Default registry</a> for more details.</p><h4 id="ProcessCollector-API-reference"><a class="docs-heading-anchor" href="#ProcessCollector-API-reference">ProcessCollector API reference</a><a id="ProcessCollector-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#ProcessCollector-API-reference" title="Permalink"></a></h4><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.ProcessCollector-Tuple{Function}" href="#Prometheus.ProcessCollector-Tuple{Function}"><code>Prometheus.ProcessCollector</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.ProcessCollector(pid; registry=DEFAULT_REGISTRY)</code></pre><p>Create a process collector for the process id given by the <code>pid</code> function. The collector exposes metrics about the process&#39; CPU time, start time, memory usage, file usage, and I/O operations.</p><p><strong>Arguments</strong></p><ul><li><code>pid :: Function</code>: a function returning a process id as a string or integer for which to collect metrics. By default the <code>&quot;self&quot;</code> pid is used, i.e. the current process.</li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. The default registry is used by default. Pass <code>registry = nothing</code> to skip registration.</li></ul><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>A <code>ProcessCollector</code> for the current process is registered automatically with the default registry. If necessary it can be removed by calling</p><pre><code class="language-julia hljs">Prometheus.unregister(Prometheus.DEFAULT_REGISTRY, Prometheus.PROCESS_COLLECTOR)</code></pre></div></div><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>The process collector is currently only available on Linux since it requires the <code>/proc</code> file system. On Windows and macOS this collector will not expose any metrics.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/process_collector.jl#L77-L102">source</a></section></article><h3 id="Custom-collectors"><a class="docs-heading-anchor" href="#Custom-collectors">Custom collectors</a><a id="Custom-collectors-1"></a><a class="docs-heading-anchor-permalink" href="#Custom-collectors" title="Permalink"></a></h3><p>RandomCollector</p><h2 id="Labels"><a class="docs-heading-anchor" href="#Labels">Labels</a><a id="Labels-1"></a><a class="docs-heading-anchor-permalink" href="#Labels" title="Permalink"></a></h2><p>Prometheus allows attaching labels to metrics, see the upstream documentation:</p><ul><li><a href="https://prometheus.io/docs/practices/naming/#labels">https://prometheus.io/docs/practices/naming/#labels</a></li><li><a href="https://prometheus.io/docs/practices/instrumentation/#use-labels">https://prometheus.io/docs/practices/instrumentation/#use-labels</a></li><li><a href="https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels">https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels</a></li></ul><p>In this package labeling of collectors is done with <a href="#Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C"><code>Prometheus.Family</code></a>. A collector family consist of a number of regular collectors, the children, with unique labels.</p><p>A concrete example is a HTTP request <code>Counter</code>, where we might also want to keep track of the target resource and the status code of the request. Such instrumentation can be implemented as follows</p><pre><code class="language-julia hljs"># Custom label struct
struct RequestLabels
target::String
status_code::Int
end
# Create the counter family
request_counter = Prometheus.Family{Prometheus.Counter}(
&quot;http_requests&quot;, &quot;Total number of HTTP requests&quot;, RequestLabels
)
# Extract a Counter for a specific set of labels
counter = Prometheus.labels(request_counter, RequestLabels(&quot;/api&quot;, 200))
# Increment the counter
Prometheus.inc(counter)</code></pre><p>Note that using a custom label struct is optional, refer to the constructor <a href="#Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C"><code>Prometheus.Family</code></a> and <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a> for alternative methods.</p><h3 id="Family-API-reference"><a class="docs-heading-anchor" href="#Family-API-reference">Family API reference</a><a id="Family-API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#Family-API-reference" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C" href="#Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C"><code>Prometheus.Family</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.Family{C}(name, help, args..., label_names; registry=DEFAULT_REGISTRY, kwargs...)</code></pre><p>Create a labeled collector family with labels given by <code>label_names</code>. For every new set of label values encountered a new collector of type <code>C &lt;: Collector</code> will be created, see <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a>.</p><p><strong>Arguments</strong></p><ul><li><code>name :: String</code>: the name of the family metric.</li><li><code>help :: String</code>: the documentation for the family metric.</li><li><code>args...</code>: any extra positional arguments required for <code>C</code>s constructor, see <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a>.</li><li><code>label_names</code>: the label names for the family. Label names can be given as either of the following (typically matching the methods label values will be given later, see <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a>):<ul><li>a tuple of symbols or strings, e.g. <code>(:target, :status_code)</code> or <code>(&quot;target&quot;, &quot;status_code&quot;)</code></li><li>a named tuple type, e.g. <code>@NamedTuple{target::String, status_code::Int}</code> where the names are used as the label names</li><li>a custom struct type, e.g. <code>RequestLabels</code> defined as<pre><code class="language-julia hljs">struct RequestLabels
target::String
status_code::Int
end</code></pre>where the field names are used for the label names.</li></ul></li></ul><p><strong>Keyword arguments</strong></p><ul><li><code>registry :: Prometheus.CollectorRegistry</code>: the registry in which to register the collector. If not specified the default registry is used. Pass <code>registry = nothing</code> to skip registration.</li><li><code>kwargs...</code>: any extra keyword arguments required for <code>C</code>s constructor, see <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a>.</li></ul><p><strong>Methods</strong></p><ul><li><a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a>: get or create the collector for a specific set of labels.</li><li><a href="#Prometheus.remove-Union{Tuple{N}, Tuple{Prometheus.Family{&lt;:Any, N}, Any}} where N"><code>Prometheus.remove</code></a>: remove the collector for a specific set of labels.</li><li><a href="#Prometheus.clear-Tuple{Prometheus.Family}"><code>Prometheus.clear</code></a>: remove all collectors in the family.</li></ul><p><strong>Examples</strong></p><pre><code class="language-julia hljs"># Construct a family of Counters
counter_family = Prometheus.Family{Counter}(
&quot;http_requests&quot;, &quot;Number of HTTP requests&quot;, (:target, :status_code),
)
# Increment the counter for the labels `target=&quot;/api&quot;` and `status_code=200`
Prometheus.inc(Prometheus.labels(counter_family, (target=&quot;/api&quot;, status_code=200)))</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L751-L801">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}" href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.labels(family::Family{C}, label_values) where C</code></pre><p>Get or create the collector of type <code>C</code> from the family corresponding to the labels given by <code>label_values</code>. If no collector exist for the input labels a new one is created by invoking the <code>C</code> constructor as <code>C(name, help, args...; kwargs..., registry=nothing)</code>, where <code>name</code>, <code>help</code>, <code>args...</code>, and <code>kwargs...</code> are the arguments from the family constructor, see <a href="#Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C"><code>Family</code></a>.</p><p>Similarly to when creating the <a href="#Prometheus.Family-Union{Tuple{C}, Tuple{String, String, Any}} where C"><code>Family</code></a>, <code>label_values</code> can be given as either of the following:</p><ul><li>a tuple, e.g. <code>(&quot;/api&quot;, 200)</code></li><li>a named tuple with names matching the label names, e.g.<code>(target=&quot;/api&quot;, status_code=200)</code></li><li>a struct instance with field names matching the label names , e.g. <code>RequestLabels(&quot;/api&quot;, 200)</code></li></ul><p>All non-string values (e.g. <code>200</code> in the examples above) are stringified using <code>string</code>.</p><div class="admonition is-success"><header class="admonition-header">Tip</header><div class="admonition-body"><p><code>Base.getindex</code> is overloaded to have the meaning of <code>Prometheus.labels</code> for the family collector: <code>family[label_values]</code> is equivalent to <code>Prometheus.labels(family, label_values)</code>.</p></div></div><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>This method does an acquire/release of a lock, and a dictionary lookup, to find the collector matching the label names. For typical applications this overhead does not matter (below 100ns for some basic benchmarks) but it is safe to cache the returned collector if required.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L808-L836">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.remove-Union{Tuple{N}, Tuple{Prometheus.Family{&lt;:Any, N}, Any}} where N" href="#Prometheus.remove-Union{Tuple{N}, Tuple{Prometheus.Family{&lt;:Any, N}, Any}} where N"><code>Prometheus.remove</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.remove(family::Family, label_values)</code></pre><p>Remove the collector corresponding to <code>label_values</code>. Effectively this resets the collector since <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a> will recreate the collector when called with the same label names.</p><p>Refer to <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a> for how to specify <code>label_values</code>.</p><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>This method invalidates cached collectors for the label names.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L850-L861">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.clear-Tuple{Prometheus.Family}" href="#Prometheus.clear-Tuple{Prometheus.Family}"><code>Prometheus.clear</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Prometheus.clear(family::Family)</code></pre><p>Remove all collectors in the family. Effectively this resets the collectors since <a href="#Prometheus.labels-Union{Tuple{N}, Tuple{C}, Tuple{Prometheus.Family{C, N}, Any}} where {C, N}"><code>Prometheus.labels</code></a> will recreate them when needed.</p><div class="admonition is-info"><header class="admonition-header">Note</header><div class="admonition-body"><p>This method invalidates all cached collectors.</p></div></div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L868-L876">source</a></section></article><h2 id="Registries"><a class="docs-heading-anchor" href="#Registries">Registries</a><a id="Registries-1"></a><a class="docs-heading-anchor-permalink" href="#Registries" title="Permalink"></a></h2><h3 id="Default-registry"><a class="docs-heading-anchor" href="#Default-registry">Default registry</a><a id="Default-registry-1"></a><a class="docs-heading-anchor-permalink" href="#Default-registry" title="Permalink"></a></h3><h2 id="Exposition"><a class="docs-heading-anchor" href="#Exposition">Exposition</a><a id="Exposition-1"></a><a class="docs-heading-anchor-permalink" href="#Exposition" title="Permalink"></a></h2><p>Prometheus support</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Prometheus.expose" href="#Prometheus.expose"><code>Prometheus.expose</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">Prometheus.expose(file::String, reg::CollectorRegistry = DEFAULT_REGISTRY)</code></pre><p>Export all metrics in <code>reg</code> by writing them to the file <code>file</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L1032-L1036">source</a></section><section><div><pre><code class="language-julia hljs">expose(io::IO, reg::CollectorRegistry = DEFAULT_REGISTRY)</code></pre><p>Export all metrics in <code>reg</code> by writing them to the I/O stream <code>io</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L1048-L1052">source</a></section><section><div><pre><code class="language-julia hljs">expose(http::HTTP.Stream, reg::CollectorRegistry = DEFAULT_REGISTRY; kwargs...)</code></pre><p>Export all metrics in <code>reg</code> by writing them to the HTTP stream <code>http</code>.</p><p>The caller is responsible for checking e.g. the HTTP method and URI target. For HEAD requests this method do not write a body, however.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/fredrikekre/Prometheus.jl/blob/cc82e4286dd23d365a39045182806d8fbecb6e92/src/Prometheus.jl#L1093-L1100">source</a></section></article></article><nav class="docs-footer"><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.0 on <span class="colophon-date" title="Tuesday 16 April 2024 09:13">Tuesday 16 April 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>