Minor improvements to OT (#972)

Adding copyright header to files, and other changes

adding headers

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
Eddy Nakamura 2020-08-02 10:48:58 -03:00 committed by GitHub
parent 2e4b081f6d
commit a326550305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 253 additions and 86 deletions

View File

@ -1,12 +0,0 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "4.5.8",
"commands": [
"reportgenerator"
]
}
}
}

View File

@ -42,7 +42,7 @@ jobs:
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Merging test results
run: reportgenerator -reports:TestResults/**/*.xml -targetdir:TestResults -reporttypes:Cobertura
run: reportgenerator -reports:TestResults/**/*.xml -targetdir:TestResults -reporttypes:Cobertura -assemblyFilters:-xunit*
- uses: codecov/codecov-action@v1.0.12
with:

View File

@ -20,8 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E-03FA-4FFF-89A5-C51F107623FD}"
ProjectSection(SolutionItems) = preProject
build\Common.props = build\Common.props
build\Common.prod.props = build\Common.prod.props
build\Common.props = build\Common.props
build\Common.test.props = build\Common.test.props
build\debug.snk = build\debug.snk
build\docfx.cmd = build\docfx.cmd
@ -166,6 +166,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7C87CAF9-7
docs\logs\logging-correlation.md = docs\logs\logging-correlation.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{2C7DD1DA-C229-4D9E-9AF0-BCD5CD3E4948}"
ProjectSection(SolutionItems) = preProject
examples\Directory.Build.props = examples\Directory.Build.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -331,6 +336,7 @@ Global
{FF3E6E08-E8E4-4523-B526-847CD989279F} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{0935622B-9377-4056-8343-AE6ECDC274CF} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{DE9130A4-F30A-49D7-8834-41DE3021218B} = {0169B149-FB8B-46F4-9EF7-8A0E69F8FAAF}
{2C7DD1DA-C229-4D9E-9AF0-BCD5CD3E4948} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}

View File

@ -1,4 +1,20 @@
using System.Web.Mvc;
// <copyright file="RouteConfig.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.Web.Mvc;
using System.Web.Routing;
namespace Examples.AspNet
@ -14,8 +30,7 @@ namespace Examples.AspNet
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
}
}

View File

@ -1,4 +1,20 @@
using System.Net.Http.Formatting;
// <copyright file="WebApiConfig.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.Net.Http.Formatting;
using System.Web.Http;
namespace Examples.AspNet
@ -15,8 +31,7 @@ namespace Examples.AspNet
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
defaults: new { id = RouteParameter.Optional });
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());

View File

@ -1,4 +1,20 @@
using System.Web.Mvc;
// <copyright file="HomeController.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.Web.Mvc;
namespace Examples.AspNet.Controllers
{

View File

@ -1,4 +1,20 @@
using System;
// <copyright file="WeatherForecastController.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.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -14,7 +30,7 @@ namespace Examples.AspNet.Controllers
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
};
[HttpGet] // For testing traditional routing. Ex: https://localhost:XXXX/api/weatherforecast
@ -62,7 +78,7 @@ namespace Examples.AspNet.Controllers
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
Summary = Summaries[rng.Next(Summaries.Length)],
})
.ToArray();
}
@ -77,48 +93,6 @@ namespace Examples.AspNet.Controllers
response.EnsureSuccessStatusCode();
}
// Test exception dependency collection via HttpClient.
private async Task RequestInvalidViaHttpClient()
{
try
{
using var request = new HttpClient();
// This request is not available over SSL and will throw a handshake exception.
using var response = await request.GetAsync(this.Url.Content("~/subroute/10").Replace("http", "https")).ConfigureAwait(false);
Debug.Fail("Unreachable");
}
catch
{
}
}
// Test exception dependency collection via HttpClient.
private async Task RequestValidThatReturnsFailedViaHttpClient()
{
using var request = new HttpClient();
// This request will return a 500 error because customerId should be >= 0;
using var response = await request.GetAsync(this.Url.Content("~/subroute/-1")).ConfigureAwait(false);
Debug.Assert(response.StatusCode == HttpStatusCode.InternalServerError);
}
// Test successful dependency collection via HttpClient.
private async Task RequestValidThatSpawnsSubSpansViaHttpClient()
{
using var request = new HttpClient();
// This request will return successfully and cause a bunch of sub-spans;
using var response = await request.GetAsync(this.Url.Content("~/subroute/10")).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
}
// Test dependency collection via legacy HttpWebRequest sync.
private static void RequestGoogleHomPageViaHttpWebRequestLegacySync()
{
@ -144,5 +118,47 @@ namespace Examples.AspNet.Controllers
using var response = request.EndGetResponse(asyncResult);
}
// Test exception dependency collection via HttpClient.
private async Task RequestInvalidViaHttpClient()
{
try
{
using var request = new HttpClient();
// This request is not available over SSL and will throw a handshake exception.
using var response = await request.GetAsync(this.Url.Content("~/subroute/10").Replace("http", "https")).ConfigureAwait(false);
Debug.Fail("Unreachable");
}
catch
{
}
}
// Test exception dependency collection via HttpClient.
private async Task RequestValidThatReturnsFailedViaHttpClient()
{
using var request = new HttpClient();
// This request will return a 500 error because customerId should be >= 0;
using var response = await request.GetAsync(this.Url.Content("~/subroute/-1")).ConfigureAwait(false);
Debug.Assert(response.StatusCode == HttpStatusCode.InternalServerError, "response.StatusCode is InternalServerError");
}
// Test successful dependency collection via HttpClient.
private async Task RequestValidThatSpawnsSubSpansViaHttpClient()
{
using var request = new HttpClient();
// This request will return successfully and cause a bunch of sub-spans;
using var response = await request.GetAsync(this.Url.Content("~/subroute/10")).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
}
}
}

View File

@ -1,4 +1,20 @@
using System;
// <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.Web;
using System.Web.Http;
using System.Web.Mvc;
@ -8,7 +24,9 @@ using OpenTelemetry.Trace;
namespace Examples.AspNet
{
#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 openTelemetry;

View File

@ -1,4 +1,20 @@
using System;
// <copyright file="WeatherForecast.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;
namespace Examples.AspNet.Models
{

View File

@ -1,4 +1,20 @@
using System.Reflection;
// <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.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -1,4 +1,20 @@
using System;
// <copyright file="WeatherForecastController.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.Collections.Generic;
using System.Linq;
using System.Net.Http;
@ -13,7 +29,7 @@ namespace Examples.AspNetCore.Controllers
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
};
private static HttpClient httpClient = new HttpClient();
@ -30,7 +46,7 @@ namespace Examples.AspNetCore.Controllers
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
Summary = Summaries[rng.Next(Summaries.Length)],
})
.ToArray();
}

View File

@ -1,4 +1,20 @@
using System;
// <copyright file="WeatherForecast.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;
namespace Examples.AspNetCore.Models
{

View File

@ -1,4 +1,20 @@
using Microsoft.AspNetCore.Hosting;
// <copyright file="Program.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 Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Examples.AspNetCore

View File

@ -1,4 +1,20 @@
using System;
// <copyright file="Startup.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.IO;
using System.Reflection;
using Microsoft.AspNetCore.Builder;

View File

@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\Common.prod.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
@ -7,10 +6,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<CodeAnalysisRuleSet>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))/build/OpenTelemetry.prod.loose.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="StackExchange.Redis" Version="2.1.58" />

View File

@ -117,7 +117,8 @@ namespace Examples.Console
this.cts = new CancellationTokenSource();
var cancellationToken = this.cts.Token;
this.requestTask = Task.Run(async () =>
this.requestTask = Task.Run(
async () =>
{
using var source = new ActivitySource("Samples.SampleClient");
using var client = new HttpClient();

View File

@ -33,8 +33,9 @@ namespace Examples.Console
using var tracerProvider = Sdk.CreateTracerProvider(
(builder) => builder.AddActivitySource("MyCompany.MyProduct.MyWebServer")
.SetResource(Resources.CreateServiceResource("MyServiceName"))
.UseConsoleExporter(opt => opt.DisplayAsJson = options.DisplayAsJson,
(p) => p.AddProcessor((next) => new MyProcessor(next))));
.UseConsoleExporter(
opt => opt.DisplayAsJson = options.DisplayAsJson,
(p) => p.AddProcessor((next) => new MyProcessor(next))));
// The above line is required only in applications
// which decide to use Open Telemetry.

View File

@ -0,0 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\Common.test.props" />
</Project>

View File

@ -16,7 +16,6 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("OpenTelemetry.Extensions.Hosting.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)]

View File

@ -17,8 +17,6 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("OpenTelemetry.Instrumentation.AspNetCore.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("OpenTelemetry.Instrumentation.StackExchangeRedis.Tests" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)]
#if SIGNED