[None][chore] Add unittest for otlp tracing
Summary by CodeRabbit
- Tests
- Added comprehensive end-to-end test suite for tracing and observability features, validating chat completion requests, response structures, token usage tracking, and telemetry export with the remote OpenAI server.
Description
Add unit test for otlp tracing: PR#5897
PR Checklist
Please review the following before submitting your PR:
-
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
-
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
-
Test cases are provided for new code paths (see test instructions)
-
Any new dependencies have been scanned for license and vulnerabilities
-
CODEOWNERS updated if ownership changes
-
Documentation updated as needed
-
The reviewers assigned automatically/manually are appropriate for the PR.
-
[x] Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...
Provide a user friendly way for developers to interact with a Jenkins server.
Run /bot [-h|--help] to print this help message.
See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]
Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.
--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.
--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.
--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.
--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.
--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.
--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.
--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.
--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.
--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.
--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.
--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".
--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.
--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.
For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.
kill
kill
Kill all running builds associated with pull request.
skip
skip --comment COMMENT
Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
reuse-pipeline
reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
๐ Walkthrough
Walkthrough
A new test module introduces end-to-end tracing validation for RemoteOpenAIServer. It implements a fake in-process gRPC TraceService, provides fixtures for server setup and client creation, supplies OpenTelemetry attribute decoding utilities, and includes a comprehensive test verifying trace export correctness.
Changes
| Cohort / File(s) | Summary |
|---|---|
New tracing test module tests/unittest/others/test_tracing.py |
Introduces FakeTraceService gRPC servicer implementation that records trace export requests via an event-signaling mechanism. Adds utility functions decode_value() and decode_attributes() to extract and decode OpenTelemetry AnyValue fields supporting bool, string, int, double, and array types. Provides fixtures for trace service setup, model configuration (name, backend, worker count), temporary extra LLM API options file, RemoteOpenAIServer instantiation with OTLP tracing endpoint, and sync/async OpenAI clients. Implements comprehensive test_tracing() function that sends a chat completion request, validates response structure, waits for trace export, and asserts decoded trace attributes include generation and latency metrics. |
Sequence Diagram
sequenceDiagram
participant Test as test_tracing
participant Client as OpenAI Client
participant Server as RemoteOpenAIServer
participant OTLP as FakeTraceService
Test->>Server: Fixture: Start server with OTLP endpoint
Test->>Client: Fixture: Create client
Test->>Client: Send chat completion request
Client->>Server: POST /v1/chat/completions
activate Server
Server->>Server: Process request
Server->>OTLP: Export trace (async)
OTLP->>OTLP: Record export request & signal event
Server-->>Client: Return completion response
deactivate Server
Client-->>Test: Response with id, choice, content
Test->>Test: Validate response structure
Test->>OTLP: Wait for trace export (with timeout)
Test->>Test: Decode trace attributes<br/>(usage, temperature, top_p, latency)
Test->>Test: Assert all expected attributes present
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
- FakeTraceService gRPC implementation: Verify correct servicer interface implementation and event synchronization mechanism for test reliability
- OpenTelemetry attribute decoding logic: Validate
decode_value()anddecode_attributes()correctly handle nestedAnyValuestructures across all supported types (bool, string, int, double, array) - Fixture dependencies and lifecycle: Confirm proper server startup, OTLP endpoint configuration, cleanup/teardown logic, and fixture parameter wiring
- Test assertion completeness: Review timeout handling, trace structure validation (
resource_spansโscope_spansโspans), and attribute extraction correctness
Pre-merge checks and finishing touches
โ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description Check | โ ๏ธ Warning | The pull request description is incomplete and does not adequately follow the required template. The "Description" section contains only a single sentence stating "Add unit test for otlp tracing: [PR#5897]" without explaining what is being tested, why the test is needed, or what the expected outcomes are. Most critically, the "Test Coverage" section is entirely missing, which is essential for a test-focused PR to document what test cases are included and what they validate. The PR Checklist items remain unchecked and not addressed. While the title implies the general intent, the description itself provides insufficient context and fails to meet the template requirements. | The author should expand the "Description" section to clearly explain the purpose of the test, what OTLP tracing functionality is being validated, and how it relates to PR #5897. Add a complete "Test Coverage" section that details the specific test cases included in the new test module (e.g., test_tracing), what they validate (trace structure, attributes, integration with RemoteOpenAIServer), and how they ensure the OTLP tracing implementation works correctly. Additionally, review and address the PR Checklist items to confirm compliance with coding guidelines, dependency scanning, and documentation requirements. |
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
โ Passed checks (1 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | โ Passed | The pull request title "[None][chore] Add unittest for otlp tracing" accurately and concisely describes the main change in the pull request. The changeset introduces a new comprehensive test module tests/unittest/others/test_tracing.py that implements end-to-end tracing tests for OTLP (OpenTelemetry Protocol) integration, which directly aligns with what the title conveys. The title follows the repository's template format with the [None] ticket indicator and [chore] type designation. It is clear, specific, and sufficiently descriptive for a developer scanning commit history to understand the primary purpose of the change. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
/bot run --disable-fail-fast
PR_Github #22818 [ run ] triggered by Bot. Commit: 096e667
PR_Github #22818 [ run ] completed with state SUCCESS. Commit: 096e667
/LLM/main/L0_MergeRequest_PR pipeline #17212 completed with status: 'FAILURE'
/bot run --stage-list "H100_PCIe-PyTorch-Perf-1, H100_PCIe-TensorRT-Perf-1"
PR_Github #22878 [ run ] triggered by Bot. Commit: bce291a
PR_Github #22878 [ run ] completed with state SUCCESS. Commit: bce291a
/LLM/main/L0_MergeRequest_PR pipeline #17255 (Partly Tested) completed with status: 'FAILURE'
/bot run --stage-list "H100_PCIe-PyTorch-Perf-1, H100_PCIe-TensorRT-Perf-1"
PR_Github #22966 [ run ] triggered by Bot. Commit: 386cee1
PR_Github #22966 [ run ] completed with state SUCCESS. Commit: 386cee1
/LLM/main/L0_MergeRequest_PR pipeline #17315 (Partly Tested) completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23624 [ run ] triggered by Bot. Commit: 386cee1
PR_Github #23624 [ run ] completed with state FAILURE. Commit: 386cee1
/LLM/main/L0_MergeRequest_PR pipeline #17775 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23717 [ run ] triggered by Bot. Commit: 386cee1
PR_Github #23717 [ run ] completed with state FAILURE. Commit: 386cee1
/LLM/main/L0_MergeRequest_PR pipeline #17849 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23725 [ run ] triggered by Bot. Commit: 6cabca4
PR_Github #23725 [ run ] completed with state SUCCESS. Commit: 6cabca4
/LLM/main/L0_MergeRequest_PR pipeline #17856 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23935 [ run ] triggered by Bot. Commit: 6cabca4
PR_Github #23935 [ run ] completed with state SUCCESS. Commit: 6cabca4
/LLM/main/L0_MergeRequest_PR pipeline #18024 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23983 [ run ] triggered by Bot. Commit: 30c1aca
PR_Github #23983 [ run ] completed with state SUCCESS. Commit: 30c1aca
/LLM/main/L0_MergeRequest_PR pipeline #18059 completed with status: 'FAILURE'
/bot skip --comment "CI has passed in 23935 and 23983 separately."
PR_Github #24087 [ skip ] triggered by Bot. Commit: 30c1aca
PR_Github #24087 [ skip ] completed with state SUCCESS. Commit: 30c1aca
Skipping testing for commit 30c1aca
/bot run --disable-fail-fast
PR_Github #25690 [ run ] triggered by Bot. Commit: 5aa6df8