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 #3636

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

Conversation

Manancode
Copy link

@Manancode Manancode commented Feb 2, 2025

Solves Tutorials: Correlation IDs #9

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

scrnli_dGj9v7jaGuyrnC

Summary by CodeRabbit

  • Documentation
    • Added a new guide outlining the use of correlation IDs for distributed tracing and observability in event-driven systems.
    • The guide covers key concepts, implementation strategies, and best practices for tracking and debugging business transactions across multiple services.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

A new documentation guide titled Correlation IDs has been added. The guide explains the role of correlation IDs in AsyncAPI for distributed tracing within event-driven architectures. It covers the definition, importance, and various implementation methods including YAML examples and a practical Node.js AMQP usage example that demonstrates generating, propagating, and logging correlation IDs. The document outlines best practices for unique ID generation and consistent usage across services.

Changes

File Change Summary
markdown/.../correlation-ids.md New document added explaining correlation IDs for distributed tracing. Includes definitions, YAML examples (order processing channel), and a Node.js AMQP implementation.

Sequence Diagram(s)

sequenceDiagram
    participant Publisher as Order Publisher
    participant AMQP as AMQP Broker
    participant Consumer as Order Consumer

    Publisher->>AMQP: Generate & send order message with correlation ID in headers
    AMQP->>Consumer: Deliver order message with correlation ID
    Consumer->>Consumer: Log and trace message using the correlation ID
Loading

Poem

I'm a bunny hopping through lines of code,
With correlation IDs my traces explode!
Messages travel far with a unique, swift flair,
Guiding each order with exacting care.
Hopping and coding, a joyful affair!
🐰✨


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 2, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 851dc6e
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/679eb6d482f2e100080d7b13
😎 Deploy Preview https://deploy-preview-3636--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 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8993195) to head (851dc6e).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3636   +/-   ##
=========================================
  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.

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)

7-9: Introduction Section Clarity

The introduction provides a concise and informative overview of the guide. Consider adding a brief pointer or a link to further reading (e.g., a link to AsyncAPI documentation) to help users dive deeper into the context if needed.


10-17: Correlation IDs Overview and Bullet List

The explanation of key components (Original Request, Message Chain, and Correlation ID) is clear and lays a solid foundation.

  • Suggestion: In the bullet for "Message Chain" (line 15), consider adding an article for better readability (e.g., "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)


93-118: Node.js Example: publishOrder Method

The publishOrder method correctly generates a correlation ID and includes it in both the message and the headers.

  • Suggestion: While the example code is instructional, consider a comment noting that in production code, additional error handling might be added around the AMQP calls.

120-134: Node.js Example: consumeOrder Method

The consume function correctly retrieves and logs the correlation ID.

  • Suggestion: Consider wrapping the message processing (e.g., the JSON parsing on line 126) in a try-catch block to handle potential parsing errors gracefully, ensuring robust error handling in real-world scenarios.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8993195 and 851dc6e.

📒 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 (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (11)
markdown/docs/tutorials/correlation-ids.md (11)

1-6: Front Matter and Metadata Structure

The YAML front matter is well-formed and clearly sets the title, description, and weight for the tutorial. This metadata will help with proper ordering and navigation on the website.


18-25: Purpose of Correlation IDs

This section effectively outlines why correlation IDs are important, with clear, bulleted points. The structure is easy to follow.


26-32: Implementation Methods Overview

The list of methods for implementing correlation IDs (Message Headers, Payload Fields, Middleware) is straightforward and informative.


35-78: AsyncAPI YAML Example

The YAML snippet is comprehensive and well-formatted. It clearly demonstrates how to define correlation IDs within an AsyncAPI specification, including the proper placement in message headers.

  • Suggestion: You might mention, optionally, any reference to standards like x-correlation-id if it aligns with industry practices, though the current example is perfectly acceptable per the tutorial’s intent.

80-82: Practical Implementation Introduction

The introductory text for the Node.js with AMQP example sets the stage nicely for the code example that follows.


83-92: Node.js Example: Module Imports and Connection Setup

The import statements and the connect method of OrderService are implemented clearly. The asynchronous connection to AMQP and channel creation are well demonstrated.


137-158: Usage Example and Main Function

The usage example clearly demonstrates how to both consume and publish orders. This practical snippet ties the tutorial together effectively.


160-168: Best Practices Section

The best practices for implementing correlation IDs are well outlined and easy to follow. This section adds significant practical value to the tutorial by summarizing the key takeaways.


169-182: Mermaid Sequence Diagram

The sequence diagram provides an effective visual representation of how correlation IDs are propagated through the system. It enhances the documentation by offering a clear, concise flow of interactions.


184-190: Monitoring and Debugging Guidelines

This section is succinct and effectively stresses the importance of correlation IDs in tracking, analyzing, and debugging distributed transactions.


191-196: Conclusion and Final Reminder

The conclusion reiterates the importance of correlation IDs and the “Remember” block offers a helpful tip for implementation. The structure is clear and reinforces the overall message of the tutorial.

@Manancode
Copy link
Author

Manancode commented Feb 2, 2025

One of the tests is failing during the artifact upload step when using the lighthouse-ci-action.
Error: Create Artifact Container failed: The artifact name lighthouse-results is not valid.

The issue appears to be related to the artifact name lighthouse-results. The artifact name should be changed to a valid format.

I would be happy to raise a PR to update the default artifact name if this is confirmed as an issue

Copy link
Collaborator

@TRohit20 TRohit20 left a comment

Choose a reason for hiding this comment

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

Hey @Manancode , Is this PR ready for review?

CC @fmvilas or @derberg can one of you give a technical go-ahead for the same first please?

@Manancode
Copy link
Author

Yes @TRohit20 the PR is ready to review. Please go through the content and diagrams used in the deployed-preview

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.

2 participants