Skip to content

Commit

Permalink
in_opentelemetry: support tag_from_uri
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 committed Nov 4, 2023
1 parent 3a3bcf1 commit 5f773cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions plugins/in_opentelemetry/opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_opentelemetry, tag_key),
""
},
{
FLB_CONFIG_MAP_BOOL, "tag_from_uri", "true",
0, FLB_TRUE, offsetof(struct flb_opentelemetry, tag_from_uri),
"If true, tag will be created from uri. e.g. v1_metrics from /v1/metrics ."
},
{
FLB_CONFIG_MAP_INT, "successful_response_code", "201",
0, FLB_TRUE, offsetof(struct flb_opentelemetry, successful_response_code),
Expand Down
1 change: 1 addition & 0 deletions plugins/in_opentelemetry/opentelemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct flb_opentelemetry {
flb_sds_t tcp_port;
const char *tag_key;
bool raw_traces;
int tag_from_uri;

size_t buffer_max_size; /* Maximum buffer size */
size_t buffer_chunk_size; /* Chunk allocation size */
Expand Down
4 changes: 2 additions & 2 deletions plugins/in_opentelemetry/opentelemetry_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,8 +1568,8 @@ int opentelemetry_prot_handle(struct flb_opentelemetry *ctx, struct http_conn *c
/* Compose the query string using the URI */
len = strlen(uri);

if (len == 1) {
tag = NULL; /* use default tag */
if (ctx->tag_from_uri != FLB_TRUE) {
tag = flb_sds_create(ctx->ins->tag);
}
else {
tag = flb_sds_create_size(len);
Expand Down

0 comments on commit 5f773cf

Please sign in to comment.