Move test infra to .NET Core 3.0 (#403)
* Add W3C TraceContext validation test app * fix linux build * some fixes * Use ASP.NET Core test app as W3C test suite example * broken solution * remove new project * move tests to 3.0 * update minver * fix http tests to force 2.0 * minver is in common props, remove from projects * move lightstep tests to 3.1
This commit is contained in:
parent
dbc89a27ee
commit
40a51b69bc
|
|
@ -1,7 +1,7 @@
|
||||||
# CI build. No publioshing of artifacts
|
# CI build. No publioshing of artifacts
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DotNetVersion: "2.2.101"
|
DotNetVersion: "3.1.100"
|
||||||
|
|
||||||
# A pipeline with no CI trigger
|
# A pipeline with no CI trigger
|
||||||
trigger: none
|
trigger: none
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# CI build with the upload to MyGet
|
# CI build with the upload to MyGet
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DotNetVersion: "2.2.101"
|
DotNetVersion: "3.1.100"
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branches:
|
branches:
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ You can contribute to this project from a Windows, macOS or Linux machine. Requi
|
||||||
In all platforms, the requirements are:
|
In all platforms, the requirements are:
|
||||||
|
|
||||||
* Git client and command line tools. You may use Visual Studio to clone the repo, but we use [SourceLink](https://github.com/dotnet/sourcelink) to build and it needs git.
|
* Git client and command line tools. You may use Visual Studio to clone the repo, but we use [SourceLink](https://github.com/dotnet/sourcelink) to build and it needs git.
|
||||||
* .NET Core 2.1+
|
* .NET Core 3.1+
|
||||||
|
|
||||||
#### Windows
|
#### Windows
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ This is because unit tests targeting .NET Framework (i.e: `net46`) are disabled
|
||||||
|
|
||||||
Open `OpenTelemetry.sln` in your IDE of choice and follow normal development process.
|
Open `OpenTelemetry.sln` in your IDE of choice and follow normal development process.
|
||||||
|
|
||||||
To build from the command line you need `dotnet` version `2.1+`.
|
To build from the command line you need `dotnet` version `3.1+`.
|
||||||
|
|
||||||
``` sh
|
``` sh
|
||||||
dotnet build OpenTelemetry.sln
|
dotnet build OpenTelemetry.sln
|
||||||
|
|
@ -79,7 +79,7 @@ You can use any of the IDEs mentioned above to test your contribution. Open root
|
||||||
folder or `OpenTelemetry.sln` in your editor and follow normal development
|
folder or `OpenTelemetry.sln` in your editor and follow normal development
|
||||||
process.
|
process.
|
||||||
|
|
||||||
To test from command line you need `dotnet` version `2.0+`.
|
To test from command line you need `dotnet` version `3.1+`.
|
||||||
|
|
||||||
``` sh
|
``` sh
|
||||||
dotnet test OpenTelemetry.sln
|
dotnet test OpenTelemetry.sln
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="16.4" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Solution Include="OpenTelemetry.sln" />
|
<Solution Include="OpenTelemetry.sln" />
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Collector.Asp
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77C7929A-2EED-4AA6-8705-B5C443C8AA0F}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77C7929A-2EED-4AA6-8705-B5C443C8AA0F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.2.0", "test\TestApp.AspNetCore.2.0\TestApp.AspNetCore.2.0.csproj", "{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.3.0", "test\TestApp.AspNetCore.3.0\TestApp.AspNetCore.3.0.csproj", "{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Stackdriver.Tests", "test\OpenTelemetry.Exporter.Stackdriver.Tests\OpenTelemetry.Exporter.Stackdriver.Tests.csproj", "{6875032B-DFDC-4CDE-A283-37CA7F99926A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Stackdriver.Tests", "test\OpenTelemetry.Exporter.Stackdriver.Tests\OpenTelemetry.Exporter.Stackdriver.Tests.csproj", "{6875032B-DFDC-4CDE-A283-37CA7F99926A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
@ -105,7 +105,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Hosting.Tests
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.OpenTelemetryProtocol", "src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj", "{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.OpenTelemetryProtocol", "src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj", "{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Exporter.Prometheus.Tests", "test\OpenTelemetry.Exporter.Prometheus.Tests\OpenTelemetry.Exporter.Prometheus.Tests.csproj", "{393128EC-454D-45E8-A204-EC54904E5B3F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.Tests", "test\OpenTelemetry.Exporter.Prometheus.Tests\OpenTelemetry.Exporter.Prometheus.Tests.csproj", "{393128EC-454D-45E8-A204-EC54904E5B3F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>netcoreapp2.2;net462</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MinVer" Version="1.1.0">
|
<PackageReference Include="MinVer" Version="2.0.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
@ -27,5 +27,4 @@
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.ApplicationInsights\OpenTelemetry.Exporter.ApplicationInsights.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.ApplicationInsights\OpenTelemetry.Exporter.ApplicationInsights.csproj" />
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
|
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -42,7 +42,7 @@ namespace OpenTelemetry.Collector.AspNetCore
|
||||||
/// <param name="options">Configuration options for dependencies collector.</param>
|
/// <param name="options">Configuration options for dependencies collector.</param>
|
||||||
public AspNetCoreCollector(Tracer tracer, AspNetCoreCollectorOptions options)
|
public AspNetCoreCollector(Tracer tracer, AspNetCoreCollectorOptions options)
|
||||||
{
|
{
|
||||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", tracer), options.EventFilter);
|
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", tracer, options.RequestFilter), null);
|
||||||
this.diagnosticSourceSubscriber.Subscribe();
|
this.diagnosticSourceSubscriber.Subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace OpenTelemetry.Collector.AspNetCore
|
namespace OpenTelemetry.Collector.AspNetCore
|
||||||
{
|
{
|
||||||
|
|
@ -25,9 +27,9 @@ namespace OpenTelemetry.Collector.AspNetCore
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
|
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal Func<string, object, object, bool> EventFilter { get; set; } = DefaultFilter;
|
internal Predicate<HttpContext> RequestFilter { get; set; } = DefaultFilter;
|
||||||
|
|
||||||
private static bool DefaultFilter(string activityName, object arg1, object unused)
|
private static bool DefaultFilter(HttpContext httpContext)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -32,11 +33,13 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
||||||
private readonly PropertyFetcher beforeActionAttributeRouteInfoFetcher = new PropertyFetcher("AttributeRouteInfo");
|
private readonly PropertyFetcher beforeActionAttributeRouteInfoFetcher = new PropertyFetcher("AttributeRouteInfo");
|
||||||
private readonly PropertyFetcher beforeActionTemplateFetcher = new PropertyFetcher("Template");
|
private readonly PropertyFetcher beforeActionTemplateFetcher = new PropertyFetcher("Template");
|
||||||
private readonly bool hostingSupportsW3C = false;
|
private readonly bool hostingSupportsW3C = false;
|
||||||
|
private readonly Predicate<HttpContext> requestFilter;
|
||||||
|
|
||||||
public HttpInListener(string name, Tracer tracer)
|
public HttpInListener(string name, Tracer tracer, Predicate<HttpContext> requestFilter)
|
||||||
: base(name, tracer)
|
: base(name, tracer)
|
||||||
{
|
{
|
||||||
this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
|
this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
|
||||||
|
this.requestFilter = requestFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnStartActivity(Activity activity, object payload)
|
public override void OnStartActivity(Activity activity, object payload)
|
||||||
|
|
@ -50,6 +53,12 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.requestFilter != null && !this.requestFilter(context))
|
||||||
|
{
|
||||||
|
CollectorEventSource.Log.RequestIsFilteredOut(activity.OperationName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var request = context.Request;
|
var request = context.Request;
|
||||||
|
|
||||||
// see the spec https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
|
// see the spec https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,11 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Update="MinVer" Version="2.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@
|
||||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.0.519" />
|
<PackageReference Include="StackExchange.Redis" Version="2.0.519" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Implementation\" />
|
<Folder Include="Implementation\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,5 @@
|
||||||
<ProtoRoot>Implementation</ProtoRoot>
|
<ProtoRoot>Implementation</ProtoRoot>
|
||||||
</Protobuf>
|
</Protobuf>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,5 @@
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
|
||||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -20,4 +20,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenTelemetry.Api\OpenTelemetry.Api.csproj" />
|
<ProjectReference Include="..\OpenTelemetry.Api\OpenTelemetry.Api.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// <copyright file="CollectorEventSource.cs" company="OpenTelemetry Authors">
|
// <copyright file="CollectorEventSource.cs" company="OpenTelemetry Authors">
|
||||||
// Copyright 2018, OpenTelemetry Authors
|
// Copyright 2018, OpenTelemetry Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -79,6 +79,12 @@ namespace OpenTelemetry.Collector
|
||||||
this.WriteEvent(5, eventName);
|
this.WriteEvent(5, eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Event(6, Message = "Request is filtered out.", Level = EventLevel.Verbose)]
|
||||||
|
public void RequestIsFilteredOut(string eventName)
|
||||||
|
{
|
||||||
|
this.WriteEvent(6, eventName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a culture-independent string representation of the given <paramref name="exception"/> object,
|
/// Returns a culture-independent string representation of the given <paramref name="exception"/> object,
|
||||||
/// appropriate for diagnostics tracing.
|
/// appropriate for diagnostics tracing.
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,6 @@ namespace OpenTelemetry.Collector
|
||||||
|
|
||||||
public virtual void OnException(Activity activity, object payload)
|
public virtual void OnException(Activity activity, object payload)
|
||||||
{
|
{
|
||||||
var span = this.Tracer.CurrentSpan;
|
|
||||||
|
|
||||||
// TODO: gather exception information
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnCustom(string name, Activity activity, object payload)
|
public virtual void OnCustom(string name, Activity activity, object payload)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
using OpenTelemetry.Trace.Configuration;
|
using OpenTelemetry.Trace.Configuration;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using TestApp.AspNetCore._2._0;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using OpenTelemetry.Trace;
|
using OpenTelemetry.Trace;
|
||||||
|
|
@ -26,11 +25,10 @@ using Moq;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
using Microsoft.AspNetCore.TestHost;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenTelemetry.Context.Propagation;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Net.Http;
|
||||||
using OpenTelemetry.Trace.Samplers;
|
using OpenTelemetry.Trace.Samplers;
|
||||||
|
using TestApp.AspNetCore._3._0;
|
||||||
|
|
||||||
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -98,13 +96,6 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
var expectedTraceId = ActivityTraceId.CreateRandom();
|
var expectedTraceId = ActivityTraceId.CreateRandom();
|
||||||
var expectedSpanId = ActivitySpanId.CreateRandom();
|
var expectedSpanId = ActivitySpanId.CreateRandom();
|
||||||
|
|
||||||
var tf = new Mock<ITextFormat>();
|
|
||||||
tf.Setup(m => m.Extract<HttpRequest>(It.IsAny<HttpRequest>(), It.IsAny<Func<HttpRequest, string, IEnumerable<string>>>())).Returns(new SpanContext(
|
|
||||||
expectedTraceId,
|
|
||||||
expectedSpanId,
|
|
||||||
ActivityTraceFlags.Recorded,
|
|
||||||
true));
|
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
using (var testFactory = this.factory
|
using (var testFactory = this.factory
|
||||||
.WithWebHostBuilder(builder =>
|
.WithWebHostBuilder(builder =>
|
||||||
|
|
@ -112,15 +103,16 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
{
|
{
|
||||||
services.AddSingleton<TracerFactory>(_ =>
|
services.AddSingleton<TracerFactory>(_ =>
|
||||||
TracerFactory.Create(b => b
|
TracerFactory.Create(b => b
|
||||||
.SetSampler(new AlwaysSampleSampler())
|
|
||||||
.SetTextFormat(tf.Object)
|
|
||||||
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
||||||
.AddRequestCollector()));
|
.AddRequestCollector()));
|
||||||
})))
|
})))
|
||||||
using (var client = testFactory.CreateClient())
|
using (var client = testFactory.CreateClient())
|
||||||
{
|
{
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Get, "/api/values/2");
|
||||||
|
request.Headers.Add("traceparent", $"00-{expectedTraceId}-{expectedSpanId}-01");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.GetAsync("/api/values/2");
|
var response = await client.SendAsync(request);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||||
|
|
@ -142,27 +134,14 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task FilterOutRequest()
|
public async Task FilterOutRequest()
|
||||||
{
|
{
|
||||||
bool Filter(string eventName, object arg1, object _)
|
|
||||||
{
|
|
||||||
if (eventName == "Microsoft.AspNetCore.Hosting.HttpRequestIn" &&
|
|
||||||
arg1 is HttpContext context &&
|
|
||||||
context.Request.Path == "/api/values/2")
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var spanProcessor = new Mock<SpanProcessor>();
|
var spanProcessor = new Mock<SpanProcessor>();
|
||||||
|
|
||||||
void ConfigureTestServices(IServiceCollection services)
|
void ConfigureTestServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddSingleton<TracerFactory>(_ =>
|
services.AddSingleton<TracerFactory>(_ =>
|
||||||
TracerFactory.Create(b => b
|
TracerFactory.Create(b => b
|
||||||
.SetSampler(new AlwaysSampleSampler())
|
|
||||||
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
||||||
.AddRequestCollector(o => o.EventFilter = Filter)));
|
.AddRequestCollector(o => o.RequestFilter = (httpContext) => httpContext.Request.Path != "/api/values/2")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
using OpenTelemetry.Trace.Configuration;
|
using OpenTelemetry.Trace.Configuration;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using TestApp.AspNetCore._2._0;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using OpenTelemetry.Trace;
|
using OpenTelemetry.Trace;
|
||||||
|
|
@ -26,7 +25,7 @@ using Moq;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
using Microsoft.AspNetCore.TestHost;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using OpenTelemetry.Trace.Samplers;
|
using TestApp.AspNetCore._3._0;
|
||||||
|
|
||||||
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +64,6 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||||
services.AddSingleton<CallbackMiddleware.CallbackMiddlewareImpl>(new TestCallbackMiddlewareImpl());
|
services.AddSingleton<CallbackMiddleware.CallbackMiddlewareImpl>(new TestCallbackMiddlewareImpl());
|
||||||
services.AddSingleton<TracerFactory>(_ =>
|
services.AddSingleton<TracerFactory>(_ =>
|
||||||
TracerFactory.Create(b => b
|
TracerFactory.Create(b => b
|
||||||
.SetSampler(new AlwaysSampleSampler())
|
|
||||||
.AddProcessorPipeline(p => p.AddProcessor(e => spanProcessor.Object))
|
.AddProcessorPipeline(p => p.AddProcessor(e => spanProcessor.Object))
|
||||||
.AddRequestCollector()));
|
.AddRequestCollector()));
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for OpenTelemetry</Description>
|
<Description>Unit test project for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -28,9 +28,8 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.csproj" />
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
<ProjectReference Include="..\TestApp.AspNetCore.2.0\TestApp.AspNetCore.2.0.csproj" />
|
<ProjectReference Include="..\TestApp.AspNetCore.3.0\TestApp.AspNetCore.3.0.csproj" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ namespace OpenTelemetry.Collector.Dependencies.Tests
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(tc.Url),
|
RequestUri = new Uri(tc.Url),
|
||||||
Method = new HttpMethod(tc.Method),
|
Method = new HttpMethod(tc.Method),
|
||||||
|
Version = new Version(2, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tc.Headers != null)
|
if (tc.Headers != null)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for OpenTelemetry</Description>
|
<Description>Unit test project for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for Jaeger Exporter for OpenTelemetry</Description>
|
<Description>Unit test project for Jaeger Exporter for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for Stackdriver Exporter for OpenTelemetry</Description>
|
<Description>Unit test project for Stackdriver Exporter for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
<Description>Unit test project for ApplicationInsights Exporter for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for OpenTelemetry.Shims.OpenTracing</Description>
|
<Description>Unit test project for OpenTelemetry.Shims.OpenTracing</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Unit test project for OpenTelemetry</Description>
|
<Description>Unit test project for OpenTelemetry</Description>
|
||||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace TestApp.AspNetCore._2._0
|
namespace TestApp.AspNetCore._3._0
|
||||||
{
|
{
|
||||||
public class CallbackMiddleware
|
public class CallbackMiddleware
|
||||||
{
|
{
|
||||||
|
|
@ -19,35 +19,21 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace TestApp.AspNetCore._2._0.Controllers
|
namespace TestApp.AspNetCore._3._0.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class ForwardController : Controller
|
public class ForwardController : Controller
|
||||||
{
|
{
|
||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
public ForwardController(HttpClient httpclient)
|
|
||||||
|
public ForwardController(HttpClient httpClient)
|
||||||
{
|
{
|
||||||
this.httpClient = httpclient;
|
this.httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> CallNextAsync(string url, Data[] arguments)
|
// POST api/test
|
||||||
{
|
|
||||||
if (url != null)
|
|
||||||
{
|
|
||||||
var request = new HttpRequestMessage(HttpMethod.Post, url)
|
|
||||||
{
|
|
||||||
Content = new StringContent(JsonConvert.SerializeObject(arguments), Encoding.UTF8, "application/json"),
|
|
||||||
};
|
|
||||||
var response = await httpClient.SendAsync(request);
|
|
||||||
return await response.Content.ReadAsStringAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "all done";
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST api/values
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<string> Post([FromBody]Data[] data)
|
public async Task<string> Post([FromBody] Data[] data)
|
||||||
{
|
{
|
||||||
var result = string.Empty;
|
var result = string.Empty;
|
||||||
|
|
||||||
|
|
@ -55,13 +41,12 @@ namespace TestApp.AspNetCore._2._0.Controllers
|
||||||
{
|
{
|
||||||
foreach (var argument in data)
|
foreach (var argument in data)
|
||||||
{
|
{
|
||||||
if (argument.sleep != null)
|
var request = new HttpRequestMessage(HttpMethod.Post, argument.Url)
|
||||||
{
|
{
|
||||||
result = "slept for " + argument.sleep.Value + " ms";
|
Content = new StringContent(JsonConvert.SerializeObject(argument.Arguments),
|
||||||
await Task.Delay(argument.sleep.Value);
|
Encoding.UTF8, "application/json"),
|
||||||
}
|
};
|
||||||
|
await this.httpClient.SendAsync(request);
|
||||||
result += await CallNextAsync(argument.url, argument.arguments);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -75,8 +60,11 @@ namespace TestApp.AspNetCore._2._0.Controllers
|
||||||
|
|
||||||
public class Data
|
public class Data
|
||||||
{
|
{
|
||||||
public int? sleep { get; set; }
|
[JsonProperty("url")]
|
||||||
public string url { get; set; }
|
public string Url { get; set; }
|
||||||
public Data[] arguments { get; set; }
|
|
||||||
|
[JsonProperty("arguments")]
|
||||||
|
public Data[] Arguments { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace TestApp.AspNetCore._2._0.Controllers
|
namespace TestApp.AspNetCore._3._0.Controllers
|
||||||
{
|
{
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class ValuesController : Controller
|
public class ValuesController : Controller
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace TestApp.AspNetCore._2._0
|
namespace TestApp.AspNetCore._3._0
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
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
|
||||||
|
|
@ -19,9 +19,11 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using OpenTelemetry.Trace.Configuration;
|
using OpenTelemetry.Trace.Configuration;
|
||||||
|
|
||||||
namespace TestApp.AspNetCore._2._0
|
namespace TestApp.AspNetCore._3._0
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|
@ -39,10 +41,14 @@ namespace TestApp.AspNetCore._2._0
|
||||||
services.AddSingleton<HttpClient>();
|
services.AddSingleton<HttpClient>();
|
||||||
services.AddSingleton(
|
services.AddSingleton(
|
||||||
new CallbackMiddleware.CallbackMiddlewareImpl());
|
new CallbackMiddleware.CallbackMiddlewareImpl());
|
||||||
|
|
||||||
|
services.TryAddSingleton<TracerFactory>(_ => TracerFactory.Create(b => b
|
||||||
|
.AddRequestCollector()
|
||||||
|
.AddDependencyCollector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, TracerFactory factory)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TracerFactory factory)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
@ -50,7 +56,14 @@ namespace TestApp.AspNetCore._2._0
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseMiddleware<CallbackMiddleware>();
|
app.UseMiddleware<CallbackMiddleware>();
|
||||||
app.UseMvc();
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -11,14 +11,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All">
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
|
||||||
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
|
|
||||||
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -26,6 +19,7 @@
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.csproj" />
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.Dependencies\OpenTelemetry.Collector.Dependencies.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.Dependencies\OpenTelemetry.Collector.Dependencies.csproj" />
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\OpenTelemetry.Hosting\OpenTelemetry.Hosting.csproj" />
|
||||||
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
Loading…
Reference in New Issue