Skip to content

agents: export extra_attrs when using OTLP#293

Closed
santigimeno wants to merge 1 commit intonode-v22.x-nsolid-v5.xfrom
santi/otlp_extra_attrs
Closed

agents: export extra_attrs when using OTLP#293
santigimeno wants to merge 1 commit intonode-v22.x-nsolid-v5.xfrom
santi/otlp_extra_attrs

Conversation

@santigimeno
Copy link
Copy Markdown
Member

@santigimeno santigimeno commented Apr 11, 2025

Which was overlooked in the initial implementation. Add tests covering the case.

Fixes: https://github.com/nodesource/nsolid-roadmap/issues/29

Summary by CodeRabbit

  • New Features
    • Added support for array attributes (booleans, integers, floats, strings) in OpenTelemetry tracing, allowing richer span data.
  • Bug Fixes
    • Improved handling of extra JSON attributes to ensure valid merging and processing.
  • Tests
    • Introduced comprehensive gRPC tracing tests covering HTTP and custom tracing scenarios, including validation of array attributes.
    • Updated test client to use array attributes in custom trace spans and adjusted execution timing for improved reliability.

@santigimeno santigimeno self-assigned this Apr 11, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
@santigimeno santigimeno force-pushed the santi/otlp_extra_attrs branch from 777b00f to 1544c4d Compare April 15, 2025 14:57
@edsadr
Copy link
Copy Markdown
Member

edsadr commented Apr 15, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2025

Walkthrough

The changes introduce enhanced support for OpenTelemetry attribute propagation in gRPC/OTLP tracing. The core logic in the agent now merges additional JSON attributes and supports arrays of primitive types (boolean, integer, unsigned integer, float, string) as span attributes, skipping arrays that are empty or contain mixed types. A new test suite verifies correct propagation of various attribute types, including arrays, for both HTTP and custom tracing scenarios. The test client for custom traces now sets an array of strings as an attribute and executes tracing logic asynchronously after a delay.

Changes

File(s) Change Summary
agents/otlp/src/otlp_common.cc Enhanced fill_recordable to merge extra JSON attributes and support arrays of primitive types as span attributes.
test/agents/test-grpc-tracing.mjs Added comprehensive gRPC tracing test suite, validating attribute propagation and array support in spans.
test/common/nsolid-grpc-agent/client.js Modified custom trace to set an array-of-strings attribute and defer execution; updated tracing logic accordingly.

Assessment against linked issues

Objective Addressed Explanation
Ensure attributes set via otel API are propagated in gRPC / OTLP (#29)

Poem

In fields of code where traces hop,
Arrays and strings now never stop.
Attributes merge, JSON flows,
Through gRPC, each value goes.
With every span, a story told—
A rabbit’s trace, both brave and bold!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (1)
agents/otlp/src/otlp_common.cc (1)

422-503: Avoid using goto for skipping non-homogeneous arrays.
Although it works as intended, structured approaches (e.g., extracting the validation logic into a function that returns a boolean) can improve readability and maintainability.

         if (!item.is_boolean()) {
-           goto skip_array;
+           // Skip non-homogeneous arrays with early return or a helper function
+           is_valid_array = false;
+           break;
         }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ada5e2c and 1544c4d.

📒 Files selected for processing (3)
  • agents/otlp/src/otlp_common.cc (2 hunks)
  • test/agents/test-grpc-tracing.mjs (1 hunks)
  • test/common/nsolid-grpc-agent/client.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/common/nsolid-grpc-agent/client.js (6)
test/common/nsolid-zmq-agent/client.js (7)
  • api (60-61)
  • require (4-4)
  • require (5-5)
  • require (7-7)
  • nsolid (6-6)
  • tracer (63-63)
  • span (64-65)
test/common/nsolid-grpc-agent/index.js (4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
  • require (10-14)
test/parallel/test-nsolid-grpc-heap-sampling.js (1)
  • nsolid (5-5)
test/parallel/test-nsolid-grpc-profile.js (1)
  • nsolid (5-5)
test/parallel/test-nsolid-grpc-snapshot.js (1)
  • nsolid (5-5)
test/parallel/test-nsolid-grpc-heap-profile.js (1)
  • nsolid (5-5)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-tarball-linux
  • GitHub Check: coverage-windows
  • GitHub Check: coverage-linux-without-intl
  • GitHub Check: coverage-linux
🔇 Additional comments (2)
test/common/nsolid-grpc-agent/client.js (1)

59-74: Ensure the 1-second delay is sufficient for trace capture.
Switching to a delayed setTimeout() block allows asynchronous trace recording. However, if slower environments exceed one second before the agent processes or exports the trace, the test may yield inconsistent results. Consider verifying or making the delay configurable if necessary.

test/agents/test-grpc-tracing.mjs (1)

1-280: Comprehensive test suite appears solid.
This file thoroughly tests both HTTP and custom traces, including array-typed attributes. The structure is clear, and checks for resource attributes and various span types are well-organized.

Comment thread agents/otlp/src/otlp_common.cc
santigimeno added a commit that referenced this pull request Apr 16, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
PR-URL: #293
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
@santigimeno
Copy link
Copy Markdown
Member Author

Landed in 354e74b

@santigimeno santigimeno deleted the santi/otlp_extra_attrs branch April 16, 2025 07:41
santigimeno added a commit that referenced this pull request May 1, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
PR-URL: #293
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
santigimeno added a commit that referenced this pull request May 2, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
PR-URL: #293
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
santigimeno added a commit that referenced this pull request May 7, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
PR-URL: #293
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
santigimeno added a commit that referenced this pull request May 7, 2025
Which was overlooked in the initial implementation.
Add tests covering the case.

Fixes: nodesource/nsolid-roadmap#29
PR-URL: #293
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants