3030#include <fluent-bit/flb_input_thread.h>
3131#include <fluent-bit/flb_error.h>
3232#include <fluent-bit/flb_utils.h>
33+ #include <fluent-bit/flb_plugin_proxy.h>
3334#include <fluent-bit/flb_engine.h>
3435#include <fluent-bit/flb_metrics.h>
3536#include <fluent-bit/flb_storage.h>
@@ -135,6 +136,18 @@ int flb_input_event_type_is_log(struct flb_input_instance *ins)
135136 return FLB_FALSE ;
136137}
137138
139+ /* Check input plugin's log level.
140+ * Not for core plugins but for Golang plugins.
141+ * Golang plugins do not have thread-local flb_worker_ctx information. */
142+ int flb_input_log_check (struct flb_input_instance * ins , int l )
143+ {
144+ if (ins -> log_level < l ) {
145+ return FLB_FALSE ;
146+ }
147+
148+ return FLB_TRUE ;
149+ }
150+
138151/* Create an input plugin instance */
139152struct flb_input_instance * flb_input_new (struct flb_config * config ,
140153 const char * input , void * data ,
@@ -211,6 +224,24 @@ struct flb_input_instance *flb_input_new(struct flb_config *config,
211224 return NULL ;
212225 }
213226
227+ if (plugin -> type == FLB_INPUT_PLUGIN_CORE ) {
228+ instance -> context = NULL ;
229+ }
230+ else {
231+ struct flb_plugin_proxy_context * ctx ;
232+
233+ ctx = flb_calloc (1 , sizeof (struct flb_plugin_proxy_context ));
234+ if (!ctx ) {
235+ flb_errno ();
236+ flb_free (instance );
237+ return NULL ;
238+ }
239+
240+ ctx -> proxy = plugin -> proxy ;
241+
242+ instance -> context = ctx ;
243+ }
244+
214245 /* initialize remaining vars */
215246 instance -> alias = NULL ;
216247 instance -> id = id ;
@@ -219,7 +250,6 @@ struct flb_input_instance *flb_input_new(struct flb_config *config,
219250 instance -> tag = NULL ;
220251 instance -> tag_len = 0 ;
221252 instance -> routable = FLB_TRUE ;
222- instance -> context = NULL ;
223253 instance -> data = data ;
224254 instance -> storage = NULL ;
225255 instance -> storage_type = -1 ;
@@ -513,6 +543,13 @@ const char *flb_input_get_property(const char *key,
513543 return flb_config_prop_get (key , & ins -> properties );
514544}
515545
546+ #ifdef FLB_HAVE_METRICS
547+ void * flb_input_get_cmt_instance (struct flb_input_instance * ins )
548+ {
549+ return (void * )ins -> cmt ;
550+ }
551+ #endif
552+
516553/* Return an instance name or alias */
517554const char * flb_input_name (struct flb_input_instance * ins )
518555{
@@ -884,6 +921,7 @@ void flb_input_instance_exit(struct flb_input_instance *ins,
884921
885922 p = ins -> p ;
886923 if (p -> cb_exit && ins -> context ) {
924+ /* Multi-threaded input plugins use the same function signature for exit callbacks. */
887925 p -> cb_exit (ins -> context , config );
888926 }
889927}
0 commit comments