[WCF] Automated test for iis-hosted service scenario (#2576)
This commit is contained in:
parent
eaf73bcd0b
commit
19f4480590
|
|
@ -189,6 +189,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.AutoInstrumen
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.AssemblyRedirection.NetFramework", "test\test-applications\integrations\TestApplication.AssemblyRedirection.NetFramework\TestApplication.AssemblyRedirection.NetFramework.csproj", "{66FB648E-7FAF-418B-B2F6-B7CB9EE579CA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.Wcf.Server.IIS.NetFramework", "test\test-applications\integrations\TestApplication.Wcf.Server.IIS.NetFramework\TestApplication.Wcf.Server.IIS.NetFramework.csproj", "{65619BD1-4517-400C-8071-C1409A7D255E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -865,6 +867,18 @@ Global
|
|||
{66FB648E-7FAF-418B-B2F6-B7CB9EE579CA}.Release|x64.Build.0 = Release|x64
|
||||
{66FB648E-7FAF-418B-B2F6-B7CB9EE579CA}.Release|x86.ActiveCfg = Release|x86
|
||||
{66FB648E-7FAF-418B-B2F6-B7CB9EE579CA}.Release|x86.Build.0 = Release|x86
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -931,6 +945,7 @@ Global
|
|||
{1D7E11AA-27B6-4863-B5EC-1F0ECC6979B2} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
|
||||
{0077F121-DC2B-425E-A2F4-DEAC2A566E14} = {5C915382-C886-457D-8641-9E766D8E5A17}
|
||||
{66FB648E-7FAF-418B-B2F6-B7CB9EE579CA} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
|
||||
{65619BD1-4517-400C-8071-C1409A7D255E} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
|
||||
|
|
|
|||
|
|
@ -106,28 +106,37 @@ partial class Build
|
|||
{
|
||||
var aspNetProject = Solution.GetProjectByName(Projects.Tests.Applications.AspNet);
|
||||
|
||||
MSBuild(x => x
|
||||
.SetConfiguration(BuildConfiguration)
|
||||
.SetTargetPlatform(Platform)
|
||||
.SetProperty("DeployOnBuild", true)
|
||||
.SetMaxCpuCount(null)
|
||||
.SetProperty("PublishProfile", aspNetProject.Directory / "Properties" / "PublishProfiles" / $"FolderProfile.{BuildConfiguration}.pubxml")
|
||||
.SetTargetPath(aspNetProject));
|
||||
|
||||
var localCopyTracerHome = aspNetProject.Directory / "bin" / "tracer-home";
|
||||
CopyDirectoryRecursively(TracerHomeDirectory, localCopyTracerHome);
|
||||
|
||||
DockerBuild(x => x
|
||||
.SetPath(".")
|
||||
.SetBuildArg($"configuration={BuildConfiguration}", $"windowscontainer_version={WindowsContainerVersion}")
|
||||
.SetRm(true)
|
||||
.SetTag(Path.GetFileNameWithoutExtension(aspNetProject).Replace(".", "-").ToLowerInvariant())
|
||||
.SetProcessWorkingDirectory(aspNetProject.Directory)
|
||||
);
|
||||
BuildDockerImage(aspNetProject);
|
||||
|
||||
Directory.Delete(localCopyTracerHome, true);
|
||||
|
||||
var wcfProject = Solution.GetProjectByName(Projects.Tests.Applications.Wcf);
|
||||
BuildDockerImage(wcfProject);
|
||||
});
|
||||
|
||||
void BuildDockerImage(Project project)
|
||||
{
|
||||
MSBuild(x => x
|
||||
.SetConfiguration(BuildConfiguration)
|
||||
.SetTargetPlatform(Platform)
|
||||
.SetProperty("DeployOnBuild", true)
|
||||
.SetMaxCpuCount(null)
|
||||
.SetProperty("PublishProfile",
|
||||
project.Directory / "Properties" / "PublishProfiles" / $"FolderProfile.{BuildConfiguration}.pubxml")
|
||||
.SetTargetPath(project));
|
||||
|
||||
DockerBuild(x => x
|
||||
.SetPath(".")
|
||||
.SetBuildArg($"configuration={BuildConfiguration}", $"windowscontainer_version={WindowsContainerVersion}")
|
||||
.EnableRm()
|
||||
.SetTag(Path.GetFileNameWithoutExtension(project).Replace(".", "-").ToLowerInvariant())
|
||||
.SetProcessWorkingDirectory(project.Directory)
|
||||
);
|
||||
}
|
||||
|
||||
Target GenerateNetFxTransientDependencies => _ => _
|
||||
.Unlisted()
|
||||
.After(Restore)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ partial class Build
|
|||
{
|
||||
// Projects using `packages.config` can't be restored via "dotnet restore", use a NuGet Task to restore these projects.
|
||||
var legacyRestoreProjects = Solution.GetNativeProjects()
|
||||
.Concat(new[] { Solution.GetProjectByName(Projects.Tests.Applications.AspNet) });
|
||||
.Concat(new[] { Solution.GetProjectByName(Projects.Tests.Applications.AspNet) })
|
||||
.Concat(new[] { Solution.GetProjectByName(Projects.Tests.Applications.Wcf) });
|
||||
|
||||
foreach (var project in legacyRestoreProjects)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public static class Projects
|
|||
public static class Applications
|
||||
{
|
||||
public const string AspNet = "TestApplication.AspNet.NetFramework";
|
||||
public const string Wcf = "TestApplication.Wcf.Server.IIS.NetFramework";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ public class AspNetTests
|
|||
collector.Expect("OpenTelemetry.Instrumentation.AspNet.Telemetry"); // Expect WebApi span
|
||||
|
||||
string collectorUrl = $"http://{DockerNetworkHelper.IntegrationTestsGateway}:{collector.Port}";
|
||||
_environmentVariables["OTEL_TRACES_EXPORTER"] = "otlp";
|
||||
_environmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] = collectorUrl;
|
||||
var webPort = TcpPortProvider.GetOpenPort();
|
||||
await using var container = await StartContainerAsync(webPort);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
// <copyright file="WcfIISTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using DotNet.Testcontainers.Builders;
|
||||
using DotNet.Testcontainers.Containers;
|
||||
using FluentAssertions;
|
||||
using IntegrationTests.Helpers;
|
||||
using OpenTelemetry.Proto.Trace.V1;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace IntegrationTests;
|
||||
|
||||
public class WcfIISTests : TestHelper
|
||||
{
|
||||
private readonly Dictionary<string, string> _environmentVariables = new();
|
||||
|
||||
public WcfIISTests(ITestOutputHelper output)
|
||||
: base("Wcf.Client.NetFramework", output)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", "EndToEnd")]
|
||||
[Trait("Containers", "Windows")]
|
||||
public async Task SubmitsTraces()
|
||||
{
|
||||
Assert.True(EnvironmentTools.IsWindowsAdministrator(), "This test requires Windows Administrator privileges.");
|
||||
|
||||
// Using "*" as host requires Administrator. This is needed to make the mock collector endpoint
|
||||
// accessible to the Windows docker container where the test application is executed by binding
|
||||
// the endpoint to all network interfaces. In order to do that it is necessary to open the port
|
||||
// on the firewall.
|
||||
using var collector = new MockSpansCollector(Output, host: "*");
|
||||
SetExporter(collector);
|
||||
using var fwPort = FirewallHelper.OpenWinPort(collector.Port, Output);
|
||||
|
||||
collector.Expect("OpenTelemetry.Instrumentation.Wcf", span => span.Kind == Span.Types.SpanKind.Server, "Server1");
|
||||
collector.Expect("OpenTelemetry.Instrumentation.Wcf", span => span.Kind == Span.Types.SpanKind.Client, "Client1");
|
||||
collector.Expect("OpenTelemetry.Instrumentation.Wcf", span => span.Kind == Span.Types.SpanKind.Server, "Server2");
|
||||
collector.Expect("OpenTelemetry.Instrumentation.Wcf", span => span.Kind == Span.Types.SpanKind.Client, "Client2");
|
||||
|
||||
var collectorUrl = $"http://{DockerNetworkHelper.IntegrationTestsGateway}:{collector.Port}";
|
||||
_environmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] = collectorUrl;
|
||||
|
||||
var netTcpPort = TcpPortProvider.GetOpenPort();
|
||||
var httpPort = TcpPortProvider.GetOpenPort();
|
||||
|
||||
await using var container = await StartContainerAsync(netTcpPort, httpPort);
|
||||
|
||||
RunTestApplication(new TestSettings
|
||||
{
|
||||
Arguments = $"{netTcpPort} {httpPort}"
|
||||
});
|
||||
|
||||
collector.AssertExpectations();
|
||||
}
|
||||
|
||||
private async Task<IContainer> StartContainerAsync(int netTcpPort, int httpPort)
|
||||
{
|
||||
const string imageName = "testapplication-wcf-server-iis-netframework";
|
||||
|
||||
var networkId = await DockerNetworkHelper.SetupIntegrationTestsNetworkAsync();
|
||||
|
||||
var logPath = EnvironmentHelper.IsRunningOnCI()
|
||||
? Path.Combine(Environment.GetEnvironmentVariable("GITHUB_WORKSPACE"), "build_data", "profiler-logs")
|
||||
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"OpenTelemetry .NET AutoInstrumentation", "logs");
|
||||
|
||||
Directory.CreateDirectory(logPath);
|
||||
Output.WriteLine("Collecting docker logs to: " + logPath);
|
||||
|
||||
var builder = new ContainerBuilder()
|
||||
.WithImage(imageName)
|
||||
.WithCleanUp(cleanUp: true)
|
||||
.WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole())
|
||||
.WithName($"{imageName}")
|
||||
.WithNetwork(networkId, DockerNetworkHelper.IntegrationTestsNetworkName)
|
||||
.WithPortBinding(netTcpPort, 808)
|
||||
.WithPortBinding(httpPort, 80)
|
||||
.WithBindMount(logPath, "c:/inetpub/wwwroot/logs")
|
||||
.WithBindMount(EnvironmentHelper.GetNukeBuildOutput(), "c:/opentelemetry");
|
||||
|
||||
foreach (var env in _environmentVariables)
|
||||
{
|
||||
builder = builder.WithEnvironment(env.Key, env.Value);
|
||||
}
|
||||
|
||||
var container = builder.Build();
|
||||
try
|
||||
{
|
||||
var wasStarted = container.StartAsync().Wait(TimeSpan.FromMinutes(5));
|
||||
wasStarted.Should().BeTrue($"Container based on {imageName} has to be operational for the test.");
|
||||
Output.WriteLine("Container was started successfully.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
await container.DisposeAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Client.DotNet;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusRequest
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Client.DotNet;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusResponse
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<system.serviceModel>
|
||||
<extensions>
|
||||
</extensions>
|
||||
<behaviors>
|
||||
</behaviors>
|
||||
<bindings>
|
||||
<basicHttpBinding>
|
||||
<binding name="basicHttpConfig">
|
||||
<security mode="None" />
|
||||
</binding>
|
||||
</basicHttpBinding>
|
||||
<netTcpBinding>
|
||||
<binding name="netTCPConfig">
|
||||
<security mode="None" />
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<client>
|
||||
<endpoint address="http://127.0.0.1:9009/Telemetry" binding="basicHttpBinding" bindingConfiguration="basicHttpConfig" contract="TestApplication.Wcf.Client.NetFramework.IStatusServiceContract" name="StatusService_Http" />
|
||||
<endpoint address="net.tcp://127.0.0.1:9090/Telemetry" binding="netTcpBinding" bindingConfiguration="netTCPConfig" contract="TestApplication.Wcf.Client.NetFramework.IStatusServiceContract" name="StatusService_Tcp" />
|
||||
</client>
|
||||
</system.serviceModel>
|
||||
</configuration>
|
||||
|
|
@ -15,23 +15,44 @@
|
|||
// </copyright>
|
||||
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace TestApplication.Wcf.Client.NetFramework;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
public static async Task Main()
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
await CallService("StatusService_Tcp").ConfigureAwait(false);
|
||||
await CallService("StatusService_Http").ConfigureAwait(false);
|
||||
string netTcpAddress;
|
||||
string httpAddress;
|
||||
if (args.Length == 0)
|
||||
{
|
||||
// Self-hosted service addresses
|
||||
netTcpAddress = "net.tcp://127.0.0.1:9090/Telemetry";
|
||||
httpAddress = "http://127.0.0.1:9009/Telemetry";
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
// Addresses of a service hosted in IIS inside container
|
||||
netTcpAddress = $"net.tcp://localhost:{args[0]}/StatusService.svc";
|
||||
httpAddress = $"http://localhost:{args[1]}/StatusService.svc";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("TestApplication.Wcf.Client.NetFramework application requires either 0 or exactly 2 arguments.");
|
||||
}
|
||||
|
||||
await CallService(netTcpAddress, new NetTcpBinding(SecurityMode.None)).ConfigureAwait(false);
|
||||
await CallService(httpAddress, new BasicHttpBinding()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async Task CallService(string name)
|
||||
private static async Task CallService(string address, Binding binding)
|
||||
{
|
||||
// Note: Best practice is to re-use your client/channel instances.
|
||||
// This code is not meant to illustrate best practices, only the
|
||||
// instrumentation.
|
||||
var client = new StatusServiceClient(name);
|
||||
var client = new StatusServiceClient(binding, new EndpointAddress(new Uri(address)));
|
||||
try
|
||||
{
|
||||
await client.OpenAsync().ConfigureAwait(false);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Client.NetFramework;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusRequest
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Client.NetFramework;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusResponse
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
|
|
@ -15,14 +15,15 @@
|
|||
// </copyright>
|
||||
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApplication.Wcf.Client.NetFramework;
|
||||
|
||||
public class StatusServiceClient : ClientBase<IStatusServiceContract>, IStatusServiceContract
|
||||
{
|
||||
public StatusServiceClient(string name)
|
||||
: base(name)
|
||||
public StatusServiceClient(Binding binding, EndpointAddress remoteAddress)
|
||||
: base(binding, remoteAddress)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
<Project>
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\Integrations.props" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# escape=`
|
||||
|
||||
ARG windowscontainer_version=ltsc2022
|
||||
FROM mcr.microsoft.com/dotnet/framework/wcf:4.8-windowsservercore-${windowscontainer_version}
|
||||
ARG configuration=Debug
|
||||
ARG platform=x64
|
||||
ENV COR_ENABLE_PROFILING=1 `
|
||||
COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} `
|
||||
COR_PROFILER_PATH=C:\opentelemetry\win-${platform}\OpenTelemetry.AutoInstrumentation.Native.dll `
|
||||
OTEL_DOTNET_AUTO_HOME=C:\opentelemetry\ `
|
||||
OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES=TestApplication.* `
|
||||
OTEL_LOG_LEVEL=debug `
|
||||
OTEL_DOTNET_AUTO_LOG_DIRECTORY=C:\inetpub\wwwroot\logs
|
||||
WORKDIR /inetpub/wwwroot
|
||||
COPY bin/${configuration}/app.publish .
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// <copyright file="IStatusServiceContract.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.ServiceModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApplication.Wcf.Server.IIS.NetFramework;
|
||||
|
||||
[ServiceContract(Namespace = "http://opentelemetry.io/", Name = "StatusService", SessionMode = SessionMode.Allowed)]
|
||||
public interface IStatusServiceContract
|
||||
{
|
||||
[OperationContract]
|
||||
Task<StatusResponse> PingAsync(StatusRequest request);
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// <copyright file="AssemblyInfo.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TestApplication.Wcf.Server.IIS.NetFramework")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestApplication.Wcf.Server.IIS.NetFramework")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("65619bd1-4517-400c-8071-c1409a7d255e")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>x64</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Debug\app.publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>x64</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\app.publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// <copyright file="StatusRequest.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TestApplication.Wcf.Server.IIS.NetFramework;
|
||||
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusRequest
|
||||
{
|
||||
[DataMember]
|
||||
public string Status { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// <copyright file="StatusResponse.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TestApplication.Wcf.Server.IIS.NetFramework;
|
||||
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusResponse
|
||||
{
|
||||
[DataMember]
|
||||
public DateTimeOffset ServerTime { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// <copyright file="StatusService.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.ServiceModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApplication.Wcf.Server.IIS.NetFramework;
|
||||
|
||||
[ServiceBehavior(
|
||||
Namespace = "http://opentelemetry.io/",
|
||||
ConcurrencyMode = ConcurrencyMode.Multiple,
|
||||
InstanceContextMode = InstanceContextMode.Single,
|
||||
UseSynchronizationContext = false,
|
||||
Name = "StatusService")]
|
||||
public class StatusService : IStatusServiceContract
|
||||
{
|
||||
public Task<StatusResponse> PingAsync(StatusRequest request)
|
||||
{
|
||||
return Task.FromResult(
|
||||
new StatusResponse { ServerTime = DateTimeOffset.UtcNow });
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%@ ServiceHost Language="C#" Debug="true" Service="TestApplication.Wcf.Server.IIS.NetFramework.StatusService" CodeBehind="StatusService.cs" %>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\build\MSBuild.Microsoft.VisualStudio.Web.targets.props" Condition="Exists('..\..\..\..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\build\MSBuild.Microsoft.VisualStudio.Web.targets.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{65619BD1-4517-400C-8071-C1409A7D255E}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestApplication.Wcf.Server.IIS.NetFramework</RootNamespace>
|
||||
<AssemblyName>TestApplication.Wcf.Server.IIS.NetFramework</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<WcfConfigValidationEnabled>True</WcfConfigValidationEnabled>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<Use64BitIISExpress />
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceModel.Web" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="StatusService.svc" />
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IStatusServiceContract.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StatusRequest.cs" />
|
||||
<Compile Include="StatusResponse.cs" />
|
||||
<Compile Include="StatusService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Dockerfile" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Web.Release.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>62503</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:62503/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
|
||||
<appSettings>
|
||||
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.6.2" />
|
||||
<httpRuntime targetFramework="4.6.2"/>
|
||||
</system.web>
|
||||
<system.serviceModel>
|
||||
<extensions>
|
||||
<behaviorExtensions>
|
||||
<add name="telemetryExtension" type="OpenTelemetry.Instrumentation.Wcf.TelemetryEndpointBehaviorExtensionElement, OpenTelemetry.Instrumentation.Wcf" />
|
||||
</behaviorExtensions>
|
||||
</extensions>
|
||||
<services>
|
||||
<service name="TestApplication.Wcf.Server.IIS.NetFramework.StatusService">
|
||||
<endpoint binding="basicHttpBinding" behaviorConfiguration="telemetry" contract="TestApplication.Wcf.Server.IIS.NetFramework.IStatusServiceContract"/>
|
||||
<endpoint binding="netTcpBinding" behaviorConfiguration="telemetry" contract="TestApplication.Wcf.Server.IIS.NetFramework.IStatusServiceContract" bindingConfiguration="noSecurityBind"/>
|
||||
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
|
||||
</service>
|
||||
</services>
|
||||
<bindings>
|
||||
<netTcpBinding>
|
||||
<binding name="noSecurityBind" portSharingEnabled="false">
|
||||
<security mode="None"/>
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<behaviors>
|
||||
<endpointBehaviors>
|
||||
<behavior name="telemetry">
|
||||
<telemetryExtension />
|
||||
</behavior>
|
||||
</endpointBehaviors>
|
||||
<serviceBehaviors>
|
||||
<behavior>
|
||||
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
|
||||
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
|
||||
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
|
||||
<serviceDebug includeExceptionDetailInFaults="false"/>
|
||||
</behavior>
|
||||
</serviceBehaviors>
|
||||
</behaviors>
|
||||
<protocolMapping>
|
||||
<add binding="basicHttpsBinding" scheme="https" />
|
||||
</protocolMapping>
|
||||
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
|
||||
</system.serviceModel>
|
||||
<system.webServer>
|
||||
<modules runAllManagedModulesForAllRequests="true"/>
|
||||
<!--
|
||||
To browse web app root directory during debugging, set the value below to true.
|
||||
Set to false before deployment to avoid disclosing web app folder information.
|
||||
-->
|
||||
<directoryBrowse enabled="true"/>
|
||||
</system.webServer>
|
||||
|
||||
</configuration>
|
||||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Server.NetFramework;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusRequest
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using System.Runtime.Serialization;
|
|||
|
||||
namespace TestApplication.Wcf.Server.NetFramework;
|
||||
|
||||
[DataContract]
|
||||
[DataContract(Namespace = "http://opentelemetry.io/")]
|
||||
public class StatusResponse
|
||||
{
|
||||
[DataMember]
|
||||
|
|
|
|||
Loading…
Reference in New Issue