Skip to content

Commit 2d4f20b

Browse files
committed
in_opentelemetry: implement pause and resume callbacks
Previously, the in_opentelemetry input plugin did not respond to engine pause or resume signals—meaning it continued to accept and handle connections even when the engine had paused the plugin (e.g: it should stop ingesting data). This patch implements the missing pause and resume callbacks. When the plugin is paused, all active client connections are forcefully closed, and new incoming connections are rejected. The plugin tracks its paused state to ensure correct behavior until it is resumed. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent 9756062 commit 2d4f20b

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

plugins/in_opentelemetry/opentelemetry.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ static int in_opentelemetry_collect(struct flb_input_instance *ins,
5050
return -1;
5151
}
5252

53+
if (ctx->is_paused) {
54+
flb_plg_trace(ctx->ins, "TCP connection will be closed FD=%i",
55+
connection->fd);
56+
flb_downstream_conn_release(connection);
57+
return -1;
58+
}
59+
5360
flb_plg_trace(ctx->ins, "new TCP connection arrived FD=%i", connection->fd);
5461

5562
conn = opentelemetry_conn_add(connection, ctx);
@@ -76,6 +83,7 @@ static int in_opentelemetry_init(struct flb_input_instance *ins,
7683
return -1;
7784
}
7885
ctx->collector_id = -1;
86+
ctx->is_paused = FLB_FALSE;
7987

8088
/* Populate context with config map defaults and incoming properties */
8189
ret = flb_input_config_map_set(ins, (void *) ctx);
@@ -195,6 +203,27 @@ static int in_opentelemetry_exit(void *data, struct flb_config *config)
195203
return 0;
196204
}
197205

206+
static void in_opentelemetry_pause(void *data, struct flb_config *config)
207+
{
208+
struct flb_opentelemetry *ctx = data;
209+
210+
if (config->is_running == FLB_TRUE) {
211+
flb_input_collector_pause(ctx->collector_id, ctx->ins);
212+
opentelemetry_conn_release_all(ctx);
213+
ctx->is_paused = FLB_TRUE;
214+
}
215+
}
216+
217+
static void in_opentelemetry_resume(void *data, struct flb_config *config)
218+
{
219+
struct flb_opentelemetry *ctx = data;
220+
221+
if (config->is_running == FLB_TRUE) {
222+
flb_input_collector_resume(ctx->collector_id, ctx->ins);
223+
ctx->is_paused = FLB_FALSE;
224+
}
225+
}
226+
198227
/* Configuration properties map */
199228
static struct flb_config_map config_map[] = {
200229
{
@@ -272,8 +301,8 @@ struct flb_input_plugin in_opentelemetry_plugin = {
272301
.cb_pre_run = NULL,
273302
.cb_collect = in_opentelemetry_collect,
274303
.cb_flush_buf = NULL,
275-
.cb_pause = NULL,
276-
.cb_resume = NULL,
304+
.cb_pause = in_opentelemetry_pause,
305+
.cb_resume = in_opentelemetry_resume,
277306
.cb_exit = in_opentelemetry_exit,
278307
.config_map = config_map,
279308
.flags = FLB_INPUT_NET_SERVER | FLB_IO_OPT_TLS

plugins/in_opentelemetry/opentelemetry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct flb_opentelemetry {
5757
struct mk_list connections; /* linked list of connections */
5858

5959
struct mk_server *server;
60+
int is_paused; /* Plugin is paused */
6061
};
6162

6263

0 commit comments

Comments
 (0)