summaryrefslogtreecommitdiff
path: root/fs_demo.c
diff options
context:
space:
mode:
authorzhangyang <[email protected]>2024-11-05 06:11:18 -0500
committerzhangyang <[email protected]>2024-11-05 06:11:18 -0500
commitf860f62caa791c5469bd8e63bb9305e01af86dd8 (patch)
treee8437916f490e1c8d5a40d8b123d023e7321db98 /fs_demo.c
parent975a811b04834efca79990ec826c6a1924cb7bc9 (diff)
Refactor fs_demo.c: update fieldstat includes, modify counter increment logic, and adjust tag definitionsHEADmain
Diffstat (limited to 'fs_demo.c')
-rw-r--r--fs_demo.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/fs_demo.c b/fs_demo.c
index 9afb1a8..ec4ded8 100644
--- a/fs_demo.c
+++ b/fs_demo.c
@@ -1,4 +1,5 @@
-#include "fieldstat/fieldstat_easy.h"
+#include <fieldstat/fieldstat_easy.h>
+
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
@@ -24,9 +25,10 @@ void *thread_function(void *arg)
int hdr_id = td->hdr_id;
while (1)
{
- fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag1, 1, 100);
+ fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag1, 1, 1);
fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag2, 1, 2);
- fieldstat_easy_histogram_record(fse, thread_id, hdr_id, td->tag1, 1, rand() % 10000);
+ sleep(1);
+ // fieldstat_easy_histogram_record(fse, thread_id, hdr_id, td->tag1, 1, rand() % 10000);
}
return NULL;
}
@@ -41,18 +43,19 @@ int main()
tmptag.value_longlong = 1;
global_tags[0] = tmptag;
- struct field tag1 = {"direction", FIELD_VALUE_INTEGER, "incoming"};
- struct field tag2 = {"direction", FIELD_VALUE_INTEGER, "outgoing"};
+ struct field tag1 = {"direction", FIELD_VALUE_CSTRING, {.value_str = "incoming"}};
+ struct field tag2 = {"direction", FIELD_VALUE_CSTRING, {.value_str = "outgoing"}};
- struct fieldstat_easy *fse = fieldstat_easy_new(N_THREADS, NULL, global_tags, 1);
- int counter_id = fieldstat_easy_register_counter(fse, "incoming bytes");
- int hdr_id = fieldstat_easy_register_histogram(
- fse, "delay",
- 1, // min trackable value, no less than 1. The value less than this value will still be recorded, with an
- // unpromising precision.
- 10000, // max trackable value, the value larger than this value will be recorded as the max value.
- 1); // precision, value less than 10 ^ precision will be recorded keeping exact precision. The larger recorded
- // value is, the less precise of its count is.
+ struct fieldstat_easy *fse = fieldstat_easy_new(N_THREADS, "n23", global_tags, 1);
+ int counter_id = fieldstat_easy_register_counter(fse, "bytes");
+ int hdr_id = 0;
+ // int hdr_id = fieldstat_easy_register_histogram(
+ // fse, "delay",
+ // 1, // min trackable value, no less than 1. The value less than this value will still be recorded, with an
+ // // unpromising precision.
+ // 10000, // max trackable value, the value larger than this value will be recorded as the max value.
+ // 1); // precision, value less than 10 ^ precision will be recorded keeping exact precision. The larger recorded
+ // // value is, the less precise of its count is.
int output_interval_seconds = 1;
fieldstat_easy_enable_auto_output(fse, FILENAME,
output_interval_seconds); // FILENAME is the same as the one you set in python.