Skip to content

Conversation

edsiper
Copy link
Member

@edsiper edsiper commented Oct 18, 2025


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Refactor
    • Consolidated OpenTelemetry JSON trace processing into a single conversion path for simpler ingestion.
  • New Features
    • Added full JSON-to-traces conversion support and richer trace validation with more specific error reporting.
  • Bug Fixes
    • Early validation for invalid trace/span IDs to prevent malformed encoding.
  • Tests
    • Added comprehensive trace test cases and integrated a traces test runner.
  • Documentation
    • Updated internal test docs to separate logs and traces test case descriptions.

Copy link

coderabbitai bot commented Oct 18, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Centralizes OTLP JSON→CTraces conversion into a new public converter, adds a TRACES-specific error taxonomy, delegates plugin JSON handling to that converter, strengthens trace/span ID validation in logs path, and adds trace-focused tests and build integration.

Changes

Cohort / File(s) Summary
Public API & Errors
include/fluent-bit/flb_opentelemetry.h
Adds FLB_OTEL_TRACES_ERR_* error codes and FLB_OTEL_TRACES_ERR_GENERIC_ERROR; extends the error-to-string map; declares struct ctrace *flb_opentelemetry_json_traces_to_ctrace(const char *body, size_t len, int *error_status).
Centralized Traces Converter
src/opentelemetry/flb_opentelemetry_traces.c
New JSON→MessagePack→CTraces converter: parses resourceSpans, scopeSpans, spans, attributes, events, links, and status; exposes flb_opentelemetry_json_traces_to_ctrace() and sets error_status on failures.
Plugin Delegation / Refactor
plugins/in_opentelemetry/opentelemetry_traces.c
Removes in-file JSON/msgpack trace parsing and delegates JSON trace handling to flb_opentelemetry_json_traces_to_ctrace(); retains protobuf/raw handling and content-type branching.
Logs ID Validation
src/opentelemetry/flb_opentelemetry_logs.c
Adds validation around hex→ID conversions for trace_id and span_id; sets specific error_status and returns on invalid IDs.
Build Integration
src/CMakeLists.txt
Adds opentelemetry/flb_opentelemetry_traces.c to the OpenTelemetry helpers compilation group.
Tests & Fixtures
tests/internal/data/opentelemetry/traces.json, tests/internal/data/opentelemetry/logs.json, tests/internal/opentelemetry.c, tests/internal/CMakeLists.txt, tests/internal/README.md
Adds traces.json with many invalid/valid trace cases; expands logs.json with ID validation cases; integrates traces test runner test_opentelemetry_traces_cases(); updates test data references and README.

Sequence Diagram(s)

sequenceDiagram
    participant Plugin as in_opentelemetry<br/>(plugin)
    participant API as flb_opentelemetry<br/>json_traces_to_ctrace
    participant Conv as JSON → MsgPack
    participant Parser as MsgPack Parser
    participant CTr as CTraces Builder

    Plugin->>API: flb_opentelemetry_json_traces_to_ctrace(body,len,&error_status)
    API->>Conv: convert JSON → MessagePack
    Conv-->>API: msgpack payload
    API->>Parser: parse root → resourceSpans → scopeSpans → spans
    Parser->>CTr: create resources, scopes, spans, attrs, events, links, status
    CTr-->>API: assembled ctrace (pointer) or NULL
    API-->>Plugin: ctrace | NULL + error_status
    Plugin->>Plugin: handle ctrace or log failure
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

backport to v4.0.x

Suggested reviewers

  • koleini
  • fujimotos

Poem

🐰
I hopped through JSON, packed it tight,
Spans and links in tidy sight.
From messy trees to CTraces neat,
I stitched the hops with tiny feet.
Tidy traces — carrots sweet! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "opentelemetry: traces: unify JSON to ctrace encoder" accurately describes the primary change in the changeset. The core objective is to centralize OpenTelemetry traces conversion logic by extracting inline JSON-to-CTraces parsing from the plugin and consolidating it into a new unified public API function flb_opentelemetry_json_traces_to_ctrace() in a new file src/opentelemetry/flb_opentelemetry_traces.c. The word "unify" directly captures this refactoring concept. The title is concise, specific, and clearly identifies the scope (opentelemetry traces) and the action being taken, making it easy for a developer scanning the history to understand the purpose of this change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch opentelemetry_interface_json_traces

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1027 to 1035
if (obj->type != MSGPACK_OBJECT_MAP) {
flb_error("unexpected root object type for traces");
return NULL;
}

ret = flb_otel_utils_find_map_entry_by_key(&obj->via.map, "resourceSpans", 0, FLB_TRUE);
if (ret < 0) {
flb_error("resourceSpans entry is missing");
return NULL;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rejecting snake_case resourceSpans payloads

The new centralized JSON→ctrace conversion only looks for the resourceSpans key and immediately errors when it isn’t present. The previous in-plugin implementation also checked resource_spans as a fallback, allowing payloads that used the older snake_case form to be ingested. With this change any such payloads now trigger resourceSpans entry is missing and the trace is dropped. If backward compatibility is still required, consider retaining the alternate key or documenting the breaking change.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good heads up, but snake_case name lookup is not required.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (4)
plugins/in_opentelemetry/opentelemetry_traces.c (1)

62-77: error_status is always 0 with current impl; improve propagation

The converter doesn’t currently set error_status, so this logs “status: 0” on failure. After wiring the library to set error_status (see separate comment), also consider logging the symbolic name via flb_opentelemetry_error_to_string for clarity.

Example:

-        flb_plg_error(ctx->ins, "invalid JSON trace: conversion error (status: %d)", error_status);
+        flb_plg_error(ctx->ins,
+                      "invalid JSON trace: conversion error (status: %d%s%s)",
+                      error_status,
+                      error_status ? ", name: " : "",
+                      error_status ? flb_opentelemetry_error_to_string(error_status) : "");
src/opentelemetry/flb_opentelemetry_traces.c (3)

701-706: Remove duplicate/contradictory flags block

There are two “flags” blocks; this one says “unsupported” but later you actually set flags (Lines 733-737). Remove this earlier block to avoid confusion.

-        /* flags */
-        ret = flb_otel_utils_find_map_entry_by_key(&span.via.map, "flags", 0, FLB_TRUE);
-        if (ret >= 0 && span.via.map.ptr[ret].val.type == MSGPACK_OBJECT_POSITIVE_INTEGER) {
-            /* unsupported in CTraces */
-        }

335-338: Don’t abort all events on a single malformed event

Returning -1 on missing event name stops processing the entire events array. Prefer skipping just that event with a warning.

-        if (!name_str) {
-            flb_warn("span event name is missing");
-            return -1;
-        }
+        if (!name_str) {
+            flb_warn("span event name is missing; skipping event");
+            continue;
+        }

1051-1058: Best‑effort parsing: consider skipping bad resourceSpans instead of aborting

Aborting and destroying the whole ctrace on the first bad resourceSpan drops otherwise valid data. Consider logging and continuing.

Pseudo‑change:

for (...) {
    if (process_resource_span(ctr, &resource_spans->via.array.ptr[i]) == -1) {
        flb_warn("failed to process resource span %d; skipping", i);
        continue;
    }
}
return ctr;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36db973 and 498b6c0.

📒 Files selected for processing (4)
  • include/fluent-bit/flb_opentelemetry.h (1 hunks)
  • plugins/in_opentelemetry/opentelemetry_traces.c (2 hunks)
  • src/CMakeLists.txt (1 hunks)
  • src/opentelemetry/flb_opentelemetry_traces.c (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
include/fluent-bit/flb_opentelemetry.h (1)
src/opentelemetry/flb_opentelemetry_traces.c (1)
  • flb_opentelemetry_json_traces_to_ctrace (1063-1102)
src/opentelemetry/flb_opentelemetry_traces.c (8)
src/flb_sds.c (2)
  • flb_sds_create_len (58-76)
  • flb_sds_destroy (389-399)
src/opentelemetry/flb_opentelemetry_utils.c (4)
  • flb_otel_utils_find_map_entry_by_key (28-73)
  • flb_otel_utils_json_payload_get_wrapped_value (75-192)
  • flb_otel_utils_hex_to_id (573-599)
  • flb_otel_utils_convert_string_number_to_u64 (601-622)
lib/cfl/src/cfl_sds.c (2)
  • cfl_sds_create_len (93-111)
  • cfl_sds_destroy (127-137)
lib/ctraces/src/ctr_scope.c (4)
  • ctr_instrumentation_scope_create (89-112)
  • ctr_scope_span_set_instrumentation_scope (78-87)
  • ctr_scope_span_create (22-36)
  • ctr_scope_span_set_schema_url (64-76)
lib/ctraces/src/ctr_span.c (16)
  • ctr_span_event_add_ts (413-444)
  • ctr_span_event_set_attributes (484-496)
  • ctr_span_event_set_dropped_attributes_count (498-501)
  • ctr_span_set_status (281-299)
  • ctr_span_create (26-88)
  • ctr_span_set_trace_id (91-109)
  • ctr_span_set_span_id (120-134)
  • ctr_span_set_parent_span_id (145-161)
  • ctr_span_start_ts (259-266)
  • ctr_span_end_ts (276-279)
  • ctr_span_kind_set (171-179)
  • ctr_span_set_attributes (204-216)
  • ctr_span_set_dropped_attributes_count (345-348)
  • ctr_span_set_dropped_events_count (335-338)
  • ctr_span_set_dropped_links_count (340-343)
  • ctr_span_set_schema_url (321-328)
lib/ctraces/src/ctr_link.c (5)
  • ctr_link_create (22-55)
  • ctr_link_set_trace_state (79-91)
  • ctr_link_set_attributes (93-101)
  • ctr_link_set_dropped_attr_count (103-106)
  • ctr_link_set_flags (108-111)
src/flb_pack.c (1)
  • flb_pack_json (530-535)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
plugins/in_opentelemetry/opentelemetry_traces.c (2)
src/opentelemetry/flb_opentelemetry_traces.c (1)
  • flb_opentelemetry_json_traces_to_ctrace (1063-1102)
src/flb_input_trace.c (1)
  • flb_input_trace_append (123-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 32bit, x86, x86-windows-static, 3.31.6)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 64bit, x64, x64-windows-static, 3.31.6)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 64bit (Arm64), amd64_arm64, -DCMAKE_SYSTEM_NAME=Windows -DCMA...
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_ARROW=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_COVERAGE=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, gcc, g++)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, clang, clang++, ubuntu-22.04, clang-12)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, clang, clang++, ubuntu-24.04, clang-14)
  • GitHub Check: PR - fuzzing test
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, gcc, g++, ubuntu-24.04, clang-14)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, gcc, g++, ubuntu-22.04, clang-12)
  • GitHub Check: pr-compile-without-cxx (3.31.6)
  • GitHub Check: pr-compile-centos-7
🔇 Additional comments (1)
src/CMakeLists.txt (1)

117-117: Build glue looks good

New source added to OpenTelemetry Helpers is correct. Nothing else needed here.

Comment on lines +127 to +129
struct ctrace *flb_opentelemetry_json_traces_to_ctrace(const char *body, size_t len,
int *error_status);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Fix incomplete type and missing header; define error_status semantics

  • Unknown type in some translation units: struct ctrace is not declared here. Either forward-declare it or include <ctraces/ctraces.h>.
  • strcmp is used but <string.h> isn’t included in this header.
  • error_status is exposed but not documented/guaranteed to be set by the implementation.

Apply:

@@
-#include <stdint.h>
+#include <stdint.h>
+#include <string.h>
+
+/* Forward declaration to allow users to include this header without
+ * pulling in <ctraces/ctraces.h> everywhere. */
+struct ctrace;
@@
-struct ctrace *flb_opentelemetry_json_traces_to_ctrace(const char *body, size_t len,
-                                                       int *error_status);
+/* Converts an OTLP JSON Traces payload to a CTraces context.
+ * On failure returns NULL and, if error_status != NULL, sets it to a non‑zero code. */
+struct ctrace *flb_opentelemetry_json_traces_to_ctrace(const char *body, size_t len,
+                                                       int *error_status);

Optionally, introduce trace‑specific error codes in this header in a follow‑up, instead of reusing LOGS codes.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In include/fluent-bit/flb_opentelemetry.h around lines 127-129, three issues
must be fixed: forward-declare or include the definition for struct ctrace
(e.g., add a forward declaration "struct ctrace;" or include the appropriate
header <ctraces/ctraces.h>) so translation units know the type; add #include
<string.h> to this header (or ensure the header that uses strcmp includes it) so
string functions are declared; and document and guarantee error_status semantics
by changing the function comment/signature notes to state when error_status is
set and what values mean (e.g., 0 on success, non-zero on error) — ensure the
implementation sets *error_status in all return paths; optionally leave room to
add trace-specific error codes later.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/opentelemetry/flb_opentelemetry_traces.c (1)

122-129: Array attributes still silently succeed without storing data.

Despite past review comments indicating this was addressed, the MSGPACK_OBJECT_ARRAY case still returns ret = 0 (success) without setting any attribute. This silently drops array-valued attributes from the trace data, potentially causing data loss that's difficult to debug.

Consider one of these approaches:

Option 1 (minimal): Return an error so the caller's warning is triggered:

     case MSGPACK_OBJECT_ARRAY:
         /*
          * The less fun part (OTel JSON encoding), the value can be an array and
          * only allows values such as string, bool, int64, double. I am glad this
          * don't support nested arrays or maps.
          */
-        ret = 0;
+        flb_warn("array-valued attributes are not supported in CTraces, skipping");
+        ret = -1;
         break;

Option 2 (better): Serialize simple arrays to preserve information (iterate array, validate element types, concatenate to comma-separated string or JSON-encode).

🧹 Nitpick comments (1)
tests/internal/README.md (1)

39-55: Specify language for fenced code block.

The fenced code block should include a language identifier for proper syntax highlighting and markdown compliance.

Apply this diff:

-```
+```json
 {
   "test_name": {
     "input": { ... },          # OTLP/JSON traces payload

Based on static analysis hints.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02555e2 and f69990e.

📒 Files selected for processing (7)
  • src/opentelemetry/flb_opentelemetry_logs.c (1 hunks)
  • src/opentelemetry/flb_opentelemetry_traces.c (1 hunks)
  • tests/internal/CMakeLists.txt (1 hunks)
  • tests/internal/README.md (2 hunks)
  • tests/internal/data/opentelemetry/logs.json (1 hunks)
  • tests/internal/data/opentelemetry/traces.json (1 hunks)
  • tests/internal/opentelemetry.c (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/internal/data/opentelemetry/traces.json
🧰 Additional context used
🧬 Code graph analysis (2)
src/opentelemetry/flb_opentelemetry_traces.c (6)
src/flb_sds.c (2)
  • flb_sds_create_len (58-76)
  • flb_sds_destroy (389-399)
src/opentelemetry/flb_opentelemetry_utils.c (4)
  • flb_otel_utils_find_map_entry_by_key (28-73)
  • flb_otel_utils_json_payload_get_wrapped_value (75-192)
  • flb_otel_utils_hex_to_id (573-599)
  • flb_otel_utils_convert_string_number_to_u64 (601-622)
lib/cfl/src/cfl_sds.c (2)
  • cfl_sds_create_len (93-111)
  • cfl_sds_destroy (127-137)
lib/ctraces/src/ctr_scope.c (4)
  • ctr_instrumentation_scope_create (89-112)
  • ctr_scope_span_set_instrumentation_scope (78-87)
  • ctr_scope_span_create (22-36)
  • ctr_scope_span_set_schema_url (64-76)
lib/ctraces/src/ctr_span.c (13)
  • ctr_span_event_add_ts (413-444)
  • ctr_span_event_set_attributes (484-496)
  • ctr_span_event_set_dropped_attributes_count (498-501)
  • ctr_span_create (26-88)
  • ctr_span_set_trace_id (91-109)
  • ctr_span_set_span_id (120-134)
  • ctr_span_set_parent_span_id (145-161)
  • ctr_span_set_flags (315-319)
  • ctr_span_start_ts (259-266)
  • ctr_span_end_ts (276-279)
  • ctr_span_kind_set (171-179)
  • ctr_span_set_attributes (204-216)
  • ctr_span_set_schema_url (321-328)
lib/ctraces/src/ctr_link.c (5)
  • ctr_link_create (22-55)
  • ctr_link_set_trace_state (79-91)
  • ctr_link_set_attributes (93-101)
  • ctr_link_set_dropped_attr_count (103-106)
  • ctr_link_set_flags (108-111)
tests/internal/opentelemetry.c (5)
src/opentelemetry/flb_opentelemetry_utils.c (2)
  • flb_otel_utils_hex_to_id (573-599)
  • flb_otel_utils_find_map_entry_by_key (28-73)
src/flb_pack.c (2)
  • flb_pack_json (530-535)
  • flb_msgpack_to_json_str (1459-1500)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
include/fluent-bit/flb_opentelemetry.h (1)
  • flb_opentelemetry_error_code (159-169)
src/opentelemetry/flb_opentelemetry_traces.c (1)
  • flb_opentelemetry_json_traces_to_ctrace (1211-1263)
🪛 markdownlint-cli2 (0.18.1)
tests/internal/README.md

39-39: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 32bit, x86, x86-windows-static, 3.31.6)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 64bit, x64, x64-windows-static, 3.31.6)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 64bit (Arm64), amd64_arm64, -DCMAKE_SYSTEM_NAME=Windows -DCMA...
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_ARROW=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_COVERAGE=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, clang, clang++)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, clang, clang++, ubuntu-22.04, clang-12)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, gcc, g++)
  • GitHub Check: pr-compile-without-cxx (3.31.6)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, clang, clang++, ubuntu-24.04, clang-14)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, gcc, g++, ubuntu-24.04, clang-14)
  • GitHub Check: pr-compile-system-libs (-DFLB_PREFER_SYSTEM_LIBS=On, 3.31.6, gcc, g++, ubuntu-22.04, clang-12)
  • GitHub Check: pr-compile-centos-7
  • GitHub Check: PR - fuzzing test
🔇 Additional comments (9)
src/opentelemetry/flb_opentelemetry_traces.c (2)

468-474: LGTM: Hex decode validation is now properly implemented.

All calls to flb_otel_utils_hex_to_id() now check the return value and handle invalid hex appropriately by setting error_status and returning early. This addresses the previous review concern about invalid hex not being caught.

Also applies to: 505-511, 721-728, 751-758, 799-806


1222-1224: LGTM: Error status properly initialized and set throughout.

The public API correctly initializes error_status to 0 on entry and sets appropriate error codes on all failure paths. This addresses the previous review concern about error_status not being populated.

Also applies to: 1229-1234, 1243-1250, 1258-1260

tests/internal/CMakeLists.txt (1)

174-174: LGTM: Test data path updated to support logs/traces split.

The change from test_cases.json to logs.json aligns with the PR's reorganization of test data into separate files for logs and traces, improving test organization.

src/opentelemetry/flb_opentelemetry_logs.c (1)

305-310: LGTM: Hex validation properly added for trace/span IDs.

The validation now checks the return value of flb_otel_utils_hex_to_id() for both trace_id and span_id, setting appropriate error codes (FLB_OTEL_LOGS_ERR_INVALID_TRACE_ID / FLB_OTEL_LOGS_ERR_INVALID_SPAN_ID) when invalid hex is detected. This prevents malformed IDs from propagating through the system.

Also applies to: 317-322

tests/internal/data/opentelemetry/logs.json (1)

595-696: LGTM: Comprehensive hex validation test coverage.

The new test cases thoroughly exercise the hex validation logic with:

  • Invalid hex characters (G, Z)
  • Odd-length hex strings (31, 15 chars)
  • Mixed valid/invalid characters

Each case properly specifies the expected error code, ensuring robust validation of the hex decoding implementation.

tests/internal/opentelemetry.c (4)

30-30: LGTM: CTRACES integration enabled.

Adding the ctraces/ctraces.h include integrates the CTraces library for trace-specific testing, aligning with the PR's objective to add centralized JSON-to-CTraces conversion.


411-447: LGTM: Comprehensive hex validation edge-case tests.

The test function covers important edge cases:

  • Zero-length strings (should succeed with empty output)
  • Odd-length strings (should fail)
  • Invalid hex characters (G, Z)
  • Uppercase and lowercase hex (both should succeed)

This provides thorough validation of the flb_otel_utils_hex_to_id implementation.


540-541: LGTM: Test data paths separated for logs and traces.

The separate paths (logs.json and traces.json) support the PR's objective to organize test data by signal type, improving test maintainability and clarity.


801-926: LGTM: Traces test implementation mirrors logs testing approach.

The new test_opentelemetry_traces_cases() function:

  • Loads test cases from traces.json
  • Calls the centralized flb_opentelemetry_json_traces_to_ctrace() API
  • Validates both success and error cases with proper error code checking
  • Properly cleans up ctrace contexts

The implementation is consistent with the existing logs testing pattern and properly integrated into the TEST_LIST.

Also applies to: 1024-1024

@edsiper edsiper merged commit 0923ad6 into master Oct 19, 2025
57 checks passed
@edsiper edsiper deleted the opentelemetry_interface_json_traces branch October 19, 2025 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant