Skip to content

chore: Trace Azure DevOps workItems queries #11132

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

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

Dschoordsch
Copy link
Contributor

@Dschoordsch Dschoordsch commented Apr 8, 2025

Description

Relates to #10906
[Please include a summary of the changes and the related issue]

Demo

[If possible, please include a screenshot or gif/video, it'll make it easier for reviewers to understand the scope of the changes and how the change is supposed to work. If you're introducing something new or changing the existing patterns, please share a Loom and explain what decisions you've made and under what circumstances]

Testing scenarios

[Please list all the testing scenarios a reviewer has to check before approving the PR]

  • Scenario A

    • Step 1
    • Step 2...
  • Scenario B

    • Step 1
    • Step 2....

Final checklist

  • I checked the code review guidelines
  • I have added Metrics Representative as reviewer(s) if my PR invovles metrics/data/analytics related changes
  • I have performed a self-review of my code, the same way I'd do it for any other team member
  • I have tested all cases I listed in the testing scenarios and I haven't found any issues or regressions
  • Whenever I took a non-obvious choice I added a comment explaining why I did it this way
  • I added the label Skip Maintainer Review Indicating the PR only requires reviewer review and can be merged right after it's approved if the PR introduces only minor changes, does not contain any architectural changes or does not introduce any new patterns and I think one review is sufficient'
  • PR title is human readable and could be used in changelog

Summary by CodeRabbit

  • New Features

    • Improved the responsiveness and reliability of data retrieval for work items and project details.
    • Enhanced concurrent handling to ensure smoother operation under load.
  • Refactor

    • Streamlined the processing of asynchronous operations for more efficient error detection and recovery.

@github-actions github-actions bot added the size/m label Apr 8, 2025
const {error: accessibleError, accessibleOrgs} = await this.getAccessibleOrgs(id)
if (!!accessibleError) return {error: accessibleError, projects: null}

await Promise.allSettled(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apart from tracing, I only changed this to be parallel

@Dschoordsch Dschoordsch requested a review from Copilot April 8, 2025 13:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

packages/server/utils/AzureDevOpsServerManager.ts:527

  • The variable 'allWorkItems' is declared but never populated. Consider pushing the retrieved work items (e.g., fullWorkItems) into 'allWorkItems' within the Promise.allSettled mapping to ensure the returned data is complete.
accessibleOrgs.map(async (resource) => {

@Dschoordsch
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Apr 8, 2025

Walkthrough

This change enhances the AzureDevOpsServerManager class by introducing the dd-trace library to add tracing to several asynchronous methods. The modifications wrap core logic within tracer.trace calls to provide performance monitoring and improved observability while preserving the existing error handling and business logic. Additionally, some methods have updated implementations, such as changing the way work items are mapped and utilising Promise.allSettled for managing concurrent asynchronous calls.

Changes

File(s) Change Summary
packages/.../AzureDevOpsServerManager.ts Added dd-trace tracing to methods (getWorkItemData, executeWiqlQuery, getWorkItems, getAllUserWorkItems, getAllUserProjects, getProjectProcessTemplate, getProcessTemplate). Modified the mapping in executeWiqlQuery and introduced Promise.allSettled in getAllUserWorkItems. Also updated method signatures while preserving error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Manager as AzureDevOpsServerManager
    participant Tracer as dd-trace

    Client->>Manager: Call method (e.g., getWorkItemData)
    Manager->>Tracer: tracer.trace("getWorkItemData", () => { ... })
    Tracer-->>Manager: Execute wrapped logic with tracing
    Manager->>Client: Return traced result
Loading

Possibly related PRs

Suggested labels

size/s

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
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 (1)
packages/server/utils/AzureDevOpsServerManager.ts (1)

433-433: Consider simplifying double-negation patterns.

While functionally correct, using double-negation (!!) is flagged by static analysis. Consider using more explicit type checking or Boolean conversion.

- if (!!fields ? {ids, fields: fields} : {ids, $expand: 'Links'})
+ if (fields ? {ids, fields: fields} : {ids, $expand: 'Links'})

- if (!!meError || !azureDevOpsUser) return {error: meError, projects: null}
+ if (meError || !azureDevOpsUser) return {error: meError, projects: null}

- if (!!workItemsError) {
+ if (workItemsError) {

- if (!!workItems) {
+ if (workItems) {

- if (!!fullWorkItemsError) {
+ if (fullWorkItemsError) {

- if (!!accessibleError) return {error: accessibleError, projects: null}
+ if (accessibleError) return {error: accessibleError, projects: null}

Also applies to: 524-524, 536-536, 541-541, 546-546, 588-588

🧰 Tools
🪛 Biome (1.9.4)

[error] 433-433: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7134bbb and 61b7bf1.

📒 Files selected for processing (1)
  • packages/server/utils/AzureDevOpsServerManager.ts (5 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/server/utils/AzureDevOpsServerManager.ts

[error] 433-433: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 524-524: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 536-536: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 541-541: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 546-546: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 588-588: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

🔇 Additional comments (8)
packages/server/utils/AzureDevOpsServerManager.ts (8)

2-2: Nice addition of tracing capabilities.

Adding the dd-trace library is a good move for improving observability and performance monitoring of the Azure DevOps operations.


426-450: Good implementation of tracing for getWorkItemData.

The method has been properly wrapped with the tracer while maintaining the existing business logic. This will provide valuable performance insights without affecting functionality.

🧰 Tools
🪛 Biome (1.9.4)

[error] 433-433: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


452-479: Clean implementation of tracing for executeWiqlQuery.

The method has been effectively wrapped with the tracer. The refactored work item mapping (lines 468-470) is more concise and directly extracts only the needed properties (id and url).


487-507: Well-structured tracing implementation for getWorkItems.

The method maintains all its original query construction logic while adding tracing capabilities. The code remains clear and readable.


514-559: Good use of Promise.allSettled for parallel processing.

Apart from adding tracing, this method has been improved by using Promise.allSettled to handle multiple asynchronous calls concurrently, which can improve performance while still properly handling errors.

🧰 Tools
🪛 Biome (1.9.4)

[error] 524-524: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 536-536: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 541-541: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


[error] 546-546: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


579-603: Well-structured tracing for getAllUserProjects.

The method has been properly wrapped with the tracer while maintaining the existing error handling and business logic.

🧰 Tools
🪛 Biome (1.9.4)

[error] 588-588: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


617-638: Good implementation of tracing for getProjectProcessTemplate.

The method has been properly wrapped with the tracer while maintaining the existing chain of API calls and error handling.


641-654: Clean tracing implementation for getProcessTemplate.

The method has been well-wrapped with the tracer while preserving the original special case handling for unknown process error codes.

@Dschoordsch Dschoordsch merged commit f2357c8 into master Apr 8, 2025
8 checks passed
@Dschoordsch Dschoordsch deleted the chore/10906/traceAzureDevOpsQueries branch April 8, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant