Skip to content

Commit 9d86501

Browse files
cosmo0920edsiper
authored andcommitted
encoding: splunk_hec: Add metric_type field for histogram and summary
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent a2ba37a commit 9d86501

File tree

2 files changed

+73
-46
lines changed

2 files changed

+73
-46
lines changed

src/cmt_encode_splunk_hec.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ static void format_metric_name(cfl_sds_t *buf, struct cmt_map *map, const char *
8484
cfl_sds_destroy(metric_name);
8585
}
8686

87+
static void format_metric_type(cfl_sds_t *buf, const char *metric_type_name)
88+
{
89+
int len = 0;
90+
char tmp[32];
91+
92+
len = snprintf(tmp, sizeof(tmp) - 1, ",\"metric_type\":\"%s\"", metric_type_name);
93+
cfl_sds_cat_safe(buf, tmp, len);
94+
}
95+
8796
static void append_metric_value(cfl_sds_t *buf, struct cmt_map *map,
8897
struct cmt_metric *metric)
8998
{
@@ -312,6 +321,9 @@ static void format_histogram_bucket(struct cmt_splunk_hec_context *context, cfl_
312321
/* Format labels */
313322
format_metric_labels(context, buf, map, metric);
314323

324+
/* Format metric type */
325+
format_metric_type(buf, "Histogram");
326+
315327
/* Close parenthesis for fields */
316328
cfl_sds_cat_safe(buf, "}", 1);
317329

@@ -341,6 +353,9 @@ static void format_histogram_bucket(struct cmt_splunk_hec_context *context, cfl_
341353
/* Format labels */
342354
format_metric_labels(context, buf, map, metric);
343355

356+
/* Format metric type */
357+
format_metric_type(buf, "Histogram");
358+
344359
/* Close parenthesis for fields */
345360
cfl_sds_cat_safe(buf, "}", 1);
346361

@@ -370,6 +385,9 @@ static void format_histogram_bucket(struct cmt_splunk_hec_context *context, cfl_
370385
/* Format labels */
371386
format_metric_labels(context, buf, map, metric);
372387

388+
/* Format metric type */
389+
format_metric_type(buf, "Histogram");
390+
373391
/* Close parenthesis for fields */
374392
cfl_sds_cat_safe(buf, "}", 1);
375393

@@ -432,6 +450,9 @@ static void format_summary_metric(struct cmt_splunk_hec_context *context, cfl_sd
432450
/* Format labels */
433451
format_metric_labels(context, buf, map, metric);
434452

453+
/* Format metric type */
454+
format_metric_type(buf, "Summary");
455+
435456
/* Close parenthesis for fields */
436457
cfl_sds_cat_safe(buf, "}", 1);
437458

@@ -462,6 +483,9 @@ static void format_summary_metric(struct cmt_splunk_hec_context *context, cfl_sd
462483
/* Format labels */
463484
format_metric_labels(context, buf, map, metric);
464485

486+
/* Format metric type */
487+
format_metric_type(buf, "Summary");
488+
465489
/* Close parenthesis for fields */
466490
cfl_sds_cat_safe(buf, "}", 1);
467491

@@ -491,6 +515,9 @@ static void format_summary_metric(struct cmt_splunk_hec_context *context, cfl_sd
491515
/* Format labels */
492516
format_metric_labels(context, buf, map, metric);
493517

518+
/* Format metric type */
519+
format_metric_type(buf, "Summary");
520+
494521
/* Close parenthesis for fields */
495522
cfl_sds_cat_safe(buf, "}", 1);
496523

0 commit comments

Comments
 (0)