Egil.Orleans.Storage 1.9.3

dotnet add package Egil.Orleans.Storage --version 1.9.3                
NuGet\Install-Package Egil.Orleans.Storage -Version 1.9.3                
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="Egil.Orleans.Storage" Version="1.9.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Egil.Orleans.Storage --version 1.9.3                
#r "nuget: Egil.Orleans.Storage, 1.9.3"                
#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 Egil.Orleans.Storage as a Cake Addin
#addin nuget:?package=Egil.Orleans.Storage&version=1.9.3

// Install Egil.Orleans.Storage as a Cake Tool
#tool nuget:?package=Egil.Orleans.Storage&version=1.9.3                

Extensions to Orleans Storage

This library provides OpenTelemetry integration for Microsoft Orleans grain storage providers. It enables detailed telemetry collection for grain storage operations with minimal configuration, helping you monitor and analyze storage performance, errors, and usage patterns in your Orleans applications.

Installation

Install the package from NuGet: https://www.nuget.org/packages/Egil.Orleans.Storage

Usage

Adding Grain Storage Telemetry

Add telemetry enrichment for all registered grain storage providers:

siloBuilder.AddGrainStorageTelemetry();

This extension method wraps each registered grain storage provider with a telemetry enricher that creates spans for storage operations and collects metrics for read, write and clear operations.

Handling GET Operations for Missing Entities

Some storage providers (notably Azure Storage) mark read operations for non-existent entities as errors, which isn't always appropriate in Orleans. This processor ensures such operations are marked as successful in telemetry:

siloBuilder.Services.AddGrainStorageGetAlwaysOkTelemetryProcessor();

Configuring Sampling for Storage Telemetry

To prevent excessive telemetry collection in high-volume applications, configure sampling for storage operations:

siloBuilder.AddGrainStorageTelemetrySamplingProcessor(
    samplingProbability: 0.1,
    storageName: "MyStorage");

Parameters:

  • samplingProbability: Value between 0.0 and 1.0 determining what percentage of operations to trace (0.1 = 10%)
  • storageName: Optional filter to apply sampling only to a specific storage provider
  • stateName: Optional filter to apply sampling only to a specific grain state

OpenTelemetry Configuration

To properly collect and export Orleans grain storage telemetry, configure your OpenTelemetry setup as shown (this extends the default configuration in Aspire enabled projects):

public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
    builder.Logging.AddOpenTelemetry(logging =>
    {
        logging.IncludeFormattedMessage = true;
        logging.IncludeScopes = true;
    });

    builder.Services.AddOpenTelemetry()
        .WithMetrics(metrics =>
        {
            metrics.AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation()
                .AddRuntimeInstrumentation()
                .AddMeter("Microsoft.Orleans")
                .AddMeter("Microsoft.Orleans.GrainStorage"); // <-- Add this line to enable storage metrics
        })
        .WithTracing(tracing =>
        {
            tracing.AddSource("Microsoft.Orleans.Application");
            tracing.AddSource("Microsoft.Orleans.GrainStorage"); // <-- Add this line to enable storage tracing

            tracing.AddSource(builder.Environment.ApplicationName)
                .AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation();
        });

    builder.AddOpenTelemetryExporters();

    return builder;
}

private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
    if (!string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]))
    {
        builder.Services
            .AddOpenTelemetry()
            .UseOtlpExporter()
            // Recommended to allow parent sampler to influence child spans.
            .WithTracing(tracing => tracing.SetSampler(
                new ParentBasedSampler(
                    new AlwaysOnSampler())));
    }

    if (!string.IsNullOrWhiteSpace(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
    {
        builder.Services
            .AddOpenTelemetry()
            .UseAzureMonitor()
            // Recommended to allow parent sampler to influence child spans.
            .WithTracing(tracing => tracing.SetSampler(
                new ParentBasedSampler(
                new AlwaysOnSampler())));
    }

    return builder;
}

The key components in this configuration:

  • Adding the Microsoft.Orleans.GrainStorage meter to collect storage-specific metrics
  • Adding the Microsoft.Orleans.GrainStorage activity source to capture detailed traces
  • Configuring exporters like OTLP (OpenTelemetry Protocol) or Azure Monitor

Collected Telemetry

Metrics

  • orleans-storage-read: Count of read operations with storage name and state name dimensions
  • orleans-storage-write: Count of write operations with storage name and state name dimensions
  • orleans-storage-clear: Count of clear operations with storage name and state name dimensions

Traces

Storage operations generate spans with the following attributes:

  • Storage name
  • State name
  • Operation type (Read/Write/Clear)
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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
1.9.3 66 3/20/2025
1.8.3 62 3/20/2025
1.5.15-alpha-g0068e22c34 58 3/19/2025
1.5.14-alpha-g07becff3bc 53 3/19/2025
1.5.13-alpha-gd675b7ec70 58 3/19/2025
1.5.12-alpha-gc2c32e4281 57 3/19/2025
1.5.11-alpha-gabddf5bf54 57 3/19/2025
1.5.5 59 3/19/2025
1.4.2-g1104c8c7ac 61 3/19/2025
1.3.0 63 3/18/2025
1.2.0 65 3/18/2025
1.1.0 68 3/17/2025
1.0.3-alpha.0.3 61 3/17/2025
1.0.3-alpha.0.2 62 3/17/2025