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

Disable xray tracing (middleware) #3323

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

Disable xray tracing (middleware) #3323

wants to merge 1 commit into from

Conversation

CarsonF
Copy link
Member

@CarsonF CarsonF commented Oct 31, 2024

It turns out to be not so useful in its current state.
There is a performance hit to run this logic so disabling seems appropriate.

I would like to look at OpenTelemetry next.
It seems to be the actual standard, has better support, and AWS integrates with it (in a different way), and can provide a better UI via the standardized ingress.

Summary by CodeRabbit

  • New Features

    • XRay tracing functionality has been disabled to improve performance, while maintaining the existing request handling logic.
  • Bug Fixes

    • Ensured that error handling for various HTTP status codes remains intact despite the changes made to the tracing functionality.

Copy link

coderabbitai bot commented Oct 31, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request focus on the XRayMiddleware class within the src/core/tracing/xray.middleware.ts file. A new decorator, @Disabled('XRay tracing is not really helping us'), has been added to the onRequest method, which is already wrapped with the @GlobalHttpHook() decorator. This modification disables XRay tracing while maintaining the method's functionality as a global HTTP hook. The internal logic of the method, including request processing and error handling, remains unchanged.

Changes

File Change Summary
src/core/tracing/xray.middleware.ts Added @Disabled('XRay tracing is not really helping us') decorator to onRequest method.

Poem

In the meadow where bunnies play,
XRay tracing has gone away.
With a hop and a skip, we disable the trace,
Keeping our paths a lighter space.
So let’s dance and twirl, with joy we embrace! 🐇✨


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

@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

🧹 Outside diff range and nitpick comments (1)
src/core/tracing/tracing.module.ts (1)

Line range hint 16-24: Review the complete XRay integration architecture.

While the middleware application is disabled, the module still:

  1. Initializes XRay configuration in onModuleInit
  2. Registers XRay-related providers
  3. Maintains the XRayMiddleware as a global interceptor

This partial disablement might still incur performance overhead and could complicate the future transition to OpenTelemetry.

Consider:

  1. Creating a feature flag in ConfigService to completely disable XRay integration
  2. Conditionally registering providers based on this flag
  3. Creating a separate module for the planned OpenTelemetry integration

Example provider registration with feature flag:

@Module({
  imports: [LoggerModule],
  providers: [
    TracingService,
    {
      provide: APP_INTERCEPTOR,
      useFactory: (config: ConfigService) => {
        return config.xray.enabled ? new XRayMiddleware() : null;
      },
      inject: [ConfigService],
    },
    // ... other providers
  ],
})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 80b4b6f and 2f8b0f2.

📒 Files selected for processing (1)
  • src/core/tracing/tracing.module.ts (1 hunks)
🔇 Additional comments (1)
src/core/tracing/tracing.module.ts (1)

34-35: Verify the impact of disabling XRay tracing.

Let's ensure there are no direct dependencies on XRay tracing in the codebase.

✅ Verification successful

Disabling XRay tracing is safe but requires configuration awareness

The code analysis reveals that XRay tracing is an optional feature that's already properly handled:

  • The middleware is already safely disabled through commenting out consumer.apply(XRayMiddleware).forRoutes('*')
  • The implementation includes a safety check: tracing is automatically disabled when no daemon address is configured (if (!this.config.xray.daemonAddress))
  • The XRay setup is properly isolated in the tracing module with no direct dependencies from other parts of the application
  • The trace context is only used for AWS XRay specific functionality and doesn't affect other application logic
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for XRay middleware usage and dependencies

# Check for direct XRay middleware usage
echo "Checking for XRay middleware usage..."
rg -l "XRayMiddleware" --type ts

# Check for direct segment access
echo "Checking for direct XRay segment access..."
rg -l "XRay\.getSegment" --type ts

# Check for trace ID usage
echo "Checking for trace ID usage..."
rg -l "traceId" --type ts

Length of output: 417


Script:

#!/bin/bash
# Let's examine the XRay middleware implementation and its usage

# Check the content of XRay middleware
echo "=== XRay Middleware Implementation ==="
cat src/core/tracing/xray.middleware.ts

# Check the full context of tracing module
echo -e "\n=== Tracing Module Implementation ==="
cat src/core/tracing/tracing.module.ts

# Look for any AWS XRay imports or configurations
echo -e "\n=== AWS XRay Related Imports ==="
rg -l "aws-xray" --type ts

# Check for any trace context or correlation ID patterns
echo -e "\n=== Trace Context Usage ==="
rg "(?i)(trace|correlation).*id" --type ts

Length of output: 8144

src/core/tracing/tracing.module.ts Outdated Show resolved Hide resolved
Copy link

@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

🧹 Outside diff range and nitpick comments (1)
src/core/tracing/xray.middleware.ts (1)

Line range hint 16-121: Consider documenting migration plans and cleaning up unused code.

While disabling the XRay tracing addresses the immediate performance concerns, consider the following improvements:

  1. Add TODO comments about the planned OpenTelemetry migration
  2. Document the current disabled state in the class JSDoc
  3. Consider moving the XRay implementation to a separate file/folder to prepare for future removal once OpenTelemetry is implemented

This will help maintain clarity about the current state and future plans.

Would you like me to provide a code snippet with the suggested documentation improvements?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2f8b0f2 and 03671e1.

📒 Files selected for processing (1)
  • src/core/tracing/xray.middleware.ts (2 hunks)
🔇 Additional comments (1)
src/core/tracing/xray.middleware.ts (1)

9-9: LGTM: Import statement is correctly placed.

The import of the Disabled decorator is properly organized with other imports.

src/core/tracing/xray.middleware.ts Show resolved Hide resolved
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