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.
TSStatCreate(const char *name, TSRecordDataType type, TSStatPersistence persistence, TSStatSync sync_style)¶
TSStatFindName(const char *name, int *idx_ptr)¶
typedef void (*
TSRecordDumpCb)(TSRecordType *type, void *edata, int registered, const char *name, TSRecordDataType type, TSRecordData *datum)¶
TSRecordDump(TSRecordType rect_type, TSRecordDumpCb callback, void *edata)¶
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 suppored
therefore type must be
TS_RECORDDATATYPE_INT. The return value is the index of the
statistic. In general thsi 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
The values in statistics are manipulated by
TSStatIntSet() to set the statistic directly,
TSStatIntIncrement() to increase it by value, and
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. This 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
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.
TS_SUCCESS if the management
value was created and
TS_ERROR if not.
Adding Statistics TSAPI(3ts)