Skip to content
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

[AzureMonitorExporter] Integration of OpenTelemetry Resource Detectors #37837

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,14 @@

<ItemGroup Condition="$(MSBuildProjectName.StartsWith('Azure.Monitor.OpenTelemetry'))">
<!-- OpenTelemetry dependency approved for Azure.Monitor.OpenTelemetry.Exporter package only -->
<PackageReference Update="OpenTelemetry" Version="1.5.0" />
<PackageReference Update="OpenTelemetry" Version="1.5.1" />
<PackageReference Update="OpenTelemetry.Exporter.InMemory" Version="1.5.0" />
<PackageReference Update="OpenTelemetry.Extensions.Hosting" Version="1.5.0" />
<PackageReference Update="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.0-beta.1" />
<PackageReference Update="OpenTelemetry.Instrumentation.Http" Version="1.5.0-beta.1" />
<PackageReference Update="OpenTelemetry.Instrumentation.SqlClient" Version="1.5.0-beta.1" />
<PackageReference Update="OpenTelemetry.Extensions.Hosting" Version="1.5.1" />
<PackageReference Update="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.1-beta.1" />
<PackageReference Update="OpenTelemetry.Instrumentation.Http" Version="1.5.1-beta.1" />
<PackageReference Update="OpenTelemetry.Instrumentation.SqlClient" Version="1.5.1-beta.1" />
<PackageReference Update="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0-beta.2" />
<PackageReference Update="OpenTelemetry.ResourceDetectors.Azure" Version="1.0.0-beta.1" />
</ItemGroup>

<!--
Expand Down Expand Up @@ -270,7 +271,7 @@
<PackageReference Update="NSubstitute" Version="3.1.0" />
<PackageReference Update="NUnit" Version="3.13.2" />
<PackageReference Update="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Update="OpenTelemetry" Version="1.5.0" />
<PackageReference Update="OpenTelemetry" Version="1.5.1" />
<PackageReference Update="Polly" Version="7.1.0" />
<PackageReference Update="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Update="Portable.BouncyCastle" Version="1.9.0" />
Expand Down
13 changes: 13 additions & 0 deletions sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@

### Features Added

* Added `Resource` to traces, logs, and metrics with default configuration.
([#37837](https://github.com/Azure/azure-sdk-for-net/pull/37837))
* Added resource detection for `Azure App Service` and `Azure Virtual Machine` environment. .
([#37837](https://github.com/Azure/azure-sdk-for-net/pull/37837))

### Breaking Changes

### Bugs Fixed

### Other Changes

* Update OpenTelemetry dependencies
([#37837](https://github.com/Azure/azure-sdk-for-net/pull/37837))
- OpenTelemetry 1.5.1
- OpenTelemetry.Extensions.Hosting 1.5.1
- OpenTelemetry.Instrumentation.AspNetCore 1.5.1-beta.1
- OpenTelemetry.Instrumentation.Http 1.5.1-beta.1
- OpenTelemetry.Instrumentation.SqlClient 1.5.1-beta.1

## 1.0.0-beta.5 (2023-07-13)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>An OpenTelemetry .NET distro that exports to Azure Monitor</Description>
<AssemblyTitle>AzureMonitor OpenTelemetry ASP.NET Core Distro</AssemblyTitle>
Expand All @@ -13,6 +13,7 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.SqlClient" />
<PackageReference Include="OpenTelemetry.ResourceDetectors.Azure" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.ResourceDetectors.Azure;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

namespace Azure.Monitor.OpenTelemetry.AspNetCore
Expand Down Expand Up @@ -90,6 +92,9 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
builder.Services.Configure(configureAzureMonitor);
}

builder.ConfigureResource(r => r.AddDetector(new AppServiceResourceDetector())
.AddDetector(new AzureVMResourceDetector()));

builder.WithTracing(b => b
.AddSource("Azure.*")
.AddAspNetCoreInstrumentation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public async Task ValidateTelemetryExport()
// Telemetry is serialized as json, and then byte encoded.
// Need to parse the request content into something assertable.
var data = ParseJsonRequestContent<ParsedData>(transport.Requests);
Assert.Equal(15, data.Count); // Total telemetry items
Assert.Equal(16, data.Count); // Total telemetry items

// Group all parsed telemetry by name and get the count per name.
var summary = data.GroupBy(x => x.name).ToDictionary(x => x.Key!, x => x.Count());

Assert.Equal(4, summary.Count); // Total unique telemetry items
Assert.Equal(8, summary["Message"]); // Count of telemetry items
Assert.Equal(5, summary["Metric"]);
Assert.Equal(6, summary["Metric"]);
Assert.Equal(1, summary["RemoteDependency"]);
Assert.Equal(1, summary["Request"]);

Expand Down