Skip to content

Commit

Permalink
plugin_proxy: api: Expose CMetrics context to Golang plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Jul 4, 2022
1 parent a27bfe2 commit 2d1c73a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
struct flb_api {
const char *(*output_get_property) (const char *, struct flb_output_instance *);
const char *(*input_get_property) (const char *, struct flb_input_instance *);

void *(*output_get_cmt_instance) (struct flb_output_instance *);
void *(*input_get_cmt_instance) (struct flb_input_instance *);
};

#ifdef FLB_CORE
Expand Down
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ int flb_input_set_property(struct flb_input_instance *ins,
const char *k, const char *v);
const char *flb_input_get_property(const char *key,
struct flb_input_instance *ins);
#ifdef FLB_HAVE_METRICS
void *flb_input_get_cmt_instance(struct flb_input_instance *ins);
#endif

int flb_input_check(struct flb_config *config);
void flb_input_set_context(struct flb_input_instance *ins, void *context);
Expand Down
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ const char *flb_output_name(struct flb_output_instance *in);
int flb_output_set_property(struct flb_output_instance *out,
const char *k, const char *v);
const char *flb_output_get_property(const char *key, struct flb_output_instance *ins);
#ifdef FLB_HAVE_METRICS
void *flb_output_get_cmt_instance(struct flb_output_instance *ins);
#endif
void flb_output_net_default(const char *host, int port,
struct flb_output_instance *ins);
const char *flb_output_name(struct flb_output_instance *ins);
Expand Down
7 changes: 7 additions & 0 deletions src/flb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <fluent-bit/flb_api.h>
#include <fluent-bit/flb_mem.h>

#include <fluent-bit/flb_input.h>
#include <fluent-bit/flb_output.h>

struct flb_api *flb_api_create()
Expand All @@ -35,6 +36,12 @@ struct flb_api *flb_api_create()

api->output_get_property = flb_output_get_property;
api->input_get_property = flb_input_get_property;

#ifdef FLB_HAVE_METRICS
api->output_get_cmt_instance = flb_output_get_cmt_instance;
api->input_get_cmt_instance = flb_input_get_cmt_instance;
#endif

return api;
}

Expand Down
7 changes: 7 additions & 0 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,13 @@ const char *flb_input_get_property(const char *key,
return flb_config_prop_get(key, &ins->properties);
}

#ifdef FLB_HAVE_METRICS
void *flb_input_get_cmt_instance(struct flb_input_instance *ins)
{
return (void *)ins->cmt;
}
#endif

/* Return an instance name or alias */
const char *flb_input_name(struct flb_input_instance *ins)
{
Expand Down
7 changes: 7 additions & 0 deletions src/flb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,13 @@ const char *flb_output_get_property(const char *key, struct flb_output_instance
return flb_config_prop_get(key, &ins->properties);
}

#ifdef FLB_HAVE_METRICS
void *flb_output_get_cmt_instance(struct flb_output_instance *ins)
{
return (void *)ins->cmt;
}
#endif

/* Trigger the output plugins setup callbacks to prepare them. */
int flb_output_init_all(struct flb_config *config)
{
Expand Down

0 comments on commit 2d1c73a

Please sign in to comment.