Skip to content

Commit

Permalink
Merge branch 'main' into onecollector-traceflags
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Sep 8, 2023
2 parents 4743734 + c4784de commit 305bb93
Show file tree
Hide file tree
Showing 82 changed files with 323 additions and 335 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v3

- name: Install format tool
run: dotnet tool install -g dotnet-format
- name: Install dependencies
run: dotnet restore

- name: Protobuf compile
run: dotnet build -t:Protobuf_Compile --no-restore
continue-on-error: true # Note: Projects without Grpc.Tools won't have the Protobuf_Compile target which generates an error

- name: dotnet format
run: dotnet-format --folder --check
run: dotnet format opentelemetry-dotnet-contrib.sln --no-restore --verify-no-changes
1 change: 0 additions & 1 deletion build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)/OpenTelemetryContrib.prod.ruleset</CodeAnalysisRuleSet>
<NoWarn>$(NoWarn),1573,1712</NoWarn>
<PackageOutputPath Condition="$(Build_ArtifactStagingDirectory) != ''">$(Build_ArtifactStagingDirectory)</PackageOutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!--<MinVerVerbosity>detailed</MinVerVerbosity>-->
<PackageTags>Observability;OpenTelemetry;Monitoring;Telemetry</PackageTags>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions build/Common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<LangVersion>11.0</LangVersion>
<LangVersion>latest</LangVersion>
<SignAssembly>true</SignAssembly>
<RepoRoot>$([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName)</RepoRoot>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)debug.snk</AssemblyOriginatorKeyFile>
Expand All @@ -10,7 +10,7 @@
<NetMinimumSupportedVersion>net6.0</NetMinimumSupportedVersion>
<NetStandardMinimumSupportedVersion>netstandard2.0</NetStandardMinimumSupportedVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisLevel>latest-All</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -35,7 +35,7 @@
<MicrosoftOwinPkgVer>[4.2.2,5.0)</MicrosoftOwinPkgVer>
<MicrosoftPublicApiAnalyzersPkgVer>[3.3.3]</MicrosoftPublicApiAnalyzersPkgVer>
<MicrosoftSourceLinkGitHubPkgVer>[1.1.1,2.0)</MicrosoftSourceLinkGitHubPkgVer>
<OpenTelemetryCoreLatestVersion>[1.5.1,2.0)</OpenTelemetryCoreLatestVersion>
<OpenTelemetryCoreLatestVersion>[1.6.0,2.0)</OpenTelemetryCoreLatestVersion>
<OpenTelemetryCoreLatestPrereleaseVersion>[1.6.0-rc.1]</OpenTelemetryCoreLatestPrereleaseVersion>
<StackExchangeRedisPkgVer>[2.1.58,3.0)</StackExchangeRedisPkgVer>
<CassandraCSharpDriverPkgVer>[3.16.0,4.0)</CassandraCSharpDriverPkgVer>
Expand Down
4 changes: 0 additions & 4 deletions build/Common.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<Project>

<PropertyGroup Condition="'$(EnableAnalysis)'=='true' and '$(SkipAnalysis)'!='true'">
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

</Project>
21 changes: 10 additions & 11 deletions examples/AspNet/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
using System.Web.Mvc;
using System.Web.Routing;

namespace Examples.AspNet
namespace Examples.AspNet;

public class RouteConfig
{
public class RouteConfig
public static void RegisterRoutes(RouteCollection routes)
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapMvcAttributeRoutes();
routes.MapMvcAttributeRoutes();

routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
}
2 changes: 2 additions & 0 deletions examples/AspNet/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ namespace Examples.AspNet.Controllers;
public class HomeController : Controller
{
// For testing traditional routing. Ex: https://localhost:XXXX/
[HttpGet]
public ActionResult Index()
{
return this.View();
}

[HttpGet]
[Route("about_attr_route/{customerId}")] // For testing attribute routing. Ex: https://localhost:XXXX/about_attr_route
public ActionResult About(int? customerId)
{
Expand Down
32 changes: 24 additions & 8 deletions examples/AspNet/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task<IEnumerable<WeatherForecast>> Get(int customerId)
{
if (customerId < 0)
{
throw new ArgumentException();
throw new ArgumentOutOfRangeException(nameof(customerId), "CustomerId should be 0 or greater.");
}

// Making http calls here to serve as an example of
Expand Down Expand Up @@ -141,31 +141,31 @@ private static async Task RequestGoogleHomPageViaHttpClient()
{
using var request = new HttpClient();

using var response = await request.GetAsync("http://www.google.com").ConfigureAwait(false);
using var response = await request.GetAsync(new Uri("http://www.google.com")).ConfigureAwait(false);

response.EnsureSuccessStatusCode();
}

// Test dependency collection via legacy HttpWebRequest sync.
private static void RequestGoogleHomPageViaHttpWebRequestLegacySync()
{
var request = WebRequest.Create("http://www.google.com/?sync");
var request = WebRequest.Create(new Uri("http://www.google.com/?sync"));

using var response = request.GetResponse();
}

// Test dependency collection via legacy HttpWebRequest async.
private static async Task RequestGoogleHomPageViaHttpWebRequestLegacyAsync()
{
var request = (HttpWebRequest)WebRequest.Create($"http://www.google.com/?async");
var request = (HttpWebRequest)WebRequest.Create(new Uri("http://www.google.com/?async"));

using var response = await request.GetResponseAsync().ConfigureAwait(false);
}

// Test dependency collection via legacy HttpWebRequest IAsyncResult.
private static void RequestGoogleHomPageViaHttpWebRequestLegacyAsyncResult()
{
var request = (HttpWebRequest)WebRequest.Create($"http://www.google.com/?async");
var request = (HttpWebRequest)WebRequest.Create(new Uri("http://www.google.com/?async"));

var asyncResult = request.BeginGetResponse(null, null);

Expand All @@ -181,7 +181,9 @@ private async Task RequestInvalidViaHttpClient()

// 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);
var requestUri = this.GenerateContentRequestUri("~/subroute/10", uri => uri.Replace("http", "https"));

using var response = await request.GetAsync(requestUri).ConfigureAwait(false);

Debug.Fail("Unreachable");
}
Expand All @@ -197,7 +199,8 @@ private async Task RequestValidThatReturnsFailedViaHttpClient()

// 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);
using var response = await request.GetAsync(
this.GenerateContentRequestUri("~/subroute/-1")).ConfigureAwait(false);

Debug.Assert(response.StatusCode == HttpStatusCode.InternalServerError, "response.StatusCode is InternalServerError");
}
Expand All @@ -209,8 +212,21 @@ private async Task RequestValidThatSpawnsSubSpansViaHttpClient()

// 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);
using var response = await request.GetAsync(
this.GenerateContentRequestUri("~/subroute/10")).ConfigureAwait(false);

response.EnsureSuccessStatusCode();
}

private Uri GenerateContentRequestUri(string path, Func<string, string> transform = null)
{
var rawUri = this.Url.Content(path);

if (transform != null)
{
rawUri = transform(rawUri);
}

return new(rawUri);
}
}
76 changes: 14 additions & 62 deletions examples/AspNet/Examples.AspNet.csproj
Original file line number Diff line number Diff line change
@@ -1,46 +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>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9A4E3A68-904B-4835-A3C8-F664B73098DB}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenTelemetry.Exporter.AspNet</RootNamespace>
<AssemblyName>OpenTelemetry.Exporter.AspNet</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort>
</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' ">
<DebugSymbols>true</DebugSymbols>
<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 Down Expand Up @@ -87,16 +60,13 @@
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.HttpListener" Version="1.5.0-rc.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet\OpenTelemetry.Instrumentation.AspNet.csproj">
<Project>{582b70b5-0067-4d9a-abf2-623f502be9a9}</Project>
<Name>OpenTelemetry.Instrumentation.AspNet</Name>
</ProjectReference>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet\OpenTelemetry.Instrumentation.AspNet.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)" />
Expand All @@ -109,22 +79,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>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:56171/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
12 changes: 6 additions & 6 deletions examples/AspNet/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ protected void Application_Start()
.AddAspNetInstrumentation()
.AddHttpClientInstrumentation();

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 All @@ -68,15 +68,15 @@ protected void Application_Start()
var meterBuilder = Sdk.CreateMeterProviderBuilder()
.AddAspNetInstrumentation();

switch (ConfigurationManager.AppSettings["UseMetricsExporter"].ToLowerInvariant())
switch (ConfigurationManager.AppSettings["UseMetricsExporter"].ToUpperInvariant())
{
case "otlp":
case "OTLP":
meterBuilder.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["OtlpEndpoint"]);
});
break;
case "prometheus":
case "PROMETHEUS":
meterBuilder.AddPrometheusHttpListener();
break;
default:
Expand Down
28 changes: 0 additions & 28 deletions examples/AspNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,9 @@
// limitations under the License.
// </copyright>

using System.Reflection;
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("Examples.AspNet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Examples.AspNet")]
[assembly: AssemblyCopyright("Copyright @ 2020")]
[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("9a4e3a68-904b-4835-a3c8-f664b73098db")]

// 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.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
18 changes: 18 additions & 0 deletions examples/AspNet/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:23307"
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

0 comments on commit 305bb93

Please sign in to comment.