Skip to content

Commit

Permalink
Added HttpRequestTracing example
Browse files Browse the repository at this point in the history
  • Loading branch information
AntyaDev committed Apr 6, 2024
1 parent 9f7cc35 commit 73d4868
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="NBomber" Version="5.6.0-beta.13" />
<PackageReference Include="NBomber.Data" Version="5.0.0" />
<PackageReference Include="NBomber.Http" Version="5.1.0-beta.3" />
<PackageReference Include="NBomber.Http" Version="5.1.0-beta.4" />
<PackageReference Include="NBomber.WebSockets" Version="0.1.0" />
<PackageReference Include="NBomber.Sinks.InfluxDB" Version="5.0.2" />
<PackageReference Include="MQTTnet" Version="3.1.2" />
Expand Down
33 changes: 33 additions & 0 deletions examples/Demo/HTTP/HttpRequestTracing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using NBomber.CSharp;
using NBomber.Http;
using NBomber.Http.CSharp;

namespace Demo.HTTP;

public class HttpRequestTracing
{
public void Run()
{
using var httpClient = new HttpClient();

var scenario = Scenario.Create("http_scenario", async context =>
{
var request = Http.CreateRequest("GET", "https://catfact.ninja/fact");

var clientArgs = HttpClientArgs.Create(logger: context.Logger);

var response = await Http.Send(httpClient, clientArgs, request);

return response;
})
.WithoutWarmUp()
.WithLoadSimulations(Simulation.Inject(rate: 1, interval: TimeSpan.FromSeconds(1), during: TimeSpan.FromSeconds(30)));

NBomberRunner
.RegisterScenarios(scenario)
.WithWorkerPlugins(
new HttpMetricsPlugin(new [] { HttpVersion.Version1 })
)
.Run();
}
}
1 change: 1 addition & 0 deletions examples/Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
// new HttpClientArgsExample().Run();
// new WebAppSimulatorExample().RunHttpUserExample();
// new ExampleSimpleBookstore().Run();
// new HttpRequestTracing().Run();

// ----------------
// ----- WebSockets -----
Expand Down

0 comments on commit 73d4868

Please sign in to comment.