-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wcf] Add AspNet parent span correction (#1342)
Co-authored-by: Piotr Kiełkowicz <pkiekowicz@splunk.com>
- Loading branch information
1 parent
f6e7359
commit fec6a63
Showing
21 changed files
with
805 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
{ | ||
"Server": "self-hosted", | ||
"Service": { | ||
"HttpAddress": "http://localhost:9009/Telemetry", | ||
"TcpAddress": "net.tcp://localhost:9090/Telemetry" | ||
"TcpAddress": "net.tcp://localhost:9090/Telemetry", | ||
"AspNetAddress": "http://localhost:61494/StatusService.svc" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
examples/wcf/server-aspnetframework/Examples.Wcf.Server.AspNetFramework.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<Project> | ||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | ||
<PropertyGroup> | ||
<TargetFramework>net462</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<OutputPath>bin\</OutputPath> | ||
<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" /> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.ServiceModel.Web" /> | ||
<Reference Include="System.Web" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Global.asax" /> | ||
<Content Include="StatusService.svc" /> | ||
<Content Include="Web.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Global.asax.cs"> | ||
<DependentUpon>Global.asax</DependentUpon> | ||
</Compile> | ||
<Compile Include="StatusService.svc.cs"> | ||
<DependentUpon>StatusService.svc</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Web.Debug.config"> | ||
<DependentUpon>Web.config</DependentUpon> | ||
</None> | ||
<None Include="Web.Release.config"> | ||
<DependentUpon>Web.config</DependentUpon> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<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="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')" /> | ||
</Target> | ||
<PropertyGroup> | ||
<BuildDependsOnOriginalValue>$(BuildDependsOn)</BuildDependsOnOriginalValue> | ||
<BuildDependsOn>SkipBuildWithoutVisualStudio</BuildDependsOn> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="Examples.Wcf.Server.AspNetFramework.WebApiApplication" Language="C#" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// <copyright file="Global.asax.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.Configuration; | ||
using System.Web; | ||
using OpenTelemetry; | ||
using OpenTelemetry.Exporter; | ||
using OpenTelemetry.Metrics; | ||
using OpenTelemetry.Resources; | ||
using OpenTelemetry.Trace; | ||
|
||
namespace Examples.Wcf.Server.AspNetFramework; | ||
|
||
#pragma warning disable SA1649 // File name should match first type name | ||
public class WebApiApplication : HttpApplication | ||
#pragma warning restore SA1649 // File name should match first type name | ||
{ | ||
private IDisposable? tracerProvider; | ||
|
||
protected void Application_Start() | ||
{ | ||
var builder = Sdk.CreateTracerProviderBuilder() | ||
.ConfigureResource(resource => resource.AddService("Wcf-AspNetServer")) | ||
.AddAspNetInstrumentation() | ||
.AddWcfInstrumentation(); | ||
|
||
switch (ConfigurationManager.AppSettings["UseExporter"].ToUpperInvariant()) | ||
{ | ||
case "ZIPKIN": | ||
builder.AddZipkinExporter(zipkinOptions => | ||
{ | ||
zipkinOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["ZipkinEndpoint"]); | ||
}); | ||
break; | ||
case "OTLP": | ||
builder.AddOtlpExporter(otlpOptions => | ||
{ | ||
otlpOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["OtlpEndpoint"]); | ||
}); | ||
break; | ||
default: | ||
builder.AddConsoleExporter(options => options.Targets = ConsoleExporterOutputTargets.Debug); | ||
break; | ||
} | ||
|
||
this.tracerProvider = builder.Build(); | ||
} | ||
|
||
protected void Application_End() | ||
{ | ||
this.tracerProvider?.Dispose(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/wcf/server-aspnetframework/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ ServiceHost Language="C#" Debug="true" Service="Examples.Wcf.Server.AspNetFramework.StatusService" CodeBehind="StatusService.svc.cs" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// <copyright file="StatusService.svc.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.Threading.Tasks; | ||
|
||
namespace Examples.Wcf.Server.AspNetFramework; | ||
|
||
public class StatusService : IStatusServiceContract | ||
{ | ||
public Task<StatusResponse> PingAsync(StatusRequest request) | ||
{ | ||
return Task.FromResult( | ||
new StatusResponse | ||
{ | ||
ServerTime = DateTimeOffset.UtcNow, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
Oops, something went wrong.