Merge branch 'net7.0' into main
This commit is contained in:
commit
e64015cadd
|
|
@ -2,7 +2,7 @@ name: API Compatibility
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -11,10 +11,15 @@ jobs:
|
|||
runs-on: windows-latest
|
||||
env:
|
||||
CheckAPICompatibility: true
|
||||
# https://github.com/actions/setup-dotnet/issues/122
|
||||
DOTNET_MULTILEVEL_LOOKUP: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
fetch-depth: 0 # fetching all
|
||||
dotnet-version: '7.0.x'
|
||||
include-prerelease: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ name: Code Coverage
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -20,11 +20,17 @@ jobs:
|
|||
os: [windows-latest]
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
# https://github.com/actions/setup-dotnet/issues/122
|
||||
DOTNET_MULTILEVEL_LOOKUP: 1
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # fetching all
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
include-prerelease: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ name: docfx
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ name: dotnet format
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ name: dotnet format
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.cs'
|
||||
- '.editorconfig'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.cs'
|
||||
- '.editorconfig'
|
||||
|
|
@ -25,6 +25,12 @@ jobs:
|
|||
with:
|
||||
dotnet-version: 6.0.x
|
||||
|
||||
- name: Setup .NET Core 7.0
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
include-prerelease: true
|
||||
|
||||
- name: Install format tool
|
||||
run: dotnet tool install -g dotnet-format
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ name: Integration Tests
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
||||
|
|
@ -34,6 +34,6 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ name: Integration Tests
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ name: Linux
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0]
|
||||
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ name: Linux
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -16,13 +16,23 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
version: [netcoreapp3.1,net6.0]
|
||||
version: [net6.0, net7.0]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # fetching all
|
||||
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
include-prerelease: true
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ name: markdownlint
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ name: sanitycheck
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
|
||||
jobs:
|
||||
misspell:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ name: Windows
|
|||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths:
|
||||
- '**.md'
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
version: [net462,netcoreapp3.1,net6.0]
|
||||
version: [net462,net6.0]
|
||||
|
||||
steps:
|
||||
- run: 'echo "No build required"'
|
||||
|
|
|
|||
|
|
@ -2,27 +2,35 @@ name: Windows
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ main, net7.0 ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
# https://github.com/actions/setup-dotnet/issues/122
|
||||
DOTNET_MULTILEVEL_LOOKUP: 1
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
version: [net462,netcoreapp3.1,net6.0]
|
||||
version: [net462,net6.0,net7.0]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # fetching all
|
||||
|
||||
- uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
include-prerelease: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentati
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77C7929A-2EED-4AA6-8705-B5C443C8AA0F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.3.1", "test\TestApp.AspNetCore.3.1\TestApp.AspNetCore.3.1.csproj", "{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{E359BB2B-9AEC-497D-B321-7DF2450C3B8E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Jaeger", "src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj", "{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}"
|
||||
|
|
@ -273,10 +271,6 @@ Global
|
|||
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -510,7 +504,6 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
|
||||
{A533C800-3DC3-4D04-90A7-0CE7A1E6BDB3} = {F1D0972B-38CF-49C2-9F4B-4C5DE02FB71D}
|
||||
{E69578EB-B456-4062-A645-877CD964528B} = {F1D0972B-38CF-49C2-9F4B-4C5DE02FB71D}
|
||||
{C1542297-8763-4DF4-957C-489ED771C21D} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<SerilogPkgVer>[2.8.0,3.0)</SerilogPkgVer>
|
||||
<StyleCopAnalyzersPkgVer>[1.2.0-beta.354,2.0)</StyleCopAnalyzersPkgVer>
|
||||
<SystemCollectionsImmutablePkgVer>1.4.0</SystemCollectionsImmutablePkgVer>
|
||||
<SystemDiagnosticSourcePkgVer>6.0.0</SystemDiagnosticSourcePkgVer>
|
||||
<SystemDiagnosticSourcePkgVer>7.0.0-preview.4.22229.4</SystemDiagnosticSourcePkgVer>
|
||||
<SystemReflectionEmitLightweightPkgVer>4.7.0</SystemReflectionEmitLightweightPkgVer>
|
||||
<SystemTextJsonPkgVer>4.7.0</SystemTextJsonPkgVer>
|
||||
<SystemThreadingTasksExtensionsPkgVer>4.5.3</SystemThreadingTasksExtensionsPkgVer>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<OutputType>Exe</OutputType>
|
||||
<!-- https://dotnet.microsoft.com/download/dotnet-core -->
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<!-- https://dotnet.microsoft.com/download/dotnet-framework -->
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462;net47;net471;net472;net48</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"sdk": {
|
||||
"rollForward": "latestFeature",
|
||||
"version": "6.0.100"
|
||||
"version": "6.0.100",
|
||||
"allowPrerelease": "true"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<Description>ASP.NET Core middleware for hosting OpenTelemetry .NET Prometheus Exporter</Description>
|
||||
<PackageTags>$(PackageTags);prometheus;metrics</PackageTags>
|
||||
<MinVerTagPrefix>core-</MinVerTagPrefix>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.get -> bool
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity, string, object>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Enrich.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext, bool>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.get -> bool
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.set -> void
|
||||
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
|
||||
OpenTelemetry.Trace.TracerProviderBuilderExtensions
|
||||
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions = null) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
|
|
@ -35,6 +35,10 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
internal class HttpInListener : ListenerHandler
|
||||
{
|
||||
internal const string ActivityOperationName = "Microsoft.AspNetCore.Hosting.HttpRequestIn";
|
||||
#if NET7_0_OR_GREATER
|
||||
// https://github.com/dotnet/aspnetcore/blob/8d6554e655b64da75b71e0e20d6db54a3ba8d2fb/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs#L85
|
||||
internal static readonly string AspNetCoreActivitySourceName = "Microsoft.AspNetCore";
|
||||
#endif
|
||||
internal static readonly AssemblyName AssemblyName = typeof(HttpInListener).Assembly.GetName();
|
||||
internal static readonly string ActivitySourceName = AssemblyName.Name;
|
||||
internal static readonly Version Version = AssemblyName.Version;
|
||||
|
|
@ -96,8 +100,14 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
// Create a new activity with its parent set from the extracted context.
|
||||
// This makes the new activity as a "sibling" of the activity created by
|
||||
// Asp.Net Core.
|
||||
#if NET7_0_OR_GREATER
|
||||
// For NET7.0 onwards activity is created using ActivitySource so,
|
||||
// we will use the source of the activity to create the new one.
|
||||
Activity newOne = activity.Source.CreateActivity(ActivityOperationName, ActivityKind.Server, ctx.ActivityContext);
|
||||
#else
|
||||
Activity newOne = new Activity(ActivityOperationName);
|
||||
newOne.SetParentId(ctx.ActivityContext.TraceId, ctx.ActivityContext.SpanId, ctx.ActivityContext.TraceFlags);
|
||||
#endif
|
||||
newOne.TraceStateString = ctx.ActivityContext.TraceState;
|
||||
|
||||
newOne.SetTag("IsCreatedByInstrumentation", bool.TrueString);
|
||||
|
|
@ -135,8 +145,10 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
return;
|
||||
}
|
||||
|
||||
#if !NET7_0_OR_GREATER
|
||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
|
||||
ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Server);
|
||||
#endif
|
||||
|
||||
var path = (request.PathBase.HasValue || request.Path.HasValue) ? (request.PathBase + request.Path).ToString() : "/";
|
||||
activity.DisplayName = path;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
|
||||
<Description>ASP.NET Core instrumentation for OpenTelemetry .NET</Description>
|
||||
<PackageTags>$(PackageTags);distributed-tracing;AspNetCore</PackageTags>
|
||||
<IncludeDiagnosticSourceInstrumentationHelpers>true</IncludeDiagnosticSourceInstrumentationHelpers>
|
||||
|
|
@ -28,13 +28,12 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="$(MicrosoftAspNetCoreHttpFeaturesPkgVer)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="$(MicrosoftAspNetCoreHttpFeaturesNet3PkgVer)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
// </copyright>
|
||||
|
||||
using System;
|
||||
#if NET7_0_OR_GREATER
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
#endif
|
||||
using OpenTelemetry.Instrumentation.AspNetCore;
|
||||
using OpenTelemetry.Instrumentation.AspNetCore.Implementation;
|
||||
using OpenTelemetry.Internal;
|
||||
|
|
@ -42,7 +46,7 @@ namespace OpenTelemetry.Trace
|
|||
{
|
||||
return deferredTracerProviderBuilder.Configure((sp, builder) =>
|
||||
{
|
||||
AddAspNetCoreInstrumentation(builder, sp.GetOptions<AspNetCoreInstrumentationOptions>(), configureAspNetCoreInstrumentationOptions);
|
||||
AddAspNetCoreInstrumentation(builder, sp.GetOptions<AspNetCoreInstrumentationOptions>(), configureAspNetCoreInstrumentationOptions, sp);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -51,22 +55,44 @@ namespace OpenTelemetry.Trace
|
|||
|
||||
internal static TracerProviderBuilder AddAspNetCoreInstrumentation(
|
||||
this TracerProviderBuilder builder,
|
||||
AspNetCoreInstrumentation instrumentation)
|
||||
AspNetCoreInstrumentation instrumentation,
|
||||
IServiceProvider serviceProvider = null)
|
||||
{
|
||||
// For .NET7.0 onwards activity will be created using activitySource.
|
||||
// https://github.com/dotnet/aspnetcore/blob/bf3352f2422bf16fa3ca49021f0e31961ce525eb/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs#L327
|
||||
// For .NET6.0 and below, we will continue to use legacy way.
|
||||
#if NET7_0_OR_GREATER
|
||||
// TODO: Check with .NET team to see if this can be prevented
|
||||
// as this allows user to override the ActivitySource.
|
||||
var activitySourceService = serviceProvider?.GetService<ActivitySource>();
|
||||
if (activitySourceService != null)
|
||||
{
|
||||
builder.AddSource(activitySourceService.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For users not using hosting package?
|
||||
builder.AddSource(HttpInListener.AspNetCoreActivitySourceName);
|
||||
}
|
||||
#else
|
||||
builder.AddSource(HttpInListener.ActivitySourceName);
|
||||
builder.AddLegacySource(HttpInListener.ActivityOperationName); // for the activities created by AspNetCore
|
||||
#endif
|
||||
|
||||
return builder.AddInstrumentation(() => instrumentation);
|
||||
}
|
||||
|
||||
private static TracerProviderBuilder AddAspNetCoreInstrumentation(
|
||||
TracerProviderBuilder builder,
|
||||
AspNetCoreInstrumentationOptions options,
|
||||
Action<AspNetCoreInstrumentationOptions> configure = null)
|
||||
Action<AspNetCoreInstrumentationOptions> configure = null,
|
||||
IServiceProvider serviceProvider = null)
|
||||
{
|
||||
configure?.Invoke(options);
|
||||
return AddAspNetCoreInstrumentation(
|
||||
builder,
|
||||
new AspNetCoreInstrumentation(new HttpInListener(options)));
|
||||
new AspNetCoreInstrumentation(new HttpInListener(options)),
|
||||
serviceProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,30 @@ namespace OpenTelemetry.Instrumentation.Http
|
|||
{
|
||||
private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber;
|
||||
|
||||
private readonly Func<string, object, object, bool> isEnabled = (activityName, obj1, obj2)
|
||||
=> !activityName.Equals("System.Net.Http.HttpRequestOut");
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpClientInstrumentation"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">Configuration options for HTTP client instrumentation.</param>
|
||||
public HttpClientInstrumentation(HttpClientInstrumentationOptions options)
|
||||
{
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), null);
|
||||
// For .NET7.0 activity will be created using activitySource.
|
||||
// https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
|
||||
// However, in case when activity creation returns null (due to sampling)
|
||||
// the framework will fall back to creating activity anyways due to active diagnostic source listener
|
||||
// To prevent this, isEnabled is implemented which will return false always
|
||||
// so that the sampler's decision is respected.
|
||||
if (HttpHandlerDiagnosticListener.IsNet7OrGreater)
|
||||
{
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), this.isEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), null);
|
||||
}
|
||||
|
||||
this.diagnosticSourceSubscriber.Subscribe();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
internal sealed class HttpHandlerDiagnosticListener : ListenerHandler
|
||||
{
|
||||
internal static readonly AssemblyName AssemblyName = typeof(HttpHandlerDiagnosticListener).Assembly.GetName();
|
||||
internal static readonly bool IsNet7OrGreater;
|
||||
|
||||
// https://github.com/dotnet/runtime/blob/7d034ddbbbe1f2f40c264b323b3ed3d6b3d45e9a/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs#L19
|
||||
internal static readonly string HttpClientActivitySourceName = "System.Net.Http";
|
||||
internal static readonly string ActivitySourceName = AssemblyName.Name;
|
||||
internal static readonly Version Version = AssemblyName.Version;
|
||||
internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString());
|
||||
|
|
@ -40,6 +44,18 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
private readonly PropertyFetcher<TaskStatus> stopRequestStatusFetcher = new("RequestTaskStatus");
|
||||
private readonly HttpClientInstrumentationOptions options;
|
||||
|
||||
static HttpHandlerDiagnosticListener()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsNet7OrGreater = typeof(HttpClient).Assembly.GetName().Version.Major >= 7;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
IsNet7OrGreater = false;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpHandlerDiagnosticListener(HttpClientInstrumentationOptions options)
|
||||
: base("HttpHandlerDiagnosticListener")
|
||||
{
|
||||
|
|
@ -58,7 +74,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
// By this time, samplers have already run and
|
||||
// activity.IsAllDataRequested populated accordingly.
|
||||
|
||||
if (Sdk.SuppressInstrumentation)
|
||||
// For .NET7.0 or higher versions, activity is created using activity source
|
||||
// However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
|
||||
// To prevent processing such activities we first check the source name to confirm if it was created using
|
||||
// activity source or not.
|
||||
if (Sdk.SuppressInstrumentation || (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -108,8 +128,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
|
||||
activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method);
|
||||
|
||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
|
||||
ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Client);
|
||||
if (!IsNet7OrGreater)
|
||||
{
|
||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
|
||||
ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Client);
|
||||
}
|
||||
|
||||
activity.SetTag(SemanticConventions.AttributeHttpScheme, request.RequestUri.Scheme);
|
||||
activity.SetTag(SemanticConventions.AttributeHttpMethod, HttpTagHelper.GetNameForHttpMethod(request.Method));
|
||||
|
|
@ -130,6 +153,15 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
|
||||
public override void OnStopActivity(Activity activity, object payload)
|
||||
{
|
||||
// For .NET7.0 or higher versions, activity is created using activity source
|
||||
// However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
|
||||
// To prevent processing such activities we first check the source name to confirm if it was created using
|
||||
// activity source or not.
|
||||
if (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
|
||||
|
|
@ -179,6 +211,15 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
|
||||
public override void OnException(Activity activity, object payload)
|
||||
{
|
||||
// For .NET7.0 or higher versions, activity is created using activity source
|
||||
// However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
|
||||
// To prevent processing such activities we first check the source name to confirm if it was created using
|
||||
// activity source or not.
|
||||
if (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activity.IsAllDataRequested)
|
||||
{
|
||||
if (!this.stopExceptionFetcher.TryFetch(payload, out Exception exc) || exc == null)
|
||||
|
|
|
|||
|
|
@ -78,8 +78,16 @@ namespace OpenTelemetry.Trace
|
|||
this TracerProviderBuilder builder,
|
||||
HttpClientInstrumentation instrumentation)
|
||||
{
|
||||
builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
|
||||
builder.AddLegacySource("System.Net.Http.HttpRequestOut");
|
||||
if (HttpHandlerDiagnosticListener.IsNet7OrGreater)
|
||||
{
|
||||
builder.AddSource(HttpHandlerDiagnosticListener.HttpClientActivitySourceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
|
||||
builder.AddLegacySource("System.Net.Http.HttpRequestOut");
|
||||
}
|
||||
|
||||
return builder.AddInstrumentation(() => instrumentation);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for Jaeger Exporter for OpenTelemetry</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == '' AND $(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) != ''">$(TARGET_FRAMEWORK)</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for Prometheus Exporter AspNetCore for OpenTelemetry</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus.AspNetCore\OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.0" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for Zipkin Exporter for OpenTelemetry</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry EventSource extensions</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry .NET Core hosting library</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0;netcoreapp3.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) != ''">$(TARGET_FRAMEWORK)</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry Serilog extensions</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ using TestApp.AspNetCore._3._1;
|
|||
#if NET6_0
|
||||
using TestApp.AspNetCore._6._0;
|
||||
#endif
|
||||
#if NET7_0
|
||||
using TestApp.AspNetCore._7._0;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
||||
|
|
@ -345,7 +348,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
var expectedTraceId = ActivityTraceId.CreateRandom();
|
||||
var expectedParentSpanId = ActivitySpanId.CreateRandom();
|
||||
var expectedTraceState = "rojo=1,congo=2";
|
||||
var activityContext = new ActivityContext(expectedTraceId, expectedParentSpanId, ActivityTraceFlags.Recorded, expectedTraceState);
|
||||
var activityContext = new ActivityContext(expectedTraceId, expectedParentSpanId, ActivityTraceFlags.Recorded, expectedTraceState, true);
|
||||
var expectedBaggage = Baggage.SetBaggage("key1", "value1").SetBaggage("key2", "value2");
|
||||
Sdk.SetDefaultTextMapPropagator(new ExtractOnlyPropagator(activityContext, expectedBaggage));
|
||||
|
||||
|
|
@ -583,6 +586,47 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
Assert.Equal(activityName, middlewareActivity.DisplayName);
|
||||
}
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[Fact]
|
||||
public async Task UserRegisteredActivitySourceIsUsedForActivityCreationByAspNetCore()
|
||||
{
|
||||
var exportedItems = new List<Activity>();
|
||||
void ConfigureTestServices(IServiceCollection services)
|
||||
{
|
||||
services.AddOpenTelemetryTracing(options =>
|
||||
{
|
||||
options.AddAspNetCoreInstrumentation()
|
||||
.AddInMemoryExporter(exportedItems);
|
||||
});
|
||||
|
||||
// Register ActivitySource here so that it will be used
|
||||
// by ASP.NET Core to create activities
|
||||
// https://github.com/dotnet/aspnetcore/blob/0e5cbf447d329a1e7d69932c3decd1c70a00fbba/src/Hosting/Hosting/src/Internal/WebHost.cs#L152
|
||||
services.AddSingleton(sp => new ActivitySource("UserRegisteredActivitySource"));
|
||||
}
|
||||
|
||||
// Arrange
|
||||
using (var client = this.factory
|
||||
.WithWebHostBuilder(builder =>
|
||||
builder.ConfigureTestServices(ConfigureTestServices))
|
||||
.CreateClient())
|
||||
{
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
||||
WaitForActivityExport(exportedItems, 1);
|
||||
}
|
||||
|
||||
Assert.Single(exportedItems);
|
||||
var activity = exportedItems[0];
|
||||
|
||||
Assert.Equal("UserRegisteredActivitySource", activity.Source.Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.tracerProvider?.Dispose();
|
||||
|
|
@ -605,8 +649,13 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
private static void ValidateAspNetCoreActivity(Activity activityToValidate, string expectedHttpPath)
|
||||
{
|
||||
Assert.Equal(ActivityKind.Server, activityToValidate.Kind);
|
||||
#if NET7_0_OR_GREATER
|
||||
Assert.Equal(HttpInListener.AspNetCoreActivitySourceName, activityToValidate.Source.Name);
|
||||
Assert.Empty(activityToValidate.Source.Version);
|
||||
#else
|
||||
Assert.Equal(HttpInListener.ActivitySourceName, activityToValidate.Source.Name);
|
||||
Assert.Equal(HttpInListener.Version.ToString(), activityToValidate.Source.Version);
|
||||
#endif
|
||||
Assert.Equal(expectedHttpPath, activityToValidate.GetTagValue(SemanticConventions.AttributeHttpTarget) as string);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ using TestApp.AspNetCore._3._1;
|
|||
#if NET6_0
|
||||
using TestApp.AspNetCore._6._0;
|
||||
#endif
|
||||
#if NET7_0
|
||||
using TestApp.AspNetCore._7._0;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ using TestApp.AspNetCore._3._1;
|
|||
#if NET6_0
|
||||
using TestApp.AspNetCore._6._0;
|
||||
#endif
|
||||
#if NET7_0
|
||||
using TestApp.AspNetCore._7._0;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ using TestApp.AspNetCore._3._1;
|
|||
#if NET6_0
|
||||
using TestApp.AspNetCore._6._0;
|
||||
#endif
|
||||
#if NET7_0
|
||||
using TestApp.AspNetCore._7._0;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry ASP.NET Core instrumentation</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -27,6 +27,11 @@
|
|||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestEventListener.cs" Link="TestEventListener.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.7.0\TestApp.AspNetCore.7.0.csproj" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0-preview.5.22303.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.6.0\TestApp.AspNetCore.6.0.csproj" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.0" />
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry Grpc for .NET instrumentation</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry HTTP instrumentations</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry SqlClient instrumentations</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == '' and $(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) != ''">$(TARGET_FRAMEWORK)</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
# This should be run from the root of the repo:
|
||||
# docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile .
|
||||
|
||||
ARG SDK_VERSION=6.0
|
||||
ARG SDK_VERSION=7.0
|
||||
FROM ubuntu AS w3c
|
||||
#Install git
|
||||
WORKDIR /w3c
|
||||
RUN apt-get update && apt-get install -y git
|
||||
RUN git clone https://github.com/w3c/trace-context.git
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
ARG PUBLISH_CONFIGURATION=Release
|
||||
ARG PUBLISH_FRAMEWORK=net6.0
|
||||
ARG PUBLISH_FRAMEWORK=net7.0
|
||||
WORKDIR /repo
|
||||
COPY . ./
|
||||
WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ using TestApp.AspNetCore._3._1;
|
|||
#if NET6_0
|
||||
using TestApp.AspNetCore._6._0;
|
||||
#endif
|
||||
#if NET7_0
|
||||
using TestApp.AspNetCore._7._0;
|
||||
#endif
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry ASP.NET Core instrumentation for W3C Trace Context Trace</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) == ''">net7.0;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(TARGET_FRAMEWORK) != ''">$(TARGET_FRAMEWORK)</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -33,8 +33,8 @@
|
|||
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.6.0\TestApp.AspNetCore.6.0.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.3.1\TestApp.AspNetCore.3.1.csproj" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<ProjectReference Include="$(RepoRoot)\test\TestApp.AspNetCore.7.0\TestApp.AspNetCore.7.0.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry.Shims.OpenTracing</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry</Description>
|
||||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
|
||||
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<NoWarn>$(NoWarn),CS0618</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
# ASP.NET Core Integration Test
|
||||
|
||||
This test app is used for ASP.NET Core integration testing by unit tests. You
|
||||
could also manually run W3C test suite.
|
||||
|
||||
## Run W3C test suite
|
||||
|
||||
The detailed instruction for the test tool available
|
||||
[here](https://github.com/w3c/trace-context/tree/master/test).
|
||||
|
||||
* Follow it to install prerequisites and get the test code
|
||||
* Start this test app with Visual Studio (or `dotnet run`)
|
||||
* Run test per instruction using `http://localhost:63741/api/forward` endpoint
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1
|
||||
namespace TestApp.AspNetCore._7._0
|
||||
{
|
||||
public class ActivityMiddleware
|
||||
{
|
||||
|
|
@ -21,4 +21,4 @@ using System.Diagnostics.CodeAnalysis;
|
|||
"SA1300",
|
||||
Justification = "Reviewed.",
|
||||
Scope = "namespaceanddescendants",
|
||||
Target = "TestApp.AspNetCore._3._1")]
|
||||
Target = "TestApp.AspNetCore._7._0")]
|
||||
|
|
@ -13,10 +13,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
public class CallbackMiddleware
|
||||
{
|
||||
|
|
@ -19,7 +19,9 @@ using System.Diagnostics;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenTelemetry;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1.Controllers
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0.Controllers
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
public class ChildActivityController : Controller
|
||||
{
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
|
@ -20,7 +21,9 @@ using System.Text.Json.Serialization;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1.Controllers
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0.Controllers
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class ForwardController : Controller
|
||||
|
|
@ -16,7 +16,9 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1.Controllers
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0.Controllers
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class ValuesController : Controller
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
|
|
@ -21,7 +21,9 @@ using Microsoft.Extensions.Configuration;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace TestApp.AspNetCore._3._1
|
||||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
||||
namespace TestApp.AspNetCore._7._0
|
||||
#pragma warning restore SA1300 // Element should begin with upper-case letter
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -11,7 +12,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0-preview.4.22259.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -20,4 +21,5 @@
|
|||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Hosting\OpenTelemetry.Extensions.Hosting.csproj" />
|
||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue