Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interval to dummy events #8076

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions plugins/in_dummy/in_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,19 @@ static int configure(struct flb_dummy *ctx,
}

/* interval settings */
tm->tv_sec = 1;
tm->tv_nsec = 0;
if (ctx->interval_sec <= 0 && ctx->interval_nsec <= 0) {
/* Illegal settings. Override them. */
ctx->interval_sec = atoi(DEFAULT_INTERVAL_SEC);
ctx->interval_nsec = atoi(DEFAULT_INTERVAL_NSEC);
}

tm->tv_sec = ctx->interval_sec;
tm->tv_nsec = ctx->interval_nsec;

if (ctx->rate > 1) {
tm->tv_sec = 0;
tm->tv_nsec = 1000000000 / ctx->rate;
}
}

/* dummy timestamp */
flb_time_zero(&ctx->dummy_timestamp);
Expand Down Expand Up @@ -420,6 +426,16 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_dummy, fixed_timestamp),
"used a fixed timestamp, allows the message to pre-generated once."
},
{
FLB_CONFIG_MAP_INT, "interval_sec", DEFAULT_INTERVAL_SEC,
0, FLB_TRUE, offsetof(struct flb_dummy, interval_sec),
"Set the collector interval"
},
{
FLB_CONFIG_MAP_INT, "interval_nsec", DEFAULT_INTERVAL_NSEC,
0, FLB_TRUE, offsetof(struct flb_dummy, interval_nsec),
"Set the collector interval (sub seconds)"
},
{0}
};

Expand Down
6 changes: 6 additions & 0 deletions plugins/in_dummy/in_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#define DEFAULT_DUMMY_MESSAGE "{\"message\":\"dummy\"}"
#define DEFAULT_DUMMY_METADATA "{}"

#define DEFAULT_INTERVAL_SEC "1"
#define DEFAULT_INTERVAL_NSEC "0"

struct flb_dummy {
int coll_fd;

Expand All @@ -35,6 +38,9 @@ struct flb_dummy {
int samples;
int samples_count;

int interval_sec;
int interval_nsec;

int dummy_timestamp_set;
struct flb_time base_timestamp;
struct flb_time dummy_timestamp;
Expand Down