Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 25, 2025

This PR integrates Azure Application Insights with OpenTelemetry and the .NET Profiler to provide comprehensive monitoring and performance profiling for the ASP.NET Core application.

Changes Made

Package Dependencies

  • Added Azure.Monitor.OpenTelemetry.AspNetCore (v1.3.0) for OpenTelemetry integration
  • Added Microsoft.ApplicationInsights.Profiler.AspNetCore (v2.6.0) for .NET Profiler support

Configuration Updates

  • Program.cs: Added OpenTelemetry configuration with UseAzureMonitor()
  • Program.cs: Added Application Insights telemetry services with AddApplicationInsightsTelemetry()
  • Program.cs: Added Service Profiler with AddServiceProfiler()
  • Program.cs: Added required using statement for Azure.Monitor.OpenTelemetry.AspNetCore

Environment Configuration

  • The application now automatically reads the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable
  • All logs and exceptions are automatically sent to Application Insights
  • Compatible with containerized deployment using the existing Dockerfile

Documentation & Testing

  • README.md: Updated with APPLICATIONINSIGHTS_CONNECTION_STRING environment variable documentation
  • README.md: Updated .NET SDK requirement to 9.0
  • ApplicationInsightsTests.cs: Added basic integration tests to verify Application Insights services are properly registered

Runtime Configuration

Set the following environment variable to enable Application Insights:

APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=your-instrumentation-key-here;IngestionEndpoint=https://region.in.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/"

Benefits

  • Telemetry: Automatic collection of requests, dependencies, exceptions, and custom metrics
  • Logging: All application logs are sent to Application Insights
  • Profiling: .NET Profiler provides detailed performance insights
  • Monitoring: OpenTelemetry integration provides distributed tracing
  • Container Support: Works seamlessly in containerized environments

This implementation follows Microsoft's best practices from the official documentation for OpenTelemetry and Application Insights integration.

Fixes #740.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.visualstudio.microsoft.com
    • Triggering command: wget REDACTED -O dotnet-sdk.tar.gz (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 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] Add azure application insights Add Azure Application Insights integration with OpenTelemetry and .NET Profiler Jun 25, 2025
Copilot AI requested a review from BenjaminMichaelis June 25, 2025 16:45
Copilot finished work on behalf of BenjaminMichaelis June 25, 2025 16:45
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review June 25, 2025 23:50
Ensures Azure Application Insights and Service Profiler are
only configured in non-development environments to avoid
conflicts and resource consumption during local development.
Adds the Application Insights connection string to the container app configuration for both staging and production environments.

This allows collecting telemetry data from the application.
@BenjaminMichaelis BenjaminMichaelis changed the title Add Azure Application Insights integration with OpenTelemetry and .NET Profiler feat: Add Azure Application Insights integration with OpenTelemetry and .NET Profiler Jun 27, 2025
Removes the Application Insights tests, which appear unnecessary
at this stage. Adds a functional test for the health check endpoint.
@BenjaminMichaelis BenjaminMichaelis enabled auto-merge (squash) June 27, 2025 02:40
@BenjaminMichaelis BenjaminMichaelis merged commit a40b482 into main Jun 27, 2025
5 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the copilot/fix-740 branch June 27, 2025 04:20
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.

Add azure application insights

2 participants