Skip to content

Commit

Permalink
Convert WCF aspnet example app to new csproj format
Browse files Browse the repository at this point in the history
  • Loading branch information
repl-chris committed Sep 14, 2023
1 parent 3811ab5 commit c02a8d0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,19 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{23AA75F6-403F-4867-BF0E-BAF0A44F9A7A}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Examples.Wcf.Server.AspNetFramework</RootNamespace>
<AssemblyName>Examples.Wcf.Server.AspNetFramework</AssemblyName>
<TargetFrameworkVersion>v4.8</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>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AppConfig>web.config</AppConfig>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="DotNetCoreWeb" />
<ProjectCapability Include="SupportsSystemWeb" />
<ProjectCapability Include="LegacyRazorEditor" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
Expand All @@ -60,9 +34,7 @@
<DependentUpon>StatusService.svc</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="stylecop.json" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand All @@ -71,35 +43,31 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj">
<Project>{ec83d37a-3704-4515-8ee8-4d007cd9e0a8}</Project>
<Name>OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\OpenTelemetry.Instrumentation.AspNet\OpenTelemetry.Instrumentation.AspNet.csproj">
<Project>{582b70b5-0067-4d9a-abf2-623f502be9a9}</Project>
<Name>OpenTelemetry.Instrumentation.AspNet</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\OpenTelemetry.Instrumentation.Wcf\OpenTelemetry.Instrumentation.Wcf.csproj">
<Project>{cad5c27a-d359-4086-9c4f-02204c084a8e}</Project>
<Name>OpenTelemetry.Instrumentation.Wcf</Name>
</ProjectReference>
<ProjectReference Include="..\shared\Examples.Wcf.Shared.csproj">
<Project>{21716c26-3b2a-4208-bdfb-8e58e2af49ea}</Project>
<Name>Examples.Wcf.Shared</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<!--
<PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="[5.2.9,6.0)" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="[5.2.9,6.0)" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="[3.2.9,4.0)" />
-->
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestVersion)" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryCoreLatestVersion)" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="$(OpenTelemetryCoreLatestVersion)" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet\OpenTelemetry.Instrumentation.AspNet.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.Wcf\OpenTelemetry.Instrumentation.Wcf.csproj" />
<ProjectReference Include="$(RepoRoot)\examples\wcf\shared\Examples.Wcf.Shared.csproj" />
</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="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="Exists('$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets')" />
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
<Target Name="SkipBuildWithoutVisualStudio">
<Message Text="Skipping build because Visual Studio is not available." Condition="!Exists('$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets')" />
<CallTarget Targets="$(BuildDependsOnOriginalValue)" Condition="Exists('$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets')" />
Expand All @@ -108,22 +76,4 @@
<BuildDependsOnOriginalValue>$(BuildDependsOn)</BuildDependsOnOriginalValue>
<BuildDependsOn>SkipBuildWithoutVisualStudio</BuildDependsOn>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>61494</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:61494/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
10 changes: 4 additions & 6 deletions examples/wcf/server-aspnetframework/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#pragma warning disable IDE0005 // Using directive is unnecessary.
using System;
using System.Configuration;
using System.Web;
Expand All @@ -23,7 +22,6 @@
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
#pragma warning restore IDE0005 // Using directive is unnecessary.

namespace Examples.Wcf.Server.AspNetFramework;

Expand All @@ -36,19 +34,19 @@ public class WebApiApplication : HttpApplication
protected void Application_Start()
{
var builder = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Wcf-AspNetServer"))
.ConfigureResource(resource => resource.AddService("Wcf-AspNetServer"))
.AddAspNetInstrumentation()
.AddWcfInstrumentation();

switch (ConfigurationManager.AppSettings["UseExporter"].ToLowerInvariant())
switch (ConfigurationManager.AppSettings["UseExporter"].ToUpperInvariant())
{
case "zipkin":
case "ZIPKIN":
builder.AddZipkinExporter(zipkinOptions =>
{
zipkinOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["ZipkinEndpoint"]);
});
break;
case "otlp":
case "OTLP":
builder.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["OtlpEndpoint"]);
Expand Down
18 changes: 18 additions & 0 deletions examples/wcf/server-aspnetframework/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:61494"
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
12 changes: 0 additions & 12 deletions examples/wcf/server-aspnetframework/stylecop.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace OpenTelemetry.Instrumentation.Wcf.Implementation;
/// </summary>
internal static class AspNetParentSpanCorrector
{
private const string TelemetryHttpModuleTypeName = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, PublicKeyToken=7bd6737fe5b67e3c";
private const string TelemetryHttpModuleOptionsTypeName = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, PublicKeyToken=7bd6737fe5b67e3c";
private const string TelemetryHttpModuleTypeName = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule";
private const string TelemetryHttpModuleOptionsTypeName = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule";

private static readonly ReflectedInfo ReflectedValues = Initialize();
private static readonly PropertyFetcher<object> RequestFetcher = new PropertyFetcher<object>("Request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void AspNetReflectionFailedToBind(Exception exception)
}
}

[Event(EventIds.AspNetReflectionFailedToBind, Message = "Failed to bind to asp.net instrumentation. Exception {0}.", Level = EventLevel.Verbose)]
[Event(EventIds.AspNetReflectionFailedToBind, Message = "Failed to bind to ASP.NET instrumentation. Exception {0}.", Level = EventLevel.Verbose)]
public void AspNetReflectionFailedToBind(string exception)
{
this.WriteEvent(EventIds.AspNetReflectionFailedToBind, exception);
Expand Down

0 comments on commit c02a8d0

Please sign in to comment.