Skip to content

Commit

Permalink
Stress test improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Feb 22, 2024
1 parent 09dd46f commit 9cfd530
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
<PackageReference Include="System.Text.Json" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 23 additions & 12 deletions test/OpenTelemetry.Tests.Stress.Logs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Runtime.CompilerServices;
using CommandLine;
using Microsoft.Extensions.Logging;

namespace OpenTelemetry.Tests.Stress;
Expand All @@ -11,19 +12,10 @@ public partial class Program
private static ILogger logger;
private static Payload payload = new Payload();

public static void Main()
public static void Main(string[] args)
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.AddProcessor(new DummyProcessor());
});
});

logger = loggerFactory.CreateLogger<Program>();

Stress(prometheusPort: 9464);
Parser.Default.ParseArguments<StressTestOptions>(args)
.WithParsed(LaunchStressTest);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -36,4 +28,23 @@ protected static void Run()
exception: null,
formatter: (state, ex) => string.Empty);
}

protected static void WriteRunInformationToConsole(StressTestOptions options)
{
}

private static void LaunchStressTest(StressTestOptions options)
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.AddProcessor(new DummyProcessor());
});
});

logger = loggerFactory.CreateLogger<Program>();

RunStressTest(options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
<PackageReference Include="System.Text.Json" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus.HttpListener\OpenTelemetry.Exporter.Prometheus.HttpListener.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
136 changes: 103 additions & 33 deletions test/OpenTelemetry.Tests.Stress.Metrics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,134 @@

using System.Diagnostics.Metrics;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
using CommandLine;
using OpenTelemetry.Metrics;

namespace OpenTelemetry.Tests.Stress;

public partial class Program
{
private const int ArraySize = 10;

// Note: Uncomment the below line if you want to run Histogram stress test
private const int MaxHistogramMeasurement = 1000;

private static readonly Meter TestMeter = new(Utils.GetCurrentMethodName());
private static readonly Histogram<long> TestHistogram = TestMeter.CreateHistogram<long>("TestHistogram");
private static readonly Counter<long> TestCounter = TestMeter.CreateCounter<long>("TestCounter");
private static readonly string[] DimensionValues = new string[ArraySize];
private static readonly ThreadLocal<Random> ThreadLocalRandom = new(() => new Random());
private static TestType testType;

// Note: Uncomment the below line if you want to run Histogram stress test
private static readonly Histogram<long> TestHistogram = TestMeter.CreateHistogram<long>("TestHistogram");
protected enum TestType
{
/// <summary>Histogram.</summary>
Histogram,

/// <summary>Counter.</summary>
Counter,
}

public static void Main(string[] args)
{
Parser.Default.ParseArguments<StressTestOptions>(args)
.WithParsed(LaunchStressTest);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected static void Run()
{
var random = ThreadLocalRandom.Value;
if (testType == TestType.Histogram)
{
TestHistogram.Record(
random.Next(MaxHistogramMeasurement),
new("DimName1", DimensionValues[random.Next(0, ArraySize)]),
new("DimName2", DimensionValues[random.Next(0, ArraySize)]),
new("DimName3", DimensionValues[random.Next(0, ArraySize)]));
}
else if (testType == TestType.Counter)
{
TestCounter.Add(
100,
new("DimName1", DimensionValues[random.Next(0, ArraySize)]),
new("DimName2", DimensionValues[random.Next(0, ArraySize)]),
new("DimName3", DimensionValues[random.Next(0, ArraySize)]));
}
}

protected static void WriteRunInformationToConsole(StressTestOptions options)
{
if (options.PrometheusTestMetricsPort != 0)
{
Console.Write($", testPrometheusEndpoint = http://localhost:{options.PrometheusTestMetricsPort}/metrics/");
}
}

public static void Main()
private static void LaunchStressTest(StressTestOptions options)
{
for (int i = 0; i < ArraySize; i++)
{
DimensionValues[i] = $"DimValue{i}";
}

using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(TestMeter.Name)
var builder = Sdk.CreateMeterProviderBuilder()
.AddMeter(TestMeter.Name);

// .SetExemplarFilter(new AlwaysOnExemplarFilter())
.AddPrometheusHttpListener(
options => options.UriPrefixes = new string[] { $"http://localhost:9185/" })
.Build();
if (options.PrometheusTestMetricsPort != 0)
{
builder.AddPrometheusHttpListener(o => o.UriPrefixes = new string[] { $"http://localhost:{options.PrometheusTestMetricsPort}/" });
}

if (options.EnableExemplars)
{
builder.SetExemplarFilter(new AlwaysOnExemplarFilter());

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (ubuntu-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net8.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net462)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net6.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'AlwaysOnExemplarFilter' is inaccessible due to its protection level

Check failure on line 86 in test/OpenTelemetry.Tests.Stress.Metrics/Program.cs

View workflow job for this annotation

GitHub Actions / build-test-solution-stable / build-test (windows-latest, net7.0)

'MeterProviderBuilder' does not contain a definition for 'SetExemplarFilter' and no accessible extension method 'SetExemplarFilter' accepting a first argument of type 'MeterProviderBuilder' could be found (are you missing a using directive or an assembly reference?)
}

if (options.AddViewToFilterTags)
{
builder
.AddView("TestCounter", new MetricStreamConfiguration { TagKeys = new string[] { "DimName1" } })
.AddView("TestHistogram", new MetricStreamConfiguration { TagKeys = new string[] { "DimName1" } });
}

if (options.AddOtlpExporter)
{
builder.AddOtlpExporter((exporterOptions, readerOptions) =>
{
readerOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.OtlpExporterExportIntervalMilliseconds;
});
}

using var meterProvider = builder.Build();

Stress(prometheusPort: 9464);
testType = options.TestType;

RunStressTest(options);
}

// Note: Uncomment the below lines if you want to run Counter stress test
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// protected static void Run()
// {
// var random = ThreadLocalRandom.Value;
// TestCounter.Add(
// 100,
// new("DimName1", DimensionValues[random.Next(0, ArraySize)]),
// new("DimName2", DimensionValues[random.Next(0, ArraySize)]),
// new("DimName3", DimensionValues[random.Next(0, ArraySize)]));
// }

// Note: Uncomment the below lines if you want to run Histogram stress test
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected static void Run()
protected partial class StressTestOptions
{
[JsonConverter(typeof(JsonStringEnumConverter))]
[Option('t', "type", HelpText = "The metrics stress test type to run. Valid values: [Histogram, Counter]. Default value: Histogram.", Required = false)]
public TestType TestType { get; set; } = TestType.Histogram;

[Option('m', "metrics_port", HelpText = "The prometheus http listener port where prometheus will be exposed for retrieving test metrics while the stress test is running. Set to '0' to disable. Default value: 9185.", Required = false)]
public int PrometheusTestMetricsPort { get; set; } = 9185;

[Option('v', "view", HelpText = "Whether or not a view should be configured to filter tags for the stress test. Default value: False.", Required = false)]
public bool AddViewToFilterTags { get; set; }

[Option('o', "otlp", HelpText = "Whether or not an OTLP exporter should be added for the stress test. Default value: False.", Required = false)]
public bool AddOtlpExporter { get; set; }

[Option('i', "interval", HelpText = "The OTLP exporter export interval in milliseconds. Default value: 5000.", Required = false)]
public int OtlpExporterExportIntervalMilliseconds { get; set; } = 5000;

[Option('e', "exemplars", HelpText = "Whether or not to enable exemplars for the stress test. Default value: False.", Required = false)]
public bool EnableExemplars { get; set; }
}

private sealed class NoOptions
{
var random = ThreadLocalRandom.Value;
TestHistogram.Record(
random.Next(MaxHistogramMeasurement),
new("DimName1", DimensionValues[random.Next(0, ArraySize)]),
new("DimName2", DimensionValues[random.Next(0, ArraySize)]),
new("DimName3", DimensionValues[random.Next(0, ArraySize)]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus.HttpListener\OpenTelemetry.Exporter.Prometheus.HttpListener.csproj" />
<PackageReference Include="System.Text.Json" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 17 additions & 6 deletions test/OpenTelemetry.Tests.Stress.Traces/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Runtime.CompilerServices;
using CommandLine;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

Expand All @@ -12,13 +13,10 @@ public partial class Program
{
private static readonly ActivitySource ActivitySource = new ActivitySource("OpenTelemetry.Tests.Stress");

public static void Main()
public static void Main(string[] args)
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(ActivitySource.Name)
.Build();

Stress(prometheusPort: 9464);
Parser.Default.ParseArguments<StressTestOptions>(args)
.WithParsed(LaunchStressTest);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -29,4 +27,17 @@ protected static void Run()
activity?.SetTag("foo", "value");
}
}

protected static void WriteRunInformationToConsole(StressTestOptions options)
{
}

private static void LaunchStressTest(StressTestOptions options)
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(ActivitySource.Name)
.Build();

RunStressTest(options);
}
}
10 changes: 9 additions & 1 deletion test/OpenTelemetry.Tests.Stress/Meat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ public partial class Program
{
public static void Main()
{
Stress(concurrency: 1, prometheusPort: 9464);
RunStressTest(new()
{
Concurrency = 1,
PrometheusInternalMetricsPort = 9464,
});
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected static void Run()
{
}

protected static void WriteRunInformationToConsole(StressTestOptions options)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
<PackageReference Include="System.Text.Json" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 9cfd530

Please sign in to comment.