Skip to content

Commit

Permalink
in_opentelemetry: add tag_from_uri support to http2 codepath
Browse files Browse the repository at this point in the history
tags are still v1_logs/v1_metrics/v1_traces even in gRPC cases

Signed-off-by: Stewart Webb <[email protected]>
  • Loading branch information
nuclearpidgeon committed Sep 21, 2024
1 parent 41b90b7 commit c122d70
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions plugins/in_opentelemetry/opentelemetry_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -2493,5 +2512,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request,
}
}

flb_sds_destroy(tag);

return result;
}

0 comments on commit c122d70

Please sign in to comment.