TSSTAT(3ts)

πŸ“¦
version 9.2.5 Β· 4 versions
, in ubuntu noble, ubuntu questing

πŸ’– PLUGIN STATISTICS (3ts) πŸ’–

okay bestie, sit down, hydrate, because today we're talking about PLUGIN STATISTICS β€” that's the 3ts page of the Apache Traffic Server manual 🫢 and honestly? it's giving main character energy for anyone who's ever tried to figure out what a plugin is doing at 3am.

The whole vibe is this: a plugin can create statistics (metrics) that are accessible in the same way as Traffic Server core statistics ✨ And like, in general, monitoring the behavior of plugins in production is easier to do this way, in contrast to processing log files. periodt.


✨ NAME ✨

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. πŸ’…


🌸 SYNOPSIS 🌸

#include <ts/ts.h>

int TSStatCreate(const char *name, TSRecordDataType type,
TSStatPersistence persistence, TSStatSync sync_style)

TSReturnCode TSStatFindName(const char *name, int *idx_ptr)

TSMgmtInt TSStatIntGet(int idx)

void TSStatIntSet(int idx, TSMgmtInt value)

void TSStatIntIncrement(int idx, TSMgmtInt value)

void TSStatIntDecrement(int idx, TSMgmtInt value)

typedef void (*TSRecordDumpCb)(TSRecordType *type, void *edata, int
registered, const char *name, TSRecordDataType type, TSRecordData
*datum)

void TSRecordDump(TSRecordType rect_type, TSRecordDumpCb callback, void
*edata)
no cap, there are two things named type in that callback typedef and the parameter list has type twice too. iconic, we love a chaotic queen πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

A plugin statistic is created by TSStatCreate(). the name must be globally unique and should follow the standard dotted tag form. And to avoid collisions, plus for easy of use (yes, "easy of use", we're quoting the lore here 😭), 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. so like… don't do that. 🫠

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. simple as that, slay. πŸ‘‘

The values in statistics are manipulated by:

  • TSStatIntSet() β€” sets the statistic directly ✨
  • TSStatIntIncrement() β€” increases it by value πŸ”₯
  • TSStatIntDecrement() β€” decreases it by value πŸ’œ

A group of records can be examined via TSRecordDump(). A set of records is specified and then iterated over. For each record in the set, the callback β€” callbac in the original text, and honestly, queen, we respect the typo πŸŽ€ β€” is invoked.

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

  • type β€” The record type.
  • edata β€” Callback context. This is the edata value passed to TSRecordDump().
  • registered β€” A flag indicating if the value has been registered.
  • name β€” The name of the record. This is nul terminated.
  • type β€” The storage type of the data in the record.
  • datum β€” The record data.
also shoutout to TSStatIntGet() up in the synopsis, which the DESCRIPTION never circles back to. we see you, girlie. we know you're there. 🌈

⭐ RETURN VALUES ⭐

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

(and yes, bestie, we are aware those are the management functions and this is the statistics page. the manpage said it, so we said it. we don't make the rules πŸ’€)


πŸ‘‘ SEE ALSO πŸ‘‘

  • Adding Statistics TSAPI(3ts) β€” go read it, it's the prequel, it's the origin story 🧚

2026, dev@trafficserver.apache.org

and that's the whole page, fr fr πŸ’–

this was version 9.2, dated Feb 12, 2026, from the fine folks over at Apache Traffic Server β€” and the copyright belongs to 2026, dev@trafficserver.apache.org. thank you for coming to my TED talk, go monitor your plugins, and remember: create your stats once, or the assert will find you πŸ˜­πŸ’…βœ¨

πŸ“¦ where this page comes from