From 5aab3eb02cb82b41e0093113883f65ca3c575668 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 | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index 0de3c3b1221..b1b735ddff1 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -2392,6 +2392,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; @@ -2435,19 +2436,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) {