Aaron.Akka.Streams.BackpressureMonitor 0.2.0

dotnet add package Aaron.Akka.Streams.BackpressureMonitor --version 0.2.0                
NuGet\Install-Package Aaron.Akka.Streams.BackpressureMonitor -Version 0.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aaron.Akka.Streams.BackpressureMonitor" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aaron.Akka.Streams.BackpressureMonitor --version 0.2.0                
#r "nuget: Aaron.Akka.Streams.BackpressureMonitor, 0.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aaron.Akka.Streams.BackpressureMonitor as a Cake Addin
#addin nuget:?package=Aaron.Akka.Streams.BackpressureMonitor&version=0.2.0

// Install Aaron.Akka.Streams.BackpressureMonitor as a Cake Tool
#tool nuget:?package=Aaron.Akka.Streams.BackpressureMonitor&version=0.2.0                

Aaron.Akka.Streams.BackpressureMonitor

This package provides access to some experimental Akka.NET Streams stages that can be used for monitoring occurrences of backpressure inside your Akka.NET applications.

Installation and Use

To access these stages, install the Aaron.Akka.Streams.BackpressureMonitor NuGet package:

install-package Aaron.Akka.Streams.BackpressureMonitor

Next, use the Aaron.Akka.Streams.Dsl namespace and call the BackpressureAlert extension method on either a Source<T> or a Flow<T> stage:

var source = Source.From(Enumerable.Repeat(0, 10))
    .BackpressureAlert(LogLevel.InfoLevel)
    .RunWith(Sink.Ignore<int>(), Sys.Materializer());

You will see the following logs appear in your stream when backpressure is detected between the downstream consumer and the upstream producer above the BackpressureAlert stage:

[INFO][11/2/2021 7:10:45 PM][Thread 0055][Logic (akka://test)] [BackpressureAlert] Backpressure detected. Measuring duration starting now...
[INFO][11/2/2021 7:10:45 PM][Thread 0055][Logic (akka://test)] [BackpressureAlert] Backpressure relieved. Total backpressure wait time: 00:00:00.0777019

Customizing the BackpressureAlert Logs

If you need to raise backpessure alerts in multiple locations, you can change the name of each BackpressureAlert stage instance via the WithAttributes extension method in Akka.Streams:

var source = Source.From(Enumerable.Repeat(0, 3))
    .BackpressureAlert(LogLevel.InfoLevel).WithAttributes(Attributes.CreateName("MyName"))
    .SelectAsync(1, async i =>
    {
        await Task.Delay(100);
        return i;
    })
    .RunWith(Sink.Ignore<int>(), Sys.Materializer());

The Attributes.CreateName("MyName") call will cause the logs to carry additional context about which alert is firing:

[INFO][11/2/2021 7:10:45 PM][Thread 0045][Logic (akka://test)] [MyName-BackpressureAlert] Backpressure detected. Measuring duration starting now...
[INFO][11/2/2021 7:10:45 PM][Thread 0046][Logic (akka://test)] [MyName-BackpressureAlert] Backpressure relieved. Total backpressure wait time: 00:00:00.0470042

Contributing

See CONTRIBUTING.md for information about building the project from source and contributing changes.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 23 2/19/2025
0.1.3 1,946 10/26/2022
0.1.2 744 2/2/2022
0.1.1 412 11/2/2021
0.1.0 322 11/2/2021

Upgraded to Akka.NET v1.5.38
Updated all test dependencies to latest versions:
- Microsoft.NET.Test.Sdk to 17.13.0
- xunit to 2.9.3
- xunit.runner.visualstudio to 2.5.7
- coverlet.collector to 6.0.4
Fixed breaking changes in Akka.NET 1.5.x:
- Updated `OnDownstreamFinish` to handle exceptions
- Updated logging API calls to match new format