Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions plugins/compress/compress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ compress_transform_init(TSCont contp, Data *data)
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
}

static int compress_stat_bytes_in = TS_ERROR;

static void
init_compress_stats()
{
if (TS_ERROR == compress_stat_bytes_in) {
compress_stat_bytes_in =
TSStatCreate("proxy.process.plugin.compress.bytes_in", TS_RECORDDATATYPE_COUNTER, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to the new metrics API, since TSStatCreate is deprecated for 11.

}
}

static void
compress_transform_one(Data *data, TSIOBufferReader upstream_reader, int amount)
{
Expand All @@ -371,6 +382,10 @@ compress_transform_one(Data *data, TSIOBufferReader upstream_reader, int amount)
upstream_length = amount;
}

if (TS_ERROR != compress_stat_bytes_in) {
TSStatIntIncrement(compress_stat_bytes_in, upstream_length);
}

#if HAVE_ZSTD_H
if (data->compression_type & COMPRESSION_TYPE_ZSTD && (data->compression_algorithms & ALGORITHM_ZSTD)) {
Zstd::transform_one(data, upstream_buffer, upstream_length);
Expand Down Expand Up @@ -1032,6 +1047,8 @@ TSPluginInit(int argc, const char *argv[])
fatal("the compress plugin failed to register");
}

Compress::init_compress_stats();

info("TSPluginInit %s", argv[0]);

if (!Compress::global_hidden_header_name) {
Expand Down Expand Up @@ -1060,6 +1077,7 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
{
CHECK_REMAP_API_COMPATIBILITY(api_info, errbuf, errbuf_size);
info("The compress plugin is successfully initialized");
Compress::init_compress_stats();
return TS_SUCCESS;
}

Expand Down