.. include:: header.rst

`home`__

__ reference.html

.. contents:: Table of contents
  :depth: 2
  :backlinks: none

.. raw:: html

	<a name="stats_metric"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+stats_metric&labels=documentation&body=Documentation+under+heading+%22class+stats_metric%22+could+be+improved">report issue</a>]</span>



stats_metric
------------

Declared in "`libtorrent/session_stats.hpp`__"


__ include/libtorrent/session_stats.hpp

describes one statistics metric from the `session`__. For more information,
see the `session statistics`__ section.


__ reference-Session.html#session
__ manual-ref.html#session-statistics


.. parsed-literal::
	

	struct stats_metric
	{
	   char const* name;
	   int value_index;
	   metric_type_t type;
	};

.. raw:: html

	<a name="name"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:stats_metric%3A%3A%5Bname%5D&labels=documentation&body=Documentation+under+heading+%22stats_metric%3A%3A%5Bname%5D%22+could+be+improved">report issue</a>]</span>


name
	the name of the counter or gauge
	


.. raw:: html

	<a name="value_index"></a>
	<a name="type"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:stats_metric%3A%3A%5Bvalue_index+type%5D&labels=documentation&body=Documentation+under+heading+%22stats_metric%3A%3A%5Bvalue_index+type%5D%22+could+be+improved">report issue</a>]</span>


value_index type
	the index into the `session`__ stats array, where the underlying value of
	this counter or gauge is found. The `session`__ stats array is part of the
	`session_stats_alert`__ object.
	

__ reference-Session.html#session
__ reference-Session.html#session
__ reference-Alerts.html#session_stats_alert

.. raw:: html

	<a name="counters"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:class+counters&labels=documentation&body=Documentation+under+heading+%22class+counters%22+could+be+improved">report issue</a>]</span>



counters
--------

Declared in "`libtorrent/performance_counters.hpp`__"


__ include/libtorrent/performance_counters.hpp





.. parsed-literal::
	

	struct counters
	{
	   **counters** () ;
	   **counters** (counters const&) ;
	   counters& **operator=** (counters const&) & ;
	   std::int64_t **inc_stats_counter** (int c, std\:\:int64\_t value = 1) ;
	   std::int64_t **operator[]** (int i) const ;
	   void **set_value** (int c, std\:\:int64\_t value) ;
	   void **blend_stats_counter** (int c, std\:\:int64\_t value, int ratio) ;
	};

.. raw:: html

	<a name="operator[]()"></a>
	<a name="inc_stats_counter()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:counters%3A%3A%5Boperator%5B%5D%28%29+inc_stats_counter%28%29%5D&labels=documentation&body=Documentation+under+heading+%22counters%3A%3A%5Boperator%5B%5D%28%29+inc_stats_counter%28%29%5D%22+could+be+improved">report issue</a>]</span>



operator[]() inc_stats_counter()
................................

.. parsed-literal::
	
	std::int64_t **inc_stats_counter** (int c, std\:\:int64\_t value = 1) ;
	std::int64_t **operator[]** (int i) const ;
	

returns the new value



.. raw:: html

	<a name="session_stats_metrics()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:session_stats_metrics%28%29&labels=documentation&body=Documentation+under+heading+%22session_stats_metrics%28%29%22+could+be+improved">report issue</a>]</span>



session_stats_metrics()
-----------------------

Declared in "`libtorrent/session_stats.hpp`__"


__ include/libtorrent/session_stats.hpp

.. parsed-literal::
	
	std::vector<stats_metric> **session_stats_metrics** ();
	

This free function returns the list of available metrics exposed by
libtorrent's statistics API. Each metric has a name and a *value index*.
The value index is the index into the array in `session_stats_alert`__ where
this metric's value can be found when the `session`__ stats is sampled (by
calling `post_session_stats()`__).


__ reference-Alerts.html#session_stats_alert
__ reference-Session.html#session
__ reference-Session.html#post_session_stats()

.. raw:: html

	<a name="find_metric_idx()"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:find_metric_idx%28%29&labels=documentation&body=Documentation+under+heading+%22find_metric_idx%28%29%22+could+be+improved">report issue</a>]</span>



find_metric_idx()
-----------------

Declared in "`libtorrent/session_stats.hpp`__"


__ include/libtorrent/session_stats.hpp

.. parsed-literal::
	
	int **find_metric_idx** (string\_view name);
	

given a name of a metric, this function returns the counter index of it,
or -1 if it could not be found. The counter index is the index into the
values array returned by `session_stats_alert`__.


__ reference-Alerts.html#session_stats_alert

.. raw:: html

	<a name="metric_type_t"></a>

.. raw:: html

	<span class="report-issue">[<a href="http://github.com/arvidn/libtorrent/issues/new?title=docs:enum+metric_type_t&labels=documentation&body=Documentation+under+heading+%22enum+metric_type_t%22+could+be+improved">report issue</a>]</span>



enum metric_type_t
------------------

Declared in "`libtorrent/session_stats.hpp`__"


__ include/libtorrent/session_stats.hpp

+---------+-------+-------------+
| name    | value | description |
+=========+=======+=============+
| counter | 0     |             |
+---------+-------+-------------+
| gauge   | 1     |             |
+---------+-------+-------------+





.. _`BEP 3`: https://www.bittorrent.org/beps/bep_0003.html
.. _`BEP 17`: https://www.bittorrent.org/beps/bep_0017.html
.. _extensions: manual-ref.html#extensions
.. _`BEP 52`: https://www.bittorrent.org/beps/bep_0052.html
.. _`BEP 19`: https://www.bittorrent.org/beps/bep_0019.html
.. _`BEP 38`: https://www.bittorrent.org/beps/bep_0038.html
.. _`rate based choking`: manual-ref.html#rate-based-choking
.. _`BEP 42`: https://www.bittorrent.org/beps/bep_0042.html
