Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Jul 19, 2025

closes #11136

Summary by CodeRabbit

  • New Features

    • Added health check endpoints for improved application monitoring, including /health and /alive (development environment only).
    • Enhanced OpenTelemetry support with instrumentation for Entity Framework Core and Hangfire.
  • Refactor

    • Simplified and renamed middleware and service configuration methods for clarity.
    • Streamlined environment-specific logic and removed obsolete conditional code.
  • Style

    • Improved XML formatting for package configuration files.

@ysmoradi ysmoradi requested a review from Copilot July 19, 2025 17:51
@coderabbitai
Copy link

coderabbitai bot commented Jul 19, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update the boilerplate project template to enhance OpenTelemetry instrumentation by adding support for Entity Framework Core and Hangfire. Middleware and extension methods are refactored, removing Aspire-specific logic and replacing it with generalized service defaults and health check mappings. XML formatting and package references are updated accordingly.

Changes

File(s) Change Summary
.../Directory.Packages.props Reformatted XML indentation; added OpenTelemetry.Instrumentation.EntityFrameworkCore and Hangfire package versions.
.../Boilerplate.Server.Shared.csproj Added package references for OpenTelemetry.Instrumentation.EntityFrameworkCore and Hangfire.
.../Extensions/WebApplicationBuilderExtensions.cs Renamed and refactored service defaults method; added EF Core and Hangfire OpenTelemetry instrumentation; removed Aspire-specific code and comments.
.../Extensions/WebApplicationExtensions.cs Removed MapAspire method; added MappAppHealthChecks method for development health check endpoints.
.../Boilerplate.Server.Api/Program.Middlewares.cs
.../Boilerplate.Server.Web/Program.Middlewares.cs
Replaced app.MapAspire() with app.MappAppHealthChecks(); removed conditional compilation for Aspire.

Sequence Diagram(s)

sequenceDiagram
    participant Builder as WebApplicationBuilder
    participant App as WebApplication

    Builder->>Builder: AddServerSharedServices()
    Builder->>Builder: AddServiceDefaults()
    Builder->>Builder: Configure OpenTelemetry (ASP.NET Core, HTTP, EF Core, Hangfire)
    App->>App: MappAppHealthChecks()
    App->>App: Map /health and /alive endpoints (development only)
Loading

Poem

🐇
Hopping through code with OpenTelemetry flair,
EntityFramework and Hangfire now get their share.
Aspire hops away, health checks take the stage,
With neater XML, we turn a new page.
The boilerplate garden grows ever more bright—
Instrumented, healthy, and coded just right!

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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
Contributor

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.

Pull Request Overview

This PR improves OpenTelemetry configuration in the bit Boilerplate by removing Aspire-specific conditional compilation directives and enhancing telemetry instrumentation. The changes make OpenTelemetry features always available rather than conditionally compiled based on Aspire usage.

Key changes:

  • Removed conditional compilation directives (//#if (aspire == true)) around OpenTelemetry and health check functionality
  • Added Entity Framework Core and Hangfire instrumentation to OpenTelemetry tracing
  • Enhanced HTTP client configuration with improved HTTP/2 and HTTP/3 connection handling

Reviewed Changes

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

Show a summary per file
File Description
Program.Middlewares.cs (Web) Replace conditional MapAspire() call with always-available MappAppHealthChecks()
Program.Middlewares.cs (Api) Replace conditional MapAspire() call with always-available MappAppHealthChecks()
WebApplicationExtensions.cs Rename MapAspire method to MappAppHealthChecks and remove conditional compilation
WebApplicationBuilderExtensions.cs Remove Aspire conditionals, add EF Core/Hangfire instrumentation, enhance HTTP client config
Boilerplate.Server.Shared.csproj Add package references for EF Core and Hangfire OpenTelemetry instrumentation
Directory.Packages.props Define versions for new OpenTelemetry instrumentation packages
Comments suppressed due to low confidence (3)

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs:112

  • The method name 'MappAppHealthChecks' appears to have a typo. It should be 'MapAppHealthChecks' (missing one 'p') to follow consistent naming conventions with other Map methods.
        app.MappAppHealthChecks();

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationExtensions.cs:11

  • The method name 'MappAppHealthChecks' appears to have a typo. It should be 'MapAppHealthChecks' (missing one 'p') to follow consistent naming conventions with other Map methods.
    public static WebApplication MappAppHealthChecks(this WebApplication app)

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs:53

  • The method name 'MappAppHealthChecks' appears to have a typo. It should be 'MapAppHealthChecks' (missing one 'p') to follow consistent naming conventions with other Map methods.
        app.MappAppHealthChecks();

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

🧹 Nitpick comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props (1)

2-120: Consider separating formatting changes from functional changes.

The entire file has been reformatted from 4-space to 2-space indentation. While the formatting is consistent, this wholesale formatting change makes it harder to identify the actual functional changes (adding the two OpenTelemetry package versions). Consider keeping formatting changes separate from functional changes to improve code review clarity.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs (1)

66-72: Update the outdated comment on line 67.

The method rename from AddAspireServiceDefaults to AddServiceDefaults is good, but the comment "Also knows as AddServiceDefaults" is now incorrect since the method IS AddServiceDefaults.

-    /// Also knows as AddServiceDefaults
+    /// Configures service defaults for the application
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between cd50327 and 2a057a5.

📒 Files selected for processing (6)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs (4 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationExtensions.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build and test
🔇 Additional comments (8)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs (1)

53-53: LGTM! Middleware simplification looks good.

The replacement of app.MapAspire() with app.MappAppHealthChecks() aligns with the goal of removing Aspire-specific logic while maintaining essential health check functionality. This change simplifies the middleware pipeline and focuses on core monitoring capabilities.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj (1)

21-22: Good addition of OpenTelemetry instrumentation packages.

Adding Entity Framework Core and Hangfire instrumentation extends observability coverage to key application components, which aligns well with the PR objective of improving OpenTelemetry boilerplate.

Note that both packages are in beta versions (1.12.0-beta.2 and 1.12.0-beta.1 respectively), so ensure compatibility and stability testing in your environment.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs (1)

112-112: Consistent middleware change across server projects.

The replacement of app.MapAspire() with app.MappAppHealthChecks() maintains consistency with the API server middleware configuration, which is good for maintainability and uniform behavior across the application.

src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props (1)

32-33: Package version definitions for OpenTelemetry instrumentation.

The version definitions for the new OpenTelemetry instrumentation packages are appropriate and support the Central Package Management approach. The beta versions are acceptable for these specialized instrumentation libraries.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationExtensions.cs (1)

11-28: Well-implemented health check extension method.

The MappAppHealthChecks method is a solid replacement for the removed MapAspire functionality. Key strengths:

  • Security-conscious: Restricts health check endpoints to development environments only
  • Flexible monitoring: Provides both comprehensive (/health) and minimal (/alive) health check endpoints
  • Clear documentation: Includes helpful security guidance and endpoint descriptions
  • Proper implementation: Follows .NET extension method conventions correctly

This focused approach is preferable to the broader Aspire service mappings for a boilerplate template.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs (3)

25-25: LGTM! Method call correctly updated to match the renamed method.

The change maintains consistency with the method rename from AddAspireServiceDefaults to AddServiceDefaults.


88-92: Good addition for HTTP connection performance optimization.

Enabling multiple HTTP/2 and HTTP/3 connections via SocketsHttpHandler is a beneficial performance enhancement that allows for better connection multiplexing.


119-120: Required OpenTelemetry Packages Are Present

I’ve confirmed that the shared project file (Boilerplate.Server.Shared.csproj) includes:

  • <PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" /> (v1.12.0-beta.2)
  • <PackageReference Include="OpenTelemetry.Instrumentation.Hangfire" /> (v1.12.0-beta.1)

The calls to .AddEntityFrameworkCoreInstrumentation() and .AddHangfireInstrumentation() in WebApplicationBuilderExtensions.cs are fully supported. Merging as-is.

@ysmoradi ysmoradi merged commit 236233c into bitfoundation:develop Jul 21, 2025
3 checks passed
@ysmoradi ysmoradi deleted the 11136 branch July 21, 2025 16:15
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.

Boilerplate project template OpenTelemetry needs improvements

1 participant