diff options
| author | chenzizhan <[email protected]> | 2024-08-01 14:55:40 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-08-01 14:55:40 +0800 |
| commit | 6d98df95300d5ddae1111c559cae96e52e38d900 (patch) | |
| tree | 1a3907fabc92ca4f577c5a847ffd6e3b1a9312f2 /src/fieldstat_easy.c | |
| parent | ae4c5b46775a0b730169c2d3b13190163d50f262 (diff) | |
name of exporter is also a global tag
Diffstat (limited to 'src/fieldstat_easy.c')
| -rw-r--r-- | src/fieldstat_easy.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c index 3adc5da..19092ea 100644 --- a/src/fieldstat_easy.c +++ b/src/fieldstat_easy.c @@ -127,13 +127,23 @@ struct fieldstat_easy *fieldstat_easy_new(int max_thread_num, const char *name, fse->accumulate = fieldstat_fork(fse->delta); fse->exporter = fieldstat_json_exporter_new(); - if (global_dimensions != NULL && n_dimension > 0) { - fieldstat_json_exporter_set_global_dimension(fse->exporter, global_dimensions, n_dimension); - } + if (name != NULL) { - fieldstat_json_exporter_set_name(fse->exporter, name); + struct field *global_dimension_more = malloc(sizeof(struct field) * (n_dimension + 1)); + global_dimension_more[0].key = "__name__"; + global_dimension_more[0].value_str = name; + global_dimension_more[0].type = FIELD_VALUE_CSTRING; + for (size_t i = 0; i < n_dimension; i++) { + global_dimension_more[i + 1] = global_dimensions[i]; + } + fieldstat_json_exporter_set_global_dimension(fse->exporter, global_dimension_more, n_dimension + 1); + free(global_dimension_more); + } else { + if (global_dimensions != NULL && n_dimension > 0) { + fieldstat_json_exporter_set_global_dimension(fse->exporter, global_dimensions, n_dimension); + } } - + pthread_spin_init(&fse->outputting_lock, PTHREAD_PROCESS_PRIVATE); for (int i = 0; i < max_thread_num; i++) { |
