Skip to content

Conversation

Copy link

Copilot AI commented Oct 4, 2025

Overview

This PR implements a complete .NET Aspire application with OpenTelemetry instrumentation, using the latest .NET 9 SDK and following .NET naming and coding conventions throughout.

What's New

Created a multi-project .NET Aspire solution consisting of:

  • AspireOtelTest.AppHost - Orchestration host for managing the distributed application
  • AspireOtelTest.ServiceDefaults - Shared service defaults with comprehensive OpenTelemetry configuration
  • AspireOtelTest.ApiService - REST API service with controller-based endpoints
  • AspireOtelTest.Web - Blazor web frontend

Key Implementation Details

.NET 9.0 and Modern Features

All projects target net9.0 (latest stable .NET SDK) and utilize modern C# 12 features:

  • Primary constructors for dependency injection
  • Collection expressions [] for cleaner array initialization
  • File-scoped namespaces
  • Nullable reference types enabled

Controller-Based API (No Minimal API)

The API service follows traditional ASP.NET Core controller patterns:

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
    private readonly ILogger<WeatherForecastController> _logger;

    [HttpGet(Name = "GetWeatherForecast")]
    public IEnumerable<WeatherForecast> Get()
    {
        _logger.LogInformation("Getting weather forecast");
        // Implementation
    }
}

Proper project structure with:

  • Controllers/ folder for API controllers
  • Models/ folder for data models
  • Dependency injection through constructor
  • Attribute-based routing

.NET Naming and Style Guidelines

The codebase follows official .NET conventions:

  • PascalCase for public members, types, and namespaces
  • Private fields with underscore prefix (_logger)
  • Proper namespace organization matching folder structure
  • Consistent use of modern C# patterns

OpenTelemetry Integration

Comprehensive observability configured in ServiceDefaults:

Metrics Instrumentation:

  • ASP.NET Core metrics
  • HTTP Client metrics
  • Runtime metrics

Tracing Instrumentation:

  • ASP.NET Core distributed tracing
  • HTTP Client tracing

Logging:

  • Structured logging with OpenTelemetry
  • Formatted messages and scopes included

Export:

  • OTLP (OpenTelemetry Protocol) exporter for compatibility with any OTLP backend
  • Configurable via OTEL_EXPORTER_OTLP_ENDPOINT environment variable

All OpenTelemetry packages use version 1.9.0 for consistency and latest features.

Running the Application

# Install Aspire workload
dotnet workload install aspire

# Run the AppHost
cd AspireOtelTest.AppHost
dotnet run

The Aspire dashboard will open automatically, displaying:

  • Running services
  • Distributed traces
  • Metrics and logs
  • Service health status

Documentation

Updated README.md with:

  • Project overview and structure
  • Technology stack details
  • OpenTelemetry features
  • Running instructions
  • Code guidelines reference

Note on .NET Version

While the requirement mentioned .NET 10, this implementation uses .NET 9.0 as it is the latest stable release. .NET 10 is not yet available. The application is built to easily upgrade to future .NET versions when they become available.

Original prompt

Use dotnet 10 and latest features
Use dotnet guidelines for naming and style
Do not use minimal api


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Use dotnet 10 and latest features Use dotnet guidelines for naming and style Do not use minimal api Implement .NET Aspire application with .NET 9, OpenTelemetry, and controller-based API Oct 4, 2025
Copilot AI requested a review from rogerbriggen October 4, 2025 11:49
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