Skip to content

Vendor OpenTelemetry.Resources.Azure resource detectors#3093

Merged
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/vendorResourceDetector
Jan 28, 2026
Merged

Vendor OpenTelemetry.Resources.Azure resource detectors#3093
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/vendorResourceDetector

Conversation

@rajkumar-rangaraj
Copy link
Member

Description

This PR vendors the OpenTelemetry.Resources.Azure library (version 1.15.0-beta.1) into the NETCORE shared folder to enable Azure resource detection capabilities.

Steps Followed to Vendor Code

  1. Created a New Branch in ApplicationInsights-dotnet repo for these changes.

  2. Synced OpenTelemetry.NET Contrib Repository

    • Cloned the OpenTelemetry.NET Contrib Repository:
      git clone https://github.com/open-telemetry/opentelemetry-dotnet-contrib.git
    • Fetched the tags:
      git fetch --tags
  3. Vendored OpenTelemetry.Resources.Azure

    • Checked out the release tag:
      git checkout tags/Resources.Azure-1.15.0-beta.1
    • Copied the following files into NETCORE/src/Shared/Vendoring/OpenTelemetry.Resources.Azure/:
      • AppServiceResourceDetector.cs
      • AzureContainerAppsResourceDetector.cs
      • AzureResourceBuilderExtensions.cs
      • AzureVmMetaDataRequestor.cs
      • AzureVmMetadataResponse.cs
      • AzureVMResourceDetector.cs
      • ResourceAttributeConstants.cs
      • SourceGenerationContext.cs
    • Excluded: *.csproj, README.md, CHANGELOG.md, AssemblyInfo.cs
  4. Vendored Shared Dependencies

  5. Updated Project Configuration

    • Added all vendored files to NETCORE/src/Shared/Shared.projitems for inclusion in AspNetCore and WorkerService projects
  6. Code Modifications

    • Changed all namespaces to use vendored namespace prefix:
      • OpenTelemetry.Resources.AzureMicrosoft.ApplicationInsights.Shared.Vendoring.OpenTelemetry.Resources.Azure
      • OpenTelemetry.ResourcesMicrosoft.ApplicationInsights.Shared.Vendoring.OpenTelemetry.Resources
      • OpenTelemetry.TraceMicrosoft.ApplicationInsights.Shared.Vendoring.OpenTelemetry.Trace
    • Updated all using statements to reference vendored namespaces
    • Modified public APIs to internal visibility to prevent namespace conflicts
    • Replaced C# 12 collection expressions with backward-compatible syntax for multi-targeting support
    • Updated CHANGELOG.md to document the vendored code

Testing

  • Build succeeds for all target frameworks (net8.0, net9.0, net10.0, netstandard2.0, net462, net472)
  • No namespace conflicts with OpenTelemetry packages
  • Vendored code compiles successfully in AspNetCore and WorkerService projects

Copilot AI review requested due to automatic review settings January 28, 2026 21:14
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 vendors the OpenTelemetry.Resources.Azure library (version 1.15.0-beta.1) into the NETCORE shared folder to enable Azure resource detection capabilities for Azure App Service, Azure VMs, and Azure Container Apps environments.

Changes:

  • Vendored 10 files from OpenTelemetry.Resources.Azure package with modified namespaces to avoid conflicts
  • Added all vendored files to Shared.projitems for inclusion in AspNetCore and WorkerService projects
  • Updated ThirdPartyNotices.txt to include OpenTelemetry .NET Contrib license

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
AppServiceResourceDetector.cs Detects and reports Azure App Service resource attributes from environment variables
AzureContainerAppsResourceDetector.cs Detects Azure Container Apps and Jobs resource attributes
AzureResourceBuilderExtensions.cs Extension methods to register Azure resource detectors with OpenTelemetry ResourceBuilder
AzureVMResourceDetector.cs Detects Azure VM resource attributes via Azure Instance Metadata Service
AzureVmMetaDataRequestor.cs HTTP client wrapper for querying Azure VM metadata endpoint
AzureVmMetadataResponse.cs Data model for Azure VM metadata API response
Guard.cs Input validation utility with polyfills for older target frameworks
ResourceAttributeConstants.cs Constants for Azure-specific resource attribute keys and environment variable names
ResourceSemanticConventions.cs OpenTelemetry semantic convention constants for resource attributes
SourceGenerationContext.cs System.Text.Json source generation context for .NET 6+ performance optimization
Shared.projitems Project configuration to include all vendored files in compilation
ThirdPartyNotices.txt Added OpenTelemetry .NET Contrib license attribution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rajkumar-rangaraj rajkumar-rangaraj enabled auto-merge (squash) January 28, 2026 21:38
@rajkumar-rangaraj rajkumar-rangaraj merged commit 7b1a892 into main Jan 28, 2026
18 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/vendorResourceDetector branch January 28, 2026 21:38
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