Skip to content

Commit

Permalink
Fixes for ASP.NET (Framework) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Dec 3, 2024
1 parent 5bda20a commit aea0ada
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 275 deletions.
17 changes: 11 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageVersion Include="Elastic.CommonSchema.BenchmarkDotNetExporter" Version="1.5.0" />
<PackageVersion Include="Elasticsearch.Net" Version="7.17.5" />
<PackageVersion Include="Elasticsearch.Net.VirtualizedCluster" Version="7.6.1" />
<PackageVersion Include="EntityFramework" Version="6.3.0" PrivateAssets="All" />
<PackageVersion Include="EntityFramework" Version="6.5.1" PrivateAssets="All" />
<PackageVersion Include="Fake.Core.Environment" Version="6.0.0" />
<PackageVersion Include="Fake.Core.SemVer" Version="6.0.0" />
<PackageVersion Include="Fake.DotNet.MsBuild" Version="6.0.0" />
Expand All @@ -38,6 +38,9 @@
<PackageVersion Include="Grpc.Tools" Version="2.62.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageVersion Include="JetBrains.Profiler.Api" Version="1.4.0" />
<PackageVersion Include="JunitXml.TestLogger" Version="4.1.0" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Owin" Version="4.2.2" />
<PackageVersion Include="Microsoft.Owin.Security.Cookies" Version="4.2.2" />
<PackageVersion Include="Microsoft.Web.Infrastructure" Version="2.0.0" />
<PackageVersion Include="MongoDB.Driver" Version="2.28.0" />
<PackageVersion Include="MongoDB.Driver.Core" Version="2.28.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
Expand All @@ -63,6 +66,7 @@
<PackageVersion Include="SpecFlow.xUnit" Version="3.5.5" />
<PackageVersion Include="StackExchange.Redis" Version="2.7.20" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.Memory" Version="4.6.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Testcontainers.Elasticsearch" Version="4.0.0" />
<PackageVersion Include="Testcontainers.Kafka" Version="4.0.0" />
Expand All @@ -73,18 +77,19 @@
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.0.0" />
<PackageVersion Include="Testcontainers.RabbitMq" Version="4.0.0" />
<PackageVersion Include="Testcontainers.Redis" Version="4.0.0" />
<PackageVersion Include="WebGrease" Version="1.6.0" />
<PackageVersion Include="YamlDotNet" Version="11.2.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>
<!-- Microsoft/System packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.AspNet.Identity.EntityFramework" Version="2.2.3" />
<PackageVersion Include="Microsoft.AspNet.Identity.EntityFramework" Version="2.2.4" />
<PackageVersion Include="Microsoft.AspNet.Identity.Owin" Version="2.2.4" />
<PackageVersion Include="Microsoft.AspNet.Mvc" Version="5.2.4" />
<PackageVersion Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.7" />
<PackageVersion Include="Microsoft.AspNet.Mvc" Version="5.3.0" />
<PackageVersion Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.8" />
<PackageVersion Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
<PackageVersion Include="Microsoft.AspNet.WebApi" Version="5.2.4" />
<PackageVersion Include="Microsoft.AspNet.WebApi" Version="5.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.1.34" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
Expand Down Expand Up @@ -119,7 +124,7 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Sdk.Functions" Version="4.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.Owin.Host.SystemWeb" Version="4.1.1" />
<PackageVersion Include="Microsoft.Owin.Host.SystemWeb" Version="4.2.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Web.Administration" Version="11.1.0" />
<PackageVersion Include="MicrosoftAspNetCore.Http" Version="2.1.22" />
Expand Down
11 changes: 5 additions & 6 deletions src/Elastic.Apm/Report/Serialization/MetricSetConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public override void Write(Utf8JsonWriter writer, MetricSet value, JsonSerialize
writer.WriteStartObject();
if (value.Transaction != null)
{

writer.WritePropertyName("transaction");

writer.WriteStartObject();
Expand All @@ -35,21 +34,22 @@ public override void Write(Utf8JsonWriter writer, MetricSet value, JsonSerialize

if (value.Span != null)
{

writer.WritePropertyName("span");

writer.WriteStartObject();

writer.WritePropertyName("type");
writer.WriteStringValue(value.Span.Type);

writer.WritePropertyName("subtype");
writer.WriteStringValue(value.Span.SubType);
if (value.Span.SubType is not null)
{
writer.WritePropertyName("subtype");
writer.WriteStringValue(value.Span.SubType);
}

writer.WriteEndObject();
}


writer.WritePropertyName("samples");
writer.WriteStartObject();

Expand Down Expand Up @@ -128,6 +128,5 @@ public override MetricSet Read(ref Utf8JsonReader reader, Type typeToConvert, Js

return new MetricSet(timestamp, samples);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ private void RestoreContextIfNeeded(HttpContextBase context)
if (Agent.Instance == null)
{
_logger.Trace()?
.Log("Agent.Instance is null during {RequestNotification}. url: {{UrlPath}}",
.Log("Agent.Instance is null during {RequestNotification}. url: {UrlPath}",
$"{nameof(OnExecuteRequestStep)}:{EventName()}", urlPath);
return;
}
if (Agent.Instance.Tracer == null)
{
_logger.Trace()?
.Log("Agent.Instance.Tracer is null during {RequestNotification}. url: {{UrlPath}}",
.Log("Agent.Instance.Tracer is null during {RequestNotification}. url: {UrlPath}",
$"{nameof(OnExecuteRequestStep)}:{EventName()}", urlPath);
return;
}
Expand All @@ -235,10 +235,10 @@ private void RestoreContextIfNeeded(HttpContextBase context)
var spanInApplicationInstance = context.Items[HttpContextCurrentExecutionSegmentsContainer.CurrentSpanKey] is not null;

_logger.Trace()?
.Log($"{nameof(ITracer.CurrentTransaction)} is null during {{RequestNotification}}. url: {{UrlPath}}"
.Log("{nameof(ITracer.CurrentTransaction)} is null during {RequestNotification}. url: {UrlPath}"
+ "(HttpContext.Current Span: {HttpContextCurrentHasSpan}, Transaction: {HttpContextCurrenHasTransaction})"
+ "(ApplicationContext Span: {ApplicationContextHasSpan}, Transaction: {ApplicationContextHasTransaction})",
$"{nameof(OnExecuteRequestStep)}:{EventName()}", urlPath, spanInCurrent, transactionInCurrent, spanInApplicationInstance, transactionInApplicationInstance
nameof(ITracer.CurrentTransaction), $"{nameof(OnExecuteRequestStep)}:{EventName()}", urlPath, spanInCurrent, transactionInCurrent, spanInApplicationInstance, transactionInApplicationInstance
);

if (HttpContext.Current == null)
Expand Down
4 changes: 2 additions & 2 deletions test/iis/AspNetFullFrameworkSampleApp/Areas/MyArea/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
Expand All @@ -36,7 +36,7 @@
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<MSBuildWarningsAsMessages>MSB4011</MSBuildWarningsAsMessages>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<!-- prevents NU1503 -->
Expand All @@ -40,8 +41,8 @@
<OutputType>Library</OutputType>
<RootNamespace>AspNetFullFrameworkSampleApp</RootNamespace>
<AssemblyName>AspNetFullFrameworkSampleApp</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFramework>net462</TargetFramework>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<TargetFramework>net481</TargetFramework>
<RuntimeIdentifier>win</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildFullFrameworkAsp)' == 'true'">
Expand Down Expand Up @@ -92,11 +93,16 @@
<PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" />
<PackageReference Include="Microsoft.AspNet.WebApi" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" />
<PackageReference Include="Microsoft.Owin" />
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" />
<PackageReference Include="Microsoft.Owin.Security.Cookies" />
<PackageReference Include="Microsoft.Web.Infrastructure" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NLog" />
<PackageReference Include="SQLite.CodeFirst" />
<PackageReference Include="System.Data.SQLite" />
<PackageReference Include="System.Memory" />
<PackageReference Include="WebGrease" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
Expand Down
4 changes: 2 additions & 2 deletions test/iis/AspNetFullFrameworkSampleApp/Views/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Diagnostics" />
Expand Down Expand Up @@ -39,7 +39,7 @@
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
Expand Down
Loading

0 comments on commit aea0ada

Please sign in to comment.