Skip to content

Commit

Permalink
in_dummy: Add time_interval setting.
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Valente <[email protected]>
  • Loading branch information
franciscovalentecastro committed Oct 18, 2023
1 parent 92b9053 commit f5266f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions plugins/in_dummy/in_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ static int configure(struct flb_dummy *ctx,
struct timespec *tm)
{
const char *msg;
double tmfrac;
int root_type;
int ret = -1;

Expand All @@ -214,12 +215,13 @@ static int configure(struct flb_dummy *ctx,
}

/* interval settings */
tm->tv_sec = 1;
tm->tv_sec = ctx->time_interval;
tm->tv_nsec = 0;

if (ctx->rate > 1) {
tm->tv_sec = 0;
tm->tv_nsec = 1000000000 / ctx->rate;
tmfrac = (double) ctx->time_interval / ctx->rate;
tm->tv_sec = tmfrac;
tm->tv_nsec = (tmfrac - (int) tmfrac) * 1000000000;
}

/* dummy timestamp */
Expand Down Expand Up @@ -398,7 +400,12 @@ static struct flb_config_map config_map[] = {
{
FLB_CONFIG_MAP_INT, "rate", "1",
0, FLB_TRUE, offsetof(struct flb_dummy, rate),
"set a number of events per second."
"set a number of events per time interval."
},
{
FLB_CONFIG_MAP_INT, "time_interval", "1",
0, FLB_TRUE, offsetof(struct flb_dummy, time_interval),
"set time interval to generate logs at the set rate."
},
{
FLB_CONFIG_MAP_INT, "copies", "1",
Expand Down
1 change: 1 addition & 0 deletions plugins/in_dummy/in_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct flb_dummy {
int copies;
int samples;
int samples_count;
int time_interval;

int dummy_timestamp_set;
struct flb_time base_timestamp;
Expand Down

0 comments on commit f5266f2

Please sign in to comment.