Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_opentelemetry: add tag_from_uri support to http2 codepath #9447

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading