Use RunTimeMetrics for stress (#3403)

This commit is contained in:
Cijo Thomas 2022-06-27 21:31:06 -07:00 committed by GitHub
parent ee7ffd37dc
commit dae9f7dac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 8 deletions

View File

@ -227,6 +227,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Pr
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "correlation", "docs\logs\correlation\correlation.csproj", "{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "correlation", "docs\logs\correlation\correlation.csproj", "{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Tests.Stress.Logs", "test\OpenTelemetry.Tests.Stress.Logs\OpenTelemetry.Tests.Stress.Logs.csproj", "{4298057B-24E0-47B3-BB76-C17E81AF6B39}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -457,6 +459,10 @@ Global
{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Release|Any CPU.Build.0 = Release|Any CPU {9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5}.Release|Any CPU.Build.0 = Release|Any CPU
{4298057B-24E0-47B3-BB76-C17E81AF6B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4298057B-24E0-47B3-BB76-C17E81AF6B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4298057B-24E0-47B3-BB76-C17E81AF6B39}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4298057B-24E0-47B3-BB76-C17E81AF6B39}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -44,6 +44,7 @@
<NewtonsoftJsonPkgVer>[12.0.2,13.0)</NewtonsoftJsonPkgVer> <NewtonsoftJsonPkgVer>[12.0.2,13.0)</NewtonsoftJsonPkgVer>
<MoqPkgVer>[4.14.5,5.0)</MoqPkgVer> <MoqPkgVer>[4.14.5,5.0)</MoqPkgVer>
<RabbitMQClientPkgVer>[6.1.0,7.0)</RabbitMQClientPkgVer> <RabbitMQClientPkgVer>[6.1.0,7.0)</RabbitMQClientPkgVer>
<RuntimeInstrumentationPkgVer>[1.0.0-beta.1,2.0)</RuntimeInstrumentationPkgVer>
<SwashbuckleAspNetCorePkgVer>[6.2.3]</SwashbuckleAspNetCorePkgVer> <SwashbuckleAspNetCorePkgVer>[6.2.3]</SwashbuckleAspNetCorePkgVer>
<XUnitRunnerVisualStudioPkgVer>[2.4.3,3.0)</XUnitRunnerVisualStudioPkgVer> <XUnitRunnerVisualStudioPkgVer>[2.4.3,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitPkgVer>[2.4.1,3.0)</XUnitPkgVer> <XUnitPkgVer>[2.4.1,3.0)</XUnitPkgVer>

View File

@ -10,6 +10,7 @@
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests.Stress\Skeleton.cs" /> <Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests.Stress\Skeleton.cs" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" /> <ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[6.0.0,)" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="[6.0.0,)" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="$(RuntimeInstrumentationPkgVer)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,6 +6,10 @@
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="$(RuntimeInstrumentationPkgVer)" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\Utils.cs" Link="Includes\Utils.cs" /> <Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\Utils.cs" Link="Includes\Utils.cs" />
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests.Stress\Skeleton.cs" /> <Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests.Stress\Skeleton.cs" />

View File

@ -5,6 +5,10 @@
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="$(RuntimeInstrumentationPkgVer)" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" /> <ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -27,18 +27,11 @@ namespace OpenTelemetry.Tests.Stress;
public partial class Program public partial class Program
{ {
private static readonly Meter StressMeter = new("OpenTelemetry.Tests.Stress");
private static volatile bool bContinue = true; private static volatile bool bContinue = true;
private static volatile string output = "Test results not available yet."; private static volatile string output = "Test results not available yet.";
static Program() static Program()
{ {
var process = Process.GetCurrentProcess();
StressMeter.CreateObservableGauge("Process.NonpagedSystemMemorySize64", () => process.NonpagedSystemMemorySize64);
StressMeter.CreateObservableGauge("Process.PagedSystemMemorySize64", () => process.PagedSystemMemorySize64);
StressMeter.CreateObservableGauge("Process.PagedMemorySize64", () => process.PagedMemorySize64);
StressMeter.CreateObservableGauge("Process.WorkingSet64", () => process.WorkingSet64);
StressMeter.CreateObservableGauge("Process.VirtualMemorySize64", () => process.VirtualMemorySize64);
} }
public static void Stress(int concurrency = 0, int prometheusPort = 0) public static void Stress(int concurrency = 0, int prometheusPort = 0)
@ -83,8 +76,8 @@ public partial class Program
} }
using var meterProvider = prometheusPort != 0 ? Sdk.CreateMeterProviderBuilder() using var meterProvider = prometheusPort != 0 ? Sdk.CreateMeterProviderBuilder()
.AddMeter(StressMeter.Name)
.AddMeter(meter.Name) .AddMeter(meter.Name)
.AddRuntimeMetrics()
.AddPrometheusExporter(options => .AddPrometheusExporter(options =>
{ {
options.StartHttpListener = true; options.StartHttpListener = true;