feat: integrate OTLP support with native gRPC and HTTP flushers#2548
Open
yyuuttaaoo wants to merge 9 commits intoalibaba:mainfrom
Open
feat: integrate OTLP support with native gRPC and HTTP flushers#2548yyuuttaaoo wants to merge 9 commits intoalibaba:mainfrom
yyuuttaaoo wants to merge 9 commits intoalibaba:mainfrom
Conversation
Migrate 14 Cursor skills from .cursor/ to .claude/skills/ as Claude Code native format with SKILL.md discovery. Update cross-references, consolidate testing-standards and review-standards docs, add C++ unit test build/run instructions, and fix .gitignore to track .claude/ while ignoring .cursor/ and .claude/settings.local.json. Change-Id: Ie23c35aeb581de6c076b18ba583db4602bcb6c9c Co-developed-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added OTLP gRPC and HTTP flushers to enhance data export capabilities. - Implemented `OTLPForwardService` to handle logs, metrics, and traces via gRPC. - Introduced `FlusherOTLPNative` and `FlusherOTLPHttpNative` for sending data to OTLP endpoints. - Updated CMake configuration to include new protobuf dependencies and directories. - Enhanced application startup and shutdown processes to initialize and stop gRPC sinks. - Added new serializers for OTLP data formats and integrated them into the flushing process. - Updated metric constants to include new runner types for gRPC sinks. This commit significantly expands the data handling capabilities of the application, allowing for better integration with OTLP-compliant systems. Change-Id: I664d5a5f46b0a99992d27a021ecc359a02fae7cd Co-developed-by: Cursor <noreply@cursor.com>
- Updated `devcontainer.json` to include a new volume for Docker data and added a post-start command to initialize Docker-in-Docker. - Introduced `dind-install.sh` script to facilitate Docker installation within the dev container. - Modified `Dockerfile` to copy and execute the `dind-install.sh` script, ensuring Docker is set up correctly during the container build process. - Adjusted user permissions and entry point to support Docker operations seamlessly. This commit significantly improves the development environment by enabling Docker-in-Docker functionality, allowing for more flexible container management within the dev container. Change-Id: I6b95b431bee9135d3e2aa883f88df16b30a5b610 Co-developed-by: Cursor <noreply@cursor.com>
…s, and traces - Added new test cases for OTLP HTTP and gRPC flushers, including scenarios for sending logs, metrics, and traces to an OTel Collector. - Introduced `otelgen` integration to generate OTLP data within the test environment, enhancing the testing framework's capabilities. - Created configuration files for the OTel Collector to handle incoming OTLP data and export it to local files. - Updated the Docker setup for the test cases to include necessary services and health checks for the OTel Collector. - Implemented verification logic to ensure the collector receives the expected data counts from the generated OTLP outputs. This commit significantly enhances the testing framework by enabling comprehensive validation of OTLP data handling and integration with the OTel Collector. Change-Id: I1234567890abcdef1234567890abcdef12345678 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I61c99fb83f0ff7c44b7a4b2308ce487e7c7fa781 Co-developed-by: Cursor <noreply@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds first-class OTLP ingestion and export capabilities, including a new OTLP forward gRPC service and native OTLP flushers for both gRPC and HTTP, plus corresponding build/test infrastructure updates.
Changes:
- Introduces OTLP gRPC forwarding (logs/metrics/traces) and a new gRPC sink path for async exporting.
- Adds native OTLP flushers (gRPC + HTTP) and OTLP serializers, with unit tests and e2e docker-compose scenarios.
- Updates build configuration (CMake/protobuf) and documentation to reflect the new OTLP capabilities.
Reviewed changes
Copilot reviewed 90 out of 91 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/engine/verify/otlp_collector.go | Adds verification helper to assert OTLP Collector file-exporter received expected signals. |
| test/engine/trigger/otlp/otelgen.go | Adds otelgen-based trigger to generate OTLP test data inside compose networks. |
| test/engine/steps.go | Registers new OTLP trigger/verification steps and adjusts After hook behavior. |
| test/engine/setup/env.go | Skips PID setup for docker-compose until containers start. |
| test/engine/setup/docker_compose.go | Sets Agent PID after docker-compose container startup. |
| test/e2e/test_cases/flusher_otlp_native/otel-collector-config.yaml | Adds OTel Collector config for gRPC-only receiver and file exporters. |
| test/e2e/test_cases/flusher_otlp_native/docker-compose.yaml | Adds compose service for OTel Collector for gRPC native flusher tests. |
| test/e2e/test_cases/flusher_otlp_native/case.feature | Adds e2e scenarios for OTLP native gRPC flusher (logs/metrics/traces). |
| test/e2e/test_cases/flusher_otlp_http_native/otel-collector-config.yaml | Adds OTel Collector config for gRPC+HTTP receivers and file exporters. |
| test/e2e/test_cases/flusher_otlp_http_native/docker-compose.yaml | Adds compose service for OTel Collector for OTLP HTTP native flusher tests. |
| test/e2e/test_cases/flusher_otlp_http_native/case.feature | Adds e2e scenarios for OTLP HTTP native flusher (logs/metrics/traces). |
| docs/cn/plugins/input/native/input-forward.md | Documents OTLP as an input_forward protocol and its mapping/matching behavior. |
| docs/cn/plugins/flusher/native/flusher-otlp.md | Adds documentation for flusher_otlp_native (OTLP/gRPC). |
| docs/cn/plugins/flusher/native/flusher-otlp-http.md | Adds documentation for flusher_otlp_http_native (OTLP/HTTP). |
| docs/cn/plugins/flusher/flushers.md | Lists new OTLP flushers in the flusher catalog. |
| docker/Dockerfile_development_part | Updates development image layout and startup method (control script). |
| core/unittest/sender/FlusherRunnerGrpcUnittest.cpp | Adds unit tests for PushToGrpcSink -> GrpcSink path. |
| core/unittest/sender/CMakeLists.txt | Builds and registers new sender gRPC unit test target. |
| core/unittest/pipeline/GrpcSinkMock.h | Adds a mock GrpcSink implementation for unit tests. |
| core/unittest/forward/OTLPForwardServiceUnittest.cpp | Adds unit tests for OTLP forward gRPC service behavior and config matching. |
| core/unittest/forward/CMakeLists.txt | Builds and registers OTLP forward service unit tests. |
| core/unittest/flusher/FlusherOTLPHttpNativeUnittest.cpp | Adds unit tests for OTLP HTTP native flusher request building and send handling. |
| core/unittest/flusher/CMakeLists.txt | Builds new OTLP flusher unit test binaries. |
| core/unittest/CMakeLists.txt | Adds OTLP proto sources into unit test build inputs. |
| core/runner/sink/grpc/GrpcSink.h | Introduces GrpcSink interface for async OTLP gRPC exporting. |
| core/runner/sink/grpc/GrpcSink.cpp | Implements the gRPC sink worker loop and async dispatch. |
| core/runner/sink/SinkType.h | Adds GRPC sink type. |
| core/runner/ProcessorRunner.cpp | Adds additional processing log line (currently at INFO). |
| core/runner/FlusherRunner.h | Adds PushToGrpcSink entry point. |
| core/runner/FlusherRunner.cpp | Dispatches GRPC sink type and adds PushToGrpcSink implementation. |
| core/protobuf/opentelemetry/proto/resource/v1/resource.proto | Adds OTLP Resource proto. |
| core/protobuf/opentelemetry/proto/logs/v1/logs.proto | Adds OTLP Logs proto. |
| core/protobuf/opentelemetry/proto/common/v1/common.proto | Adds OTLP Common proto. |
| core/protobuf/opentelemetry/proto/collector/trace/v1/trace_service.proto | Adds OTLP TraceService proto. |
| core/protobuf/opentelemetry/proto/collector/metrics/v1/metrics_service.proto | Adds OTLP MetricsService proto. |
| core/protobuf/opentelemetry/proto/collector/logs/v1/logs_service.proto | Adds OTLP LogsService proto. |
| core/plugin/input/InputForward.cpp | Adds OTLP protocol support via OTLPForwardServiceImpl registration. |
| core/plugin/flusher/opentelemetry/FlusherOTLPNative.h | Adds OTLP native gRPC flusher interface and sender item/context types. |
| core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.h | Adds OTLP HTTP native flusher interface. |
| core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.cpp | Implements OTLP HTTP native flusher serialization and request building. |
| core/monitor/metric_constants/RunnerMetrics.cpp | Adds grpc_sink runner label constant. |
| core/monitor/metric_constants/MetricConstants.h | Declares grpc_sink runner label constant. |
| core/forward/otlp/OTLPForwardService.h | Adds OTLP forward service wrapper classes (logs/metrics/traces) and impl API. |
| core/forward/loongsuite/LoongSuiteForwardService.h | Adds GetGrpcServices override and minor header includes cleanup. |
| core/forward/GrpcInputManager.cpp | Registers all services returned by BaseService::GetGrpcServices(). |
| core/forward/BaseService.h | Adds GetGrpcServices API to support multi-service servers. |
| core/dependencies.cmake | Adds OTLP proto compile steps to generate C++ sources. |
| core/collection_pipeline/serializer/OTLPHttpSerializer.h | Adds serializer that can output OTLP JSON and protobuf binary. |
| core/collection_pipeline/serializer/OTLPHttpSerializer.cpp | Implements OTLP request building for logs/metrics/traces and JSON/protobuf serialization. |
| core/collection_pipeline/plugin/PluginRegistry.cpp | Registers new OTLP native flushers. |
| core/application/Application.cpp | Initializes/stops GrpcSink alongside HttpSink. |
| core/CMakeLists.txt | Adds grpc sink + OTLP directories and includes proto-generated headers + sources. |
| .gitignore | Expands ignores for IDE configs and protobuf-generated headers. |
| .devcontainer/start-dind.sh | Adds helper script to start DinD with cgroup v1 nesting fix. |
| .devcontainer/devcontainer.json | Enables DinD data volume and auto-starts DinD after container start. |
| .devcontainer/Dockerfile | Installs DinD tooling and updates repo mirror settings. |
| .claude/skills/testing-standards/SKILL.md | Adds internal guidance for test standards. |
| .claude/skills/selfmonitor/SKILL.md | Adds internal guidance for metric/alarm conventions. |
| .claude/skills/security-check/scripts/security_reset.sh | Adds script to squash/reset commits containing sensitive info. |
| .claude/skills/security-check/scripts/security_check.sh | Adds script to scan staged changes/commits for sensitive tokens. |
| .claude/skills/security-check/SKILL.md | Documents sensitive info checks and cleanup flow. |
| .claude/skills/riper5-protocol/SKILL.md | Adds internal workflow protocol reference. |
| .claude/skills/review-standards/SKILL.md | Adds internal code review checklist and standards. |
| .claude/skills/project-knowledge/SKILL.md | Adds internal project architecture and conventions reference. |
| .claude/skills/omc-reference/SKILL.md | Adds internal multi-agent orchestration reference. |
| .claude/skills/mermaid/SKILL.md | Adds internal Mermaid formatting conventions. |
| .claude/skills/e2e-manual/SKILL.md | Adds internal e2e manual testing guidance. |
| .claude/skills/e2e-develop-guide/SKILL.md | Adds internal e2e framework development guidance. |
| .claude/skills/design-document/SKILL.md | Adds internal design doc conventions. |
| .claude/skills/compile/SKILL.md | Adds internal build instructions. |
| .claude/skills/commit/SKILL.md | Adds internal conventional commit guidance. |
| .claude/skills/code-review/scripts/update_comment_status.py | Adds tooling to track review comment status across rounds. |
| .claude/skills/code-review/scripts/init_review_workspace.py | Adds tooling to initialize code-review workspace files. |
| .claude/skills/code-review/scripts/generate_comment_status_report.py | Adds tooling to generate markdown status reports. |
| .claude/skills/code-review/scripts/fetch_review_comments.py | Adds tooling to fetch PR review comments with resolution state. |
| .claude/skills/code-review/scripts/build_snapshot.py | Adds tooling to snapshot changed files per review round. |
| .claude/skills/code-review/references/reviewed_commits.template.json | Adds template for reviewed commit tracking. |
| .claude/skills/code-review/references/review-plan.template.md | Adds template for review plan. |
| .claude/skills/code-review/references/meta.template.json | Adds template for review metadata. |
| .claude/skills/code-review/references/failure-playbook.md | Adds failure recovery playbook for review automation. |
| .claude/skills/code-review/references/comment-status.template.json | Adds template for comment status tracking. |
| .claude/settings.json | Enables an internal plugin configuration. |
| .claude/CLAUDE.md | Adds internal orchestration guidance for Claude tooling. |
Comments suppressed due to low confidence (14)
test/engine/verify/otlp_collector.go:1
context.WithTimeout(context.TODO(), ...)ignores the caller’s ctx (cancellation/deadlines won’t propagate). Also, resolveLocalPath’s fallback branch trims the same prefix again, so it never handles variants like "/tmp/otel-export" (no trailing slash). Use the passed-in ctx for the timeout base (e.g., ctx), and fix the fallback to handle both "/tmp/otel-export/" and "/tmp/otel-export" prefixes.
test/engine/verify/otlp_collector.go:1context.WithTimeout(context.TODO(), ...)ignores the caller’s ctx (cancellation/deadlines won’t propagate). Also, resolveLocalPath’s fallback branch trims the same prefix again, so it never handles variants like "/tmp/otel-export" (no trailing slash). Use the passed-in ctx for the timeout base (e.g., ctx), and fix the fallback to handle both "/tmp/otel-export/" and "/tmp/otel-export" prefixes.
test/engine/trigger/otlp/otelgen.go:1- The docker argument list includes an extra
"--"before the image name;docker runexpectsIMAGEdirectly after options, and"--"here can be interpreted as the image name and break the command. Also, for non-metrics paths,exec.Commandignores ctx cancellation; useexec.CommandContext(ctx, ...)so the test runner can reliably abort otelgen runs.
test/engine/trigger/otlp/otelgen.go:1 docker ps --format "{{.ID}}"can return multiple container IDs separated by newlines; trimming whitespace can leave multiple IDs, causingdocker inspect ... <containerID>to fail. Split by lines and select the first non-empty ID (or iterate) to make network discovery deterministic.
core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.cpp:1- The implementation defaults
mFormatto Protobuf (header), but the comment, warning text, and log line claim the default is JSON whenFormatis absent/invalid. This produces misleading logs and makes troubleshooting configuration behavior harder. Align the comment/log/warning with the actual default (or change the default to match the documented behavior), and ensure the “invalid Format” branch reports the real fallback.
core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.cpp:1 - The implementation defaults
mFormatto Protobuf (header), but the comment, warning text, and log line claim the default is JSON whenFormatis absent/invalid. This produces misleading logs and makes troubleshooting configuration behavior harder. Align the comment/log/warning with the actual default (or change the default to match the documented behavior), and ensure the “invalid Format” branch reports the real fallback.
core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.cpp:1 std::stoiwill throw on malformed ports (e.g.,http://host:abc/...) and can crash the process since the exception isn’t handled. SinceUrlis user configuration, catch conversion errors and returnfalsewith a clearerrMsg(and setkeepItemappropriately). Also consider validating/infering TLS from the URL scheme to avoid inconsistent configs likehttps://...withEnableTLS=false.
core/plugin/flusher/opentelemetry/FlusherOTLPHttpNative.cpp:1std::stoiwill throw on malformed ports (e.g.,http://host:abc/...) and can crash the process since the exception isn’t handled. SinceUrlis user configuration, catch conversion errors and returnfalsewith a clearerrMsg(and setkeepItemappropriately). Also consider validating/infering TLS from the URL scheme to avoid inconsistent configs likehttps://...withEnableTLS=false.
core/runner/ProcessorRunner.cpp:1- This adds an unconditional
LOG_INFOon the processor hot path and can spam logs / increase CPU under load. It should be downgraded to a lower verbosity (e.g., DEBUG/TRACE) and/or gated behind a flag to avoid production noise and performance regression.
core/runner/sink/grpc/GrpcSink.cpp:1 - The “forced to stopped” path doesn’t actually stop the async worker; the
std::futureremains valid and may still block later (e.g., at destruction) depending on the implementation. Consider switching to astd::threadthat you can deterministically join, or ensure Stop performs a definitive shutdown (cancel in-flight RPCs / clear pending queue / signal Run to exit) and thenget()the future when ready to avoid hidden hangs.
core/runner/sink/grpc/GrpcSink.cpp:1 - This busy-wait loop throttles concurrency via polling/sleep and will waste CPU under sustained pressure. Prefer a semaphore/condition-variable approach (signal on decrement) so dispatch blocks efficiently until capacity is available.
docs/cn/plugins/flusher/flushers.md:1 - The documented plugin names don’t match the implemented/introduced native flusher names (
flusher_otlp_nativeandflusher_otlp_http_native). This will mislead users and break copy/paste configs. Update the table entries to the correct plugin IDs.
docker/Dockerfile_development_part:1 - The new
CMDrelies onloongcollector_control.shbeing executable, but the Dockerfile doesn’tchmod +xit after copying. Add an explicit chmod (or ensure the repo file has the executable bit preserved in builds) to prevent container startup failures.
docker/Dockerfile_development_part:1 - The new
CMDrelies onloongcollector_control.shbeing executable, but the Dockerfile doesn’tchmod +xit after copying. Add an explicit chmod (or ensure the repo file has the executable bit preserved in builds) to prevent container startup failures.
- Improved the C++ compilation instructions in SKILL.md, emphasizing the importance of executing commands within the `build/` directory and detailing the initialization of Git submodules. - Added new sections for C++ unit testing and Docker build processes. - Refactored the OTLP flushers to ensure proper handling of log content and improved error handling in the FlusherOTLPNative and FlusherOTLPHttpNative classes. - Enhanced the handling of gRPC contexts and improved logging for better traceability. This commit enhances the documentation and refines the flushing mechanisms, ensuring better integration and usability for developers. Change-Id: Iabcdef1234567890abcdef1234567890abcdef1234 Co-developed-by: Cursor <noreply@cursor.com>
…ations - Updated `.gitignore` to ensure proper tracking of `.claude/` while ignoring `.cursor/`. - Deleted outdated E2E testing guides from `.claude/skills/` to streamline documentation. - Consolidated references to E2E testing standards and development guides, directing users to the new comprehensive guide in `.claude/skills/e2e/SKILL.md`. - Improved the handling of OTLP flushers in the C++ codebase, enhancing error handling and logging for better traceability. This commit refines the E2E testing framework and documentation, ensuring clarity and improved usability for developers. Change-Id: Iabcdef1234567890abcdef1234567890abcdef1234 Co-developed-by: Cursor <noreply@cursor.com>
…iles - Introduced a new pitfalls guide in `config-pitfalls.mdc` to highlight common configuration issues when using LoongCollector, particularly regarding the `ExcutionTimeout` setting. - Added a detailed reference document in `reference.md` outlining available E2E testing steps, including environment setup, action triggers, and result verification. - Created a structured E2E testing guide in `SKILL.md`, covering the entire process from test design to execution and debugging, along with known pitfalls. - Implemented a cleanup script in `e2e-cleanup.sh` to facilitate the removal of Docker containers and test artifacts, ensuring a clean testing environment. This commit enhances the E2E testing framework by providing clear guidelines and tools for developers, improving the overall testing experience. Change-Id: Iabcdef1234567890abcdef1234567890abcdef1234 Co-developed-by: Cursor <noreply@cursor.com>
- Modified .gitignore to simplify the exclusion of protobuf files and added new entries for test-related files. - Enhanced the OTLP file handling in `otlp_collector.go` by introducing a validation function to ensure file paths are within allowed directories before opening. - Improved error handling in the `countOTLPFileRecords` function to prevent potential security issues. These changes streamline the development process and improve the robustness of OTLP data handling in tests. Change-Id: Ie21fde7a3aed7e0f7d1038fec1ef3b99ed6476cb Co-developed-by: Cursor <noreply@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expands the data handling capabilities of the application, allowing for better integration with OTLP-compliant systems.
OTLPForwardServiceto handle logs, metrics, and traces via gRPC.FlusherOTLPNativeandFlusherOTLPHttpNativefor sending data to OTLP endpoints.