mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: promex: Rename dump functions to use the right wording
In Prometheus, a time series a stream of timestamped values belonging to the same metric and the same set of labeled dimensions. Thus the exporter dump time-series and not metrics. Thus, promex_dump_metric(), promex_dump_metric_header() and promex_metric_to_str() functions were renamed to replace "metric"
This commit is contained in:
parent
ca6f0ca82b
commit
c4b723df99
@ -393,7 +393,7 @@ enum promex_srv_state promex_srv_status(struct server *sv)
|
||||
* to process this kind of value). It returns 1 on success. Otherwise, it
|
||||
* returns 0. The buffer's length must not exceed <max> value.
|
||||
*/
|
||||
static int promex_metric_to_str(struct buffer *out, struct field *f, size_t max)
|
||||
static int promex_ts_val_to_str(struct buffer *out, struct field *f, size_t max)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -412,10 +412,11 @@ static int promex_metric_to_str(struct buffer *out, struct field *f, size_t max)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Dump the header lines for <metric>. It is its #HELP and #TYPE strings. It
|
||||
* returns 1 on success. Otherwise, if <out> length exceeds <max>, it returns 0.
|
||||
/* Dump the time series header lines for <metric>. It is its #HELP and #TYPE
|
||||
* strings. It returns 1 on success. Otherwise, if <out> length exceeds <max>,
|
||||
* it returns 0.
|
||||
*/
|
||||
static int promex_dump_metric_header(struct appctx *appctx, const struct promex_metric *metric,
|
||||
static int promex_dump_ts_header(struct appctx *appctx, const struct promex_metric *metric,
|
||||
const struct ist name, const struct ist d,
|
||||
struct ist *out, size_t max)
|
||||
{
|
||||
@ -457,12 +458,12 @@ static int promex_dump_metric_header(struct appctx *appctx, const struct promex_
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Dump the line for <metric>. It starts by the metric name followed by its
|
||||
* labels (proxy name, server name...) between braces and finally its value. If
|
||||
* not already done, the header lines are dumped first. It returns 1 on
|
||||
* success. Otherwise if <out> length exceeds <max>, it returns 0.
|
||||
/* Dump the time series for <metric>. It starts by the metric name followed by
|
||||
* its labels (proxy name, server name...) between braces and finally its
|
||||
* value. If not already done, the header lines are dumped first. It returns 1
|
||||
* on success. Otherwise if <out> length exceeds <max>, it returns 0.
|
||||
*/
|
||||
static int promex_dump_metric(struct appctx *appctx, struct ist prefix,
|
||||
static int promex_dump_ts(struct appctx *appctx, struct ist prefix,
|
||||
const struct ist n, const struct ist desc, const struct promex_metric *metric,
|
||||
struct field *val, struct promex_label *labels, struct ist *out, size_t max)
|
||||
{
|
||||
@ -478,7 +479,7 @@ static int promex_dump_metric(struct appctx *appctx, struct ist prefix,
|
||||
istcat(&name, (isttest(n) ? n : metric->n), PROMEX_MAX_NAME_LEN);
|
||||
|
||||
if ((ctx->flags & PROMEX_FL_METRIC_HDR) &&
|
||||
!promex_dump_metric_header(appctx, metric, name, desc, out, max))
|
||||
!promex_dump_ts_header(appctx, metric, name, desc, out, max))
|
||||
goto full;
|
||||
|
||||
if (istcat(out, name, max) == -1)
|
||||
@ -511,7 +512,7 @@ static int promex_dump_metric(struct appctx *appctx, struct ist prefix,
|
||||
goto full;
|
||||
|
||||
trash.data = out->len;
|
||||
if (!promex_metric_to_str(&trash, val, max))
|
||||
if (!promex_ts_val_to_str(&trash, val, max))
|
||||
goto full;
|
||||
out->len = trash.data;
|
||||
|
||||
@ -557,7 +558,7 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = info[ctx->field_num];
|
||||
}
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix, IST_NULL, IST_NULL,
|
||||
if (!promex_dump_ts(appctx, prefix, IST_NULL, IST_NULL,
|
||||
&promex_global_metrics[ctx->field_num],
|
||||
&val, labels, &out, max))
|
||||
goto full;
|
||||
@ -621,7 +622,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||
labels[1].value = promex_front_st[ctx->obj_state];
|
||||
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_front_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -662,7 +663,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num];
|
||||
}
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_front_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -717,7 +718,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
metric.type = ((val.type == FN_GAUGE) ? PROMEX_MT_GAUGE : PROMEX_MT_COUNTER);
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name)),
|
||||
ist2(mod->stats[ctx->mod_field_num].desc, strlen(mod->stats[ctx->mod_field_num].desc)),
|
||||
&metric, &val, labels, &out, max))
|
||||
@ -807,7 +808,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = mkf_u32(FO_STATUS, status == ctx->obj_state);
|
||||
labels[2].name = ist("state");
|
||||
labels[2].value = ist(li_status_st[ctx->obj_state]);
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_li_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -820,7 +821,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num];
|
||||
}
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_li_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -888,7 +889,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
metric.type = ((val.type == FN_GAUGE) ? PROMEX_MT_GAUGE : PROMEX_MT_COUNTER);
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name)),
|
||||
ist2(mod->stats[ctx->mod_field_num].desc, strlen(mod->stats[ctx->mod_field_num].desc)),
|
||||
&metric, &val, labels, &out, max))
|
||||
@ -984,7 +985,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = mkf_u32(FN_GAUGE, srv_state_count[ctx->obj_state]);
|
||||
labels[1].name = ist("state");
|
||||
labels[1].value = promex_srv_st[ctx->obj_state];
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_back_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1011,7 +1012,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
check_state = get_check_status_info(ctx->obj_state);
|
||||
labels[1].name = ist("state");
|
||||
labels[1].value = ist(check_state);
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_back_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1026,7 +1027,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
labels[1].name = ist("state");
|
||||
labels[1].value = promex_back_st[ctx->obj_state];
|
||||
val = mkf_u32(FO_STATUS, bkd_state == ctx->obj_state);
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_back_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1097,7 +1098,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num];
|
||||
}
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_back_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1152,7 +1153,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
metric.type = ((val.type == FN_GAUGE) ? PROMEX_MT_GAUGE : PROMEX_MT_COUNTER);
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name)),
|
||||
ist2(mod->stats[ctx->mod_field_num].desc, strlen(mod->stats[ctx->mod_field_num].desc)),
|
||||
&metric, &val, labels, &out, max))
|
||||
@ -1242,7 +1243,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
||||
labels[2].name = ist("state");
|
||||
labels[2].value = promex_srv_st[ctx->obj_state];
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_srv_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1294,7 +1295,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
check_state = get_check_status_info(ctx->obj_state);
|
||||
labels[2].name = ist("state");
|
||||
labels[2].value = ist(check_state);
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_srv_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1342,7 +1343,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num];
|
||||
}
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
promex_st_srv_metrics_names[ctx->field_num],
|
||||
promex_st_metric_desc[ctx->field_num],
|
||||
&promex_st_metrics[ctx->field_num],
|
||||
@ -1412,7 +1413,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
metric.type = ((val.type == FN_GAUGE) ? PROMEX_MT_GAUGE : PROMEX_MT_COUNTER);
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix,
|
||||
if (!promex_dump_ts(appctx, prefix,
|
||||
ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name)),
|
||||
ist2(mod->stats[ctx->mod_field_num].desc, strlen(mod->stats[ctx->mod_field_num].desc)),
|
||||
&metric, &val, labels, &out, max))
|
||||
@ -1494,7 +1495,7 @@ static int promex_dump_module_metrics(struct appctx *appctx, struct promex_modul
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
if (!promex_dump_metric(appctx, prefix, IST_NULL, desc, &metric,
|
||||
if (!promex_dump_ts(appctx, prefix, IST_NULL, desc, &metric,
|
||||
&val, labels, out, max))
|
||||
goto full;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user