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

docs: add correlation IDs tutorial to address distributed tracing #3699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Manancode
Copy link

@Manancode Manancode commented Feb 17, 2025

Solves Tutorials:Correlation IDs

Added new tutorial explaining correlation IDs and their implementation in AsyncAPI

Tutorial includes:
Introduction to correlation IDs in event-driven architectures
Practical implementation examples using Node.js and AMQP
AsyncAPI specification examples showing how to define correlation IDs
Best practices and monitoring guidance
Sequence diagram for visual understanding

408833954-a77914bb-e1f8-4999-a39d-811386400cd6

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive guide on correlation IDs explaining their role in distributed systems for tracking, debugging, and performance monitoring.
    • The guide offers practical examples, implementation tips, and best practices for enhanced observability and consistent transaction tracking.
    • This resource provides valuable insights for both developers and operations teams in maintaining robust systems.

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Walkthrough

A new documentation file titled Correlation IDs has been added. It explains the purpose and implementation of correlation IDs in AsyncAPI for distributed tracing, describes various methods of implementation (e.g., using message headers, payload fields, middleware), and provides a practical Node.js with AMQP example. The guide also highlights best practices and includes a sequence diagram illustrating the flow of messages across services.

Changes

File(s) Change Summary
markdown/docs/tutorials/correlation-ids.md Added new documentation for Correlation IDs, covering their significance in distributed tracing, implementation methods, Node.js AMQP example, and best practices.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Middleware
    participant Broker
    participant Service
    Client->>Middleware: Generate & attach Correlation ID
    Middleware->>Broker: Publish message with Correlation ID
    Broker->>Service: Deliver message including Correlation ID
    Service->>Middleware: Log/tracing using Correlation ID
Loading

Poem

I’m a hopping rabbit, light and free,
Skipping through docs with great glee.
Correlation IDs align every trace,
Guiding messages in perfect pace.
With carrots 🥕 and code so bright,
I cheer these changes into the night!
Hoppy coding to all in sight!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

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

netlify bot commented Feb 17, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7706d9c
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67b38d457ff9880008373163
😎 Deploy Preview https://deploy-preview-3699--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1b240da) to head (7706d9c).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3699   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          732       732           
=========================================
  Hits           732       732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Manancode
Copy link
Author

Hi @TRohit20 @fmvilas @derberg,

The previous PR got closed because I didnt checked I had a PR open and deleted the head repository. The PR is ready to review. Please go through the content and diagrams used.

Copy link
Contributor

@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

🧹 Nitpick comments (4)
markdown/docs/tutorials/correlation-ids.md (4)

14-16: Grammatical Improvement for Bullet List
Consider rephrasing the "Message Chain" description to include an article for clarity.
For example, update:

- - Message Chain: Series of messages exchanged between different services
+ - Message Chain: A series of messages exchanged between different services
🧰 Tools
🪛 LanguageTool

[uncategorized] ~15-~15: Possible missing article found.
Context: ...a business transaction - Message Chain: Series of messages exchanged between different...

(AI_HYDRA_LEO_MISSING_A)


26-32: Overview of Implementation Methods
The section outlining different methods (Message Headers, Payload Fields, Middleware) for implementing correlation IDs is clear.
Consider, as a future enhancement, adding a brief note on the potential trade-offs or use-case scenarios for each method.


35-78: AsyncAPI YAML Snippet Validation and Consistency
The YAML snippet effectively demonstrates how to define correlation IDs in an AsyncAPI document. The structure and schema definitions (including the header for "correlation-id") are well presented.
Note: There is a minor naming convention discrepancy. The header property in the YAML is defined as "correlation-id" (with a hyphen), while in the Node.js example later, the AMQP options use both correlationId (camelCase) and a header key of 'correlation-id'. Consider ensuring consistency in naming conventions where possible to avoid confusion.


81-156: Practical Node.js Implementation Example
The Node.js code example is clear and practical. It demonstrates connecting to an AMQP broker, publishing messages with correlation IDs, and consuming messages while logging the correlation ID.

  • Good Points:
    • Usage of uuidv4() for generating unique IDs.
    • Clear demonstration of inserting the correlation ID into both AMQP message properties and headers.
  • Suggestions:
    • Consider parameterizing the AMQP connection string (currently hardcoded as 'amqp://localhost') to improve reusability and ease testing in different environments.
    • It may be beneficial to include basic error handling (e.g., try/catch blocks) around asynchronous operations to make the sample more production-ready.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b240da and 7706d9c.

📒 Files selected for processing (1)
  • markdown/docs/tutorials/correlation-ids.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
markdown/docs/tutorials/correlation-ids.md

[uncategorized] ~15-~15: Possible missing article found.
Context: ...a business transaction - Message Chain: Series of messages exchanged between different...

(AI_HYDRA_LEO_MISSING_A)

⏰ Context from checks skipped due to timeout of 180000ms (5)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Lighthouse CI
🔇 Additional comments (9)
markdown/docs/tutorials/correlation-ids.md (9)

1-5: Front Matter Completeness and Clarity
The YAML front matter is well-structured with a clear title, description, and weight. This provides sufficient metadata for the document.


7-9: Introduction Section Clarity
The introduction succinctly explains the concept of correlation IDs within event-driven architectures. It sets a solid context for the reader.


10-17: Explanation of Correlation IDs Components
The "Correlation IDs" section clearly describes the key components (Original Request, Message Chain, Correlation ID) involved in distributed tracing.

Nitpick: Consider rewording the bullet for "Message Chain" to improve grammatical clarity (see next comment).

🧰 Tools
🪛 LanguageTool

[uncategorized] ~15-~15: Possible missing article found.
Context: ...a business transaction - Message Chain: Series of messages exchanged between different...

(AI_HYDRA_LEO_MISSING_A)


18-25: Benefits of Using Correlation IDs
The "Why Use Correlation IDs?" section provides a concise and comprehensive list of benefits, which is very informative.


158-166: Best Practices Section
The "Best Practices" section provides clear, actionable guidelines for using correlation IDs, emphasizing ID uniqueness, propagation, logging, documentation, and accessibility.


167-180: Mermaid Sequence Diagram Clarity
The provided sequence diagram effectively visualizes the message flow and the usage of correlation IDs across services. The diagram enhances comprehension of the overall system behavior.


182-188: Monitoring and Debugging Guidance
This section clearly outlines how correlation IDs can be leveraged for effective monitoring and debugging, which complements the tutorial content well.


189-191: Conclusion Section
The conclusion succinctly reiterates the importance of correlation IDs for observability. It effectively wraps up the tutorial.


192-194: Reminder Block Emphasis
The "Remember" block reinforces the necessity of early generation and consistent propagation of correlation IDs. This additional reminder is valuable for best practices adherence.

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.

1 participant