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
|
||||
|
||||
variables:
|
||||
DotNetVersion: "2.2.101"
|
||||
DotNetVersion: "3.1.100"
|
||||
|
||||
# A pipeline with no CI trigger
|
||||
trigger: none
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# CI build with the upload to MyGet
|
||||
|
||||
variables:
|
||||
DotNetVersion: "2.2.101"
|
||||
DotNetVersion: "3.1.100"
|
||||
|
||||
trigger:
|
||||
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:
|
||||
|
||||
* 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
|
||||
|
||||
|
|
@ -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.
|
||||
|
||||
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
|
||||
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
|
||||
process.
|
||||
|
||||
To test from command line you need `dotnet` version `2.0+`.
|
||||
To test from command line you need `dotnet` version `3.1+`.
|
||||
|
||||
``` sh
|
||||
dotnet test OpenTelemetry.sln
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?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>
|
||||
<Solution Include="OpenTelemetry.sln" />
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Collector.Asp
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77C7929A-2EED-4AA6-8705-B5C443C8AA0F}"
|
||||
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
|
||||
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
|
||||
|
|
@ -105,7 +105,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Hosting.Tests
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.OpenTelemetryProtocol", "src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj", "{A38AC295-2745-4B85-8B6B-DCA864CEDD5B}"
|
||||
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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.2;net462</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MinVer" Version="1.1.0">
|
||||
<PackageReference Include="MinVer" Version="2.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -27,5 +27,4 @@
|
|||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.ApplicationInsights\OpenTelemetry.Exporter.ApplicationInsights.csproj" />
|
||||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -21,4 +21,5 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -42,7 +42,7 @@ namespace OpenTelemetry.Collector.AspNetCore
|
|||
/// <param name="options">Configuration options for dependencies collector.</param>
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace OpenTelemetry.Collector.AspNetCore
|
||||
{
|
||||
|
|
@ -25,9 +27,9 @@ namespace OpenTelemetry.Collector.AspNetCore
|
|||
/// <summary>
|
||||
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
|
||||
/// </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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -32,11 +33,13 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
|||
private readonly PropertyFetcher beforeActionAttributeRouteInfoFetcher = new PropertyFetcher("AttributeRouteInfo");
|
||||
private readonly PropertyFetcher beforeActionTemplateFetcher = new PropertyFetcher("Template");
|
||||
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)
|
||||
{
|
||||
this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
|
||||
this.requestFilter = requestFilter;
|
||||
}
|
||||
|
||||
public override void OnStartActivity(Activity activity, object payload)
|
||||
|
|
@ -50,6 +53,12 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.requestFilter != null && !this.requestFilter(context))
|
||||
{
|
||||
CollectorEventSource.Log.RequestIsFilteredOut(activity.OperationName);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = context.Request;
|
||||
|
||||
// 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.Features" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="MinVer" Version="2.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@
|
|||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.0.519" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@
|
|||
<ItemGroup>
|
||||
<Folder Include="Implementation\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@
|
|||
<ProtoRoot>Implementation</ProtoRoot>
|
||||
</Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -18,4 +18,5 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
|
||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -20,4 +20,5 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenTelemetry.Api\OpenTelemetry.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="CollectorEventSource.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="CollectorEventSource.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -79,6 +79,12 @@ namespace OpenTelemetry.Collector
|
|||
this.WriteEvent(5, eventName);
|
||||
}
|
||||
|
||||
[Event(6, Message = "Request is filtered out.", Level = EventLevel.Verbose)]
|
||||
public void RequestIsFilteredOut(string eventName)
|
||||
{
|
||||
this.WriteEvent(6, eventName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a culture-independent string representation of the given <paramref name="exception"/> object,
|
||||
/// appropriate for diagnostics tracing.
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@ namespace OpenTelemetry.Collector
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
using OpenTelemetry.Trace.Configuration;
|
||||
using Xunit;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using TestApp.AspNetCore._2._0;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OpenTelemetry.Trace;
|
||||
|
|
@ -26,11 +25,10 @@ using Moq;
|
|||
using Microsoft.AspNetCore.TestHost;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using OpenTelemetry.Trace.Samplers;
|
||||
using TestApp.AspNetCore._3._0;
|
||||
|
||||
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||
{
|
||||
|
|
@ -98,13 +96,6 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
|||
var expectedTraceId = ActivityTraceId.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
|
||||
using (var testFactory = this.factory
|
||||
.WithWebHostBuilder(builder =>
|
||||
|
|
@ -112,15 +103,16 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
|||
{
|
||||
services.AddSingleton<TracerFactory>(_ =>
|
||||
TracerFactory.Create(b => b
|
||||
.SetSampler(new AlwaysSampleSampler())
|
||||
.SetTextFormat(tf.Object)
|
||||
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
||||
.AddRequestCollector()));
|
||||
})))
|
||||
using (var client = testFactory.CreateClient())
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "/api/values/2");
|
||||
request.Headers.Add("traceparent", $"00-{expectedTraceId}-{expectedSpanId}-01");
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values/2");
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -142,27 +134,14 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
|||
[Fact]
|
||||
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>();
|
||||
|
||||
void ConfigureTestServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<TracerFactory>(_ =>
|
||||
TracerFactory.Create(b => b
|
||||
.SetSampler(new AlwaysSampleSampler())
|
||||
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
||||
.AddRequestCollector(o => o.EventFilter = Filter)));
|
||||
.AddRequestCollector(o => o.RequestFilter = (httpContext) => httpContext.Request.Path != "/api/values/2")));
|
||||
}
|
||||
|
||||
// Arrange
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
using OpenTelemetry.Trace.Configuration;
|
||||
using Xunit;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using TestApp.AspNetCore._2._0;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OpenTelemetry.Trace;
|
||||
|
|
@ -26,7 +25,7 @@ using Moq;
|
|||
using Microsoft.AspNetCore.TestHost;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using OpenTelemetry.Trace.Samplers;
|
||||
using TestApp.AspNetCore._3._0;
|
||||
|
||||
namespace OpenTelemetry.Collector.AspNetCore.Tests
|
||||
{
|
||||
|
|
@ -65,7 +64,6 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
|||
services.AddSingleton<CallbackMiddleware.CallbackMiddlewareImpl>(new TestCallbackMiddlewareImpl());
|
||||
services.AddSingleton<TracerFactory>(_ =>
|
||||
TracerFactory.Create(b => b
|
||||
.SetSampler(new AlwaysSampleSampler())
|
||||
.AddProcessorPipeline(p => p.AddProcessor(e => spanProcessor.Object))
|
||||
.AddRequestCollector()));
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry</Description>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -28,9 +28,8 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
<ProjectReference Include="..\TestApp.AspNetCore.2.0\TestApp.AspNetCore.2.0.csproj" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.2" />
|
||||
<ProjectReference Include="..\TestApp.AspNetCore.3.0\TestApp.AspNetCore.3.0.csproj" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ namespace OpenTelemetry.Collector.Dependencies.Tests
|
|||
{
|
||||
RequestUri = new Uri(tc.Url),
|
||||
Method = new HttpMethod(tc.Method),
|
||||
Version = new Version(2, 0),
|
||||
};
|
||||
|
||||
if (tc.Headers != null)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry</Description>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry.Shims.OpenTracing</Description>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>Unit test project for OpenTelemetry</Description>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApp.AspNetCore._2._0
|
||||
namespace TestApp.AspNetCore._3._0
|
||||
{
|
||||
public class CallbackMiddleware
|
||||
{
|
||||
|
|
@ -19,35 +19,21 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TestApp.AspNetCore._2._0.Controllers
|
||||
namespace TestApp.AspNetCore._3._0.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class ForwardController : Controller
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
// POST api/test
|
||||
[HttpPost]
|
||||
public async Task<string> Post([FromBody]Data[] data)
|
||||
public async Task<string> Post([FromBody] Data[] data)
|
||||
{
|
||||
var result = string.Empty;
|
||||
|
||||
|
|
@ -55,13 +41,12 @@ namespace TestApp.AspNetCore._2._0.Controllers
|
|||
{
|
||||
foreach (var argument in data)
|
||||
{
|
||||
if (argument.sleep != null)
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, argument.Url)
|
||||
{
|
||||
result = "slept for " + argument.sleep.Value + " ms";
|
||||
await Task.Delay(argument.sleep.Value);
|
||||
}
|
||||
|
||||
result += await CallNextAsync(argument.url, argument.arguments);
|
||||
Content = new StringContent(JsonConvert.SerializeObject(argument.Arguments),
|
||||
Encoding.UTF8, "application/json"),
|
||||
};
|
||||
await this.httpClient.SendAsync(request);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -75,8 +60,11 @@ namespace TestApp.AspNetCore._2._0.Controllers
|
|||
|
||||
public class Data
|
||||
{
|
||||
public int? sleep { get; set; }
|
||||
public string url { get; set; }
|
||||
public Data[] arguments { get; set; }
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonProperty("arguments")]
|
||||
public Data[] Arguments { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TestApp.AspNetCore._2._0.Controllers
|
||||
namespace TestApp.AspNetCore._3._0.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class ValuesController : Controller
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace TestApp.AspNetCore._2._0
|
||||
namespace TestApp.AspNetCore._3._0
|
||||
{
|
||||
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.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using OpenTelemetry.Trace.Configuration;
|
||||
|
||||
namespace TestApp.AspNetCore._2._0
|
||||
namespace TestApp.AspNetCore._3._0
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
|
@ -39,10 +41,14 @@ namespace TestApp.AspNetCore._2._0
|
|||
services.AddSingleton<HttpClient>();
|
||||
services.AddSingleton(
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, TracerFactory factory)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TracerFactory factory)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
|
@ -50,7 +56,14 @@ namespace TestApp.AspNetCore._2._0
|
|||
}
|
||||
|
||||
app.UseMiddleware<CallbackMiddleware>();
|
||||
app.UseMvc();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -11,14 +11,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.All">
|
||||
<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" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -26,6 +19,7 @@
|
|||
<ProjectReference Include="..\..\src\OpenTelemetry.Collector.AspNetCore\OpenTelemetry.Collector.AspNetCore.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.Hosting\OpenTelemetry.Hosting.csproj" />
|
||||
<ProjectReference Include="..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Loading…
Reference in New Issue