diff options
| author | chenzizhan <[email protected]> | 2023-11-14 14:56:03 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-11-14 14:56:03 +0800 |
| commit | 706e5dc7a2615cec0dc2a1bf9eddcff9a391855c (patch) | |
| tree | 51aa2294b9ed76567ddff3f6ca1a8e82f6113d96 /src/fieldstat_easy.c | |
| parent | a619037a074dd57398d185cd2e2154bb991d2c2b (diff) | |
fieldstat easy name
Diffstat (limited to 'src/fieldstat_easy.c')
| -rw-r--r-- | src/fieldstat_easy.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index fc56bd5..61f17c5 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -114,7 +114,7 @@ void *fs_easy_output_thread(void *arg) // return void * for pthread_create check return NULL; // return void * for pthread_create check only } -struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const struct fieldstat_tag *tags, size_t n_tag) { +struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, const struct fieldstat_tag *tags, size_t n_tag) { struct fieldstat_easy *fse = calloc(1, sizeof(struct fieldstat_easy)); fse->fsu = malloc(sizeof(struct fs_easy_thread) * max_thread_num); fse->max_thread_num = max_thread_num; @@ -123,7 +123,13 @@ struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const struct field fse->accumulate = fieldstat_fork(fse->delta); fse->exporter = fieldstat_json_exporter_new(); - fieldstat_json_exporter_set_global_tag(fse->exporter, tags, n_tag); + if (tags != NULL && n_tag > 0) { + fieldstat_json_exporter_set_global_tag(fse->exporter, tags, n_tag); + } + if (name != NULL) { + fieldstat_json_exporter_set_name(fse->exporter, name); + } + pthread_spin_init(&fse->outputting_lock, PTHREAD_PROCESS_PRIVATE); for (int i = 0; i < max_thread_num; i++) { |
