386 lines
20 KiB
HTML
386 lines
20 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Protocols Reference</title>
|
|
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
|
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
|
<meta charset="utf-8">
|
|
<script src="js/jquery.min.js" defer></script>
|
|
<script src="js/jazzy.js" defer></script>
|
|
|
|
<script src="js/lunr.min.js" defer></script>
|
|
<script src="js/typeahead.jquery.js" defer></script>
|
|
<script src="js/jazzy.search.js" defer></script>
|
|
</head>
|
|
<body>
|
|
|
|
<a name="//apple_ref/swift/Section/Protocols" class="dashAnchor"></a>
|
|
|
|
<a title="Protocols Reference"></a>
|
|
|
|
<header class="header">
|
|
<p class="header-col header-col--primary">
|
|
<a class="header-link" href="index.html">
|
|
CoreMetrics 2.2.0 Docs
|
|
</a>
|
|
(83% documented)
|
|
</p>
|
|
|
|
<div class="header-col--secondary">
|
|
<form role="search" action="search.json">
|
|
<input type="text" placeholder="Search documentation" data-typeahead>
|
|
</form>
|
|
</div>
|
|
|
|
<p class="header-col header-col--secondary">
|
|
<a class="header-link" href="https://github.com/apple/swift-metrics">
|
|
<img class="header-icon" src="img/gh.png" alt="GitHub"/>
|
|
View on GitHub
|
|
</a>
|
|
</p>
|
|
|
|
<p class="header-col header-col--secondary">
|
|
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-metrics%2Fdocs%2F2.2.0%2FCoreMetrics%2Fdocsets%2FCoreMetrics.xml">
|
|
<img class="header-icon" src="img/dash.png" alt="Dash"/>
|
|
Install in Dash
|
|
</a>
|
|
</p>
|
|
</header>
|
|
|
|
<p class="breadcrumbs">
|
|
<a class="breadcrumb" href="index.html">CoreMetrics Reference</a>
|
|
<img class="carat" src="img/carat.png" alt=""/>
|
|
Protocols Reference
|
|
</p>
|
|
|
|
<div class="content-wrapper">
|
|
<nav class="navigation">
|
|
<ul class="nav-groups">
|
|
<li class="nav-group-name">
|
|
<a class="nav-group-name-link" href="Classes.html">Classes</a>
|
|
<ul class="nav-group-tasks">
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/Counter.html">Counter</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/FloatingPointCounter.html">FloatingPointCounter</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/Gauge.html">Gauge</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/MultiplexMetricsHandler.html">MultiplexMetricsHandler</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/NOOPMetricsHandler.html">NOOPMetricsHandler</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/Recorder.html">Recorder</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Classes/Timer.html">Timer</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="nav-group-name">
|
|
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
|
|
<ul class="nav-group-tasks">
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Enums/MetricsSystem.html">MetricsSystem</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="nav-group-name">
|
|
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
|
|
<ul class="nav-group-tasks">
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Protocols/CounterHandler.html">CounterHandler</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Protocols/FloatingPointCounterHandler.html">FloatingPointCounterHandler</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Protocols/MetricsFactory.html">MetricsFactory</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Protocols/RecorderHandler.html">RecorderHandler</a>
|
|
</li>
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Protocols/TimerHandler.html">TimerHandler</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="nav-group-name">
|
|
<a class="nav-group-name-link" href="Structs.html">Structures</a>
|
|
<ul class="nav-group-tasks">
|
|
<li class="nav-group-task">
|
|
<a class="nav-group-task-link" href="Structs/TimeUnit.html">TimeUnit</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<article class="main-content">
|
|
|
|
<section class="section">
|
|
<div class="section-content top-matter">
|
|
<h1>Protocols</h1>
|
|
<p>The following protocols are available globally.</p>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<section class="section">
|
|
<div class="section-content">
|
|
<div class="task-group">
|
|
<div class="task-name-container">
|
|
<a name="/Library%20SPI%2C%20intended%20to%20be%20implemented%20by%20backend%20libraries"></a>
|
|
<a name="//apple_ref/swift/Section/Library SPI, intended to be implemented by backend libraries" class="dashAnchor"></a>
|
|
<div class="section-name-container">
|
|
<a class="section-name-link" href="#/Library%20SPI%2C%20intended%20to%20be%20implemented%20by%20backend%20libraries"></a>
|
|
<h3 class="section-name"><span>Library SPI, intended to be implemented by backend libraries</span>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
<ul class="item-container">
|
|
<li class="item">
|
|
<div>
|
|
<code>
|
|
<a name="/s:11CoreMetrics0B7FactoryP"></a>
|
|
<a name="//apple_ref/swift/Protocol/MetricsFactory" class="dashAnchor"></a>
|
|
<a class="token" href="#/s:11CoreMetrics0B7FactoryP">MetricsFactory</a>
|
|
</code>
|
|
</div>
|
|
<div class="height-container">
|
|
<div class="pointer-container"></div>
|
|
<section class="section">
|
|
<div class="pointer"></div>
|
|
<div class="abstract">
|
|
<p>The <code>MetricsFactory</code> is the bridge between the <code><a href="Enums/MetricsSystem.html">MetricsSystem</a></code> and the metrics backend implementation.
|
|
<code>MetricsFactory</code>‘s role is to initialize concrete implementations of the various metric types:</p>
|
|
|
|
<ul>
|
|
<li><code><a href="Classes/Counter.html">Counter</a></code> -> <code><a href="Protocols/CounterHandler.html">CounterHandler</a></code></li>
|
|
<li><code><a href="Classes/FloatingPointCounter.html">FloatingPointCounter</a></code> -> <code><a href="Protocols/FloatingPointCounterHandler.html">FloatingPointCounterHandler</a></code></li>
|
|
<li><code><a href="Classes/Recorder.html">Recorder</a></code> -> <code><a href="Protocols/RecorderHandler.html">RecorderHandler</a></code></li>
|
|
<li><p><code><a href="Classes/Timer.html">Timer</a></code> -> <code><a href="Protocols/TimerHandler.html">TimerHandler</a></code></p></li>
|
|
</ul><div class="aside aside-warning">
|
|
<p class="aside-title">Warning</p>
|
|
<p>This type is an implementation detail and should not be used directly, unless implementing your own metrics backend.
|
|
To use the SwiftMetrics API, please refer to the documentation of <code><a href="Enums/MetricsSystem.html">MetricsSystem</a></code>.</p>
|
|
|
|
</div>
|
|
<h1 id='destroying-metrics' class='heading'>Destroying metrics</h1>
|
|
|
|
<p>Since <em>some</em> metrics implementations may need to allocate (potentially “heavy”) resources for metrics, destroying
|
|
metrics offers a signal to libraries when a metric is “known to never be updated again.”</p>
|
|
|
|
<p>While many metrics are bound to the entire lifetime of an application and thus never need to be destroyed eagerly,
|
|
some metrics have well defined unique life-cycles, and it may be beneficial to release any resources held by them
|
|
more eagerly than awaiting the application’s termination. In such cases, a library or application should invoke
|
|
a metric’s appropriate <code>destroy()</code> method, which in turn results in the corresponding handler that it is backed by
|
|
to be passed to <code>destroyCounter(handler:)</code>, <code>destroyRecorder(handler:)</code> or <code>destroyTimer(handler:)</code> where the factory
|
|
can decide to free any corresponding resources.</p>
|
|
|
|
<p>While some libraries may not need to implement this destroying as they may be stateless or similar,
|
|
libraries using the metrics API should always assume a library WILL make use of this signal, and shall not
|
|
neglect calling these methods when appropriate.</p>
|
|
|
|
<a href="Protocols/MetricsFactory.html" class="slightly-smaller">See more</a>
|
|
</div>
|
|
<div class="declaration">
|
|
<h4>Declaration</h4>
|
|
<div class="language">
|
|
<p class="aside-title">Swift</p>
|
|
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">MetricsFactory</span></code></pre>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="slightly-smaller">
|
|
<a href="https://github.com/apple/swift-metrics/tree/2.2.0/Sources/CoreMetrics/Metrics.swift#L524-L581">Show on GitHub</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</li>
|
|
<li class="item">
|
|
<div>
|
|
<code>
|
|
<a name="/s:11CoreMetrics14CounterHandlerP"></a>
|
|
<a name="//apple_ref/swift/Protocol/CounterHandler" class="dashAnchor"></a>
|
|
<a class="token" href="#/s:11CoreMetrics14CounterHandlerP">CounterHandler</a>
|
|
</code>
|
|
</div>
|
|
<div class="height-container">
|
|
<div class="pointer-container"></div>
|
|
<section class="section">
|
|
<div class="pointer"></div>
|
|
<div class="abstract">
|
|
<p>A <code>CounterHandler</code> represents a backend implementation of a <code><a href="Classes/Counter.html">Counter</a></code>.</p>
|
|
|
|
<p>This type is an implementation detail and should not be used directly, unless implementing your own metrics backend.
|
|
To use the SwiftMetrics API, please refer to the documentation of <code><a href="Classes/Counter.html">Counter</a></code>.</p>
|
|
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
|
|
|
|
<p>To implement your own <code>CounterHandler</code> you should respect a few requirements that are necessary so applications work
|
|
as expected regardless of the selected <code>CounterHandler</code> implementation.</p>
|
|
|
|
<ul>
|
|
<li>The <code>CounterHandler</code> must be a <code>class</code>.</li>
|
|
</ul>
|
|
|
|
<a href="Protocols/CounterHandler.html" class="slightly-smaller">See more</a>
|
|
</div>
|
|
<div class="declaration">
|
|
<h4>Declaration</h4>
|
|
<div class="language">
|
|
<p class="aside-title">Swift</p>
|
|
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">CounterHandler</span> <span class="p">:</span> <span class="kt">AnyObject</span></code></pre>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="slightly-smaller">
|
|
<a href="https://github.com/apple/swift-metrics/tree/2.2.0/Sources/CoreMetrics/Metrics.swift#L683-L692">Show on GitHub</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</li>
|
|
<li class="item">
|
|
<div>
|
|
<code>
|
|
<a name="/s:11CoreMetrics27FloatingPointCounterHandlerP"></a>
|
|
<a name="//apple_ref/swift/Protocol/FloatingPointCounterHandler" class="dashAnchor"></a>
|
|
<a class="token" href="#/s:11CoreMetrics27FloatingPointCounterHandlerP">FloatingPointCounterHandler</a>
|
|
</code>
|
|
</div>
|
|
<div class="height-container">
|
|
<div class="pointer-container"></div>
|
|
<section class="section">
|
|
<div class="pointer"></div>
|
|
<div class="abstract">
|
|
<p>A <code>FloatingPointCounterHandler</code> represents a backend implementation of a <code><a href="Classes/FloatingPointCounter.html">FloatingPointCounter</a></code>.</p>
|
|
|
|
<p>This type is an implementation detail and should not be used directly, unless implementing your own metrics backend.
|
|
To use the SwiftMetrics API, please refer to the documentation of <code><a href="Classes/FloatingPointCounter.html">FloatingPointCounter</a></code>.</p>
|
|
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
|
|
|
|
<p>To implement your own <code>FloatingPointCounterHandler</code> you should respect a few requirements that are necessary so applications work
|
|
as expected regardless of the selected <code>FloatingPointCounterHandler</code> implementation.</p>
|
|
|
|
<ul>
|
|
<li>The <code>FloatingPointCounterHandler</code> must be a <code>class</code>.</li>
|
|
</ul>
|
|
|
|
<a href="Protocols/FloatingPointCounterHandler.html" class="slightly-smaller">See more</a>
|
|
</div>
|
|
<div class="declaration">
|
|
<h4>Declaration</h4>
|
|
<div class="language">
|
|
<p class="aside-title">Swift</p>
|
|
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">FloatingPointCounterHandler</span> <span class="p">:</span> <span class="kt">AnyObject</span></code></pre>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="slightly-smaller">
|
|
<a href="https://github.com/apple/swift-metrics/tree/2.2.0/Sources/CoreMetrics/Metrics.swift#L705-L714">Show on GitHub</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</li>
|
|
<li class="item">
|
|
<div>
|
|
<code>
|
|
<a name="/s:11CoreMetrics15RecorderHandlerP"></a>
|
|
<a name="//apple_ref/swift/Protocol/RecorderHandler" class="dashAnchor"></a>
|
|
<a class="token" href="#/s:11CoreMetrics15RecorderHandlerP">RecorderHandler</a>
|
|
</code>
|
|
</div>
|
|
<div class="height-container">
|
|
<div class="pointer-container"></div>
|
|
<section class="section">
|
|
<div class="pointer"></div>
|
|
<div class="abstract">
|
|
<p>A <code>RecorderHandler</code> represents a backend implementation of a <code><a href="Classes/Recorder.html">Recorder</a></code>.</p>
|
|
|
|
<p>This type is an implementation detail and should not be used directly, unless implementing your own metrics backend.
|
|
To use the SwiftMetrics API, please refer to the documentation of <code><a href="Classes/Recorder.html">Recorder</a></code>.</p>
|
|
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
|
|
|
|
<p>To implement your own <code>RecorderHandler</code> you should respect a few requirements that are necessary so applications work
|
|
as expected regardless of the selected <code>RecorderHandler</code> implementation.</p>
|
|
|
|
<ul>
|
|
<li>The <code>RecorderHandler</code> must be a <code>class</code>.</li>
|
|
</ul>
|
|
|
|
<a href="Protocols/RecorderHandler.html" class="slightly-smaller">See more</a>
|
|
</div>
|
|
<div class="declaration">
|
|
<h4>Declaration</h4>
|
|
<div class="language">
|
|
<p class="aside-title">Swift</p>
|
|
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">RecorderHandler</span> <span class="p">:</span> <span class="kt">AnyObject</span></code></pre>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="slightly-smaller">
|
|
<a href="https://github.com/apple/swift-metrics/tree/2.2.0/Sources/CoreMetrics/Metrics.swift#L727-L738">Show on GitHub</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</li>
|
|
<li class="item">
|
|
<div>
|
|
<code>
|
|
<a name="/s:11CoreMetrics12TimerHandlerP"></a>
|
|
<a name="//apple_ref/swift/Protocol/TimerHandler" class="dashAnchor"></a>
|
|
<a class="token" href="#/s:11CoreMetrics12TimerHandlerP">TimerHandler</a>
|
|
</code>
|
|
</div>
|
|
<div class="height-container">
|
|
<div class="pointer-container"></div>
|
|
<section class="section">
|
|
<div class="pointer"></div>
|
|
<div class="abstract">
|
|
<p>A <code>TimerHandler</code> represents a backend implementation of a <code><a href="Classes/Timer.html">Timer</a></code>.</p>
|
|
|
|
<p>This type is an implementation detail and should not be used directly, unless implementing your own metrics backend.
|
|
To use the SwiftMetrics API, please refer to the documentation of <code><a href="Classes/Timer.html">Timer</a></code>.</p>
|
|
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
|
|
|
|
<p>To implement your own <code>TimerHandler</code> you should respect a few requirements that are necessary so applications work
|
|
as expected regardless of the selected <code>TimerHandler</code> implementation.</p>
|
|
|
|
<ul>
|
|
<li>The <code>TimerHandler</code> must be a <code>class</code>.</li>
|
|
</ul>
|
|
|
|
<a href="Protocols/TimerHandler.html" class="slightly-smaller">See more</a>
|
|
</div>
|
|
<div class="declaration">
|
|
<h4>Declaration</h4>
|
|
<div class="language">
|
|
<p class="aside-title">Swift</p>
|
|
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">TimerHandler</span> <span class="p">:</span> <span class="kt">AnyObject</span></code></pre>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="slightly-smaller">
|
|
<a href="https://github.com/apple/swift-metrics/tree/2.2.0/Sources/CoreMetrics/Metrics.swift#L751-L763">Show on GitHub</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
</article>
|
|
</div>
|
|
<section class="footer">
|
|
<p>© 2021 <a class="link" href="https://github.com/apple/swift-metrics" target="_blank" rel="external noopener">SwiftMetrics team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
|
|
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
|
|
</section>
|
|
</body>
|
|
</html>
|