DOKK / manpages / debian 12 / trafficserver-dev / TSStat.3ts.en
PLUGIN STATISTICS(3ts) Apache Traffic Server PLUGIN STATISTICS(3ts)

Plugin Statistics - a plugin can create statistics (metrics) that are accessible in the same way as Traffic Server core statistics. In general monitoring the behavior of plugins in production is easier to do in this way in contrast to processing log files

#include <ts/ts.h>










A plugin statistic is created by TSStatCreate(). The name must be globally unique and should follow the standard dotted tag form. To avoid collisions and for easy of use the first tag should be the plugin name or something easily derived from it. Currently only integers are supported therefore type must be TS_RECORDDATATYPE_INT. The return value is the index of the statistic. In general this should work but if it doesn't it will assert. In particular, creating the same statistic twice will fail in this way, which can happen if statistics are created as part of or based on configuration files and Traffic Server is reloaded.

TSStatFindName() locates a statistic by name. If found the function returns TS_SUCCESS and the value pointed at by idx_ptr is updated to be the index of the statistic. Otherwise it returns TS_ERROR.

The values in statistics are manipulated by TSStatIntSet() to set the statistic directly, TSStatIntIncrement() to increase it by value, and TSStatIntDecrement() to decrease it by value.

A group of records can be examined via TSRecordDump(). A set of records is specified and the iterated over. For each record in the set the callbac callback is invoked.

The records are specified by the TSRecordType. If this is TS_RECORDTYPE_NULL then all records are examined. The callback is passed

The record type.
Callback context. This is the edata value passed to TSRecordDump().
A flag indicating if the value has been registered.
The name of the record. This is nul terminated.
The storage type of the data in the record.
The record data.



TSMgmtStringCreate() and TSMgmtIntCreate() return TS_SUCCESS if the management value was created and TS_ERROR if not.

Adding Statistics TSAPI(3ts)

2023, dev@trafficserver.apache.org

November 2, 2023 9.2