From 281df4c689e2b90a4e3483a1a84e7b36a7083ffb Mon Sep 17 00:00:00 2001 From: Stewart Webb Date: Thu, 23 May 2024 08:52:31 +1000 Subject: [PATCH] in_opentelemetry: add tag_from_uri support to http2 codepath tags are still v1_logs/v1_metrics/v1_traces even in gRPC cases Signed-off-by: Stewart Webb --- plugins/in_opentelemetry/opentelemetry_prot.c | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index c1a45c41967..791db4d3f6b 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -2423,6 +2423,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, int grpc_request; struct flb_opentelemetry *context; int result = -1; + flb_sds_t tag; context = (struct flb_opentelemetry *) response->stream->user_data; @@ -2466,19 +2467,37 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, strcmp(request->path, "/opentelemetry.proto.collector.metric.v1.MetricService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export") == 0) { payload_type = 'M'; - result = process_payload_metrics_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_metrics"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_metrics_ng(context, tag, request, response); } else if (strcmp(request->path, "/v1/traces") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.trace.v1.TraceService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.traces.v1.TracesService/Export") == 0) { payload_type = 'T'; - result = process_payload_traces_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_traces"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_traces_ng(context, tag, request, response); } else if (strcmp(request->path, "/v1/logs") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.log.v1.LogService/Export") == 0 || strcmp(request->path, "/opentelemetry.proto.collector.logs.v1.LogsService/Export") == 0) { payload_type = 'L'; - result = process_payload_logs_ng(context, context->ins->tag, request, response); + if (context->tag_from_uri == FLB_TRUE) { + tag = flb_sds_create("v1_logs"); + } + else { + tag = flb_sds_create(context->ins->tag); + } + result = process_payload_logs_ng(context, tag, request, response); } if (grpc_request) { @@ -2493,5 +2512,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, } } + flb_sds_destroy(tag); + return result; }