CerbiStream.GovernanceAnalyzer 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package CerbiStream.GovernanceAnalyzer --version 1.0.4
                    
NuGet\Install-Package CerbiStream.GovernanceAnalyzer -Version 1.0.4
                    
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="CerbiStream.GovernanceAnalyzer" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CerbiStream.GovernanceAnalyzer" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="CerbiStream.GovernanceAnalyzer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CerbiStream.GovernanceAnalyzer --version 1.0.4
                    
#r "nuget: CerbiStream.GovernanceAnalyzer, 1.0.4"
                    
#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.
#addin nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.4
                    
Install CerbiStream.GovernanceAnalyzer as a Cake Addin
#tool nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.4
                    
Install CerbiStream.GovernanceAnalyzer as a Cake Tool

CerbiStream Governance Analyzer

NuGet NuGet Downloads License: MIT .NET


πŸ›‘οΈ CerbiStream Governance Analyzer

CerbiStream-GovernanceAnalyzer is a Roslyn-based static analysis tool that enforces structured logging policies at compile time using CerbiStream. It validates log structure, metadata fields, and allowed log levels against profiles defined in a cerbi_governance.json file.


βœ… Why Use It?

  • πŸš€ Catch missing fields before runtime
  • πŸ” Enforce log structure + levels across microservices
  • πŸ“Š Govern logs with per-profile validation
  • ⚑ Fast, lightweight, and easy to configure
  • ♻️ Supports dynamic JSON reloading at runtime

πŸ“¦ Installation

dotnet add package CerbiStream.GovernanceAnalyzer

πŸ“‹ How It Works

1️⃣ Define Governance JSON

Create a cerbi_governance.json file like this:

{
  "LoggingProfiles": {
    "API": {
      "RequiredFields": ["Timestamp", "LogLevel", "Message", "ApplicationId"],
      "OptionalFields": ["UserId", "TransactionId"],
      "AllowedLevels": ["Information", "Warning", "Error"],
      "EnforcementLevel": "Warning"
    },
    "SecurityLog": {
      "RequiredFields": ["UserId", "IPAddress"],
      "OptionalFields": ["DeviceType"],
      "AllowedLevels": ["Error", "Critical"],
      "EnforcementLevel": "Error"
    }
  }
}

2️⃣ Enable Analyzer During Build

If a log does not match required fields or uses a disallowed log level, a warning or error is raised at build time.

3️⃣ Enforcement Modes

Set EnforcementLevel in JSON:

  • Warning β†’ Dev notified
  • Error β†’ Build fails

🧰 Sample Usage

πŸ”§ Enable Cerbi Governance

builder.AddCerbiStream(options =>
{
    options.EnableGovernance();
});

βœ… Valid Log

logger.LogInformation("User login | UserId: {UserId}, Timestamp: {Timestamp}", userId, DateTime.UtcNow);

❌ Invalid Log

logger.LogInformation("User login"); // Missing required fields

Result: Diagnostic shows missing UserId or Timestamp.


βš™οΈ Configurable Fields

Key Type Description
RequiredFields string[] Must be present in every log for this profile
OptionalFields string[] Should be present if possible
AllowedLevels string[] Whitelisted log levels (e.g., Information, Error)
EnforcementLevel string Error = fail build, Warning = show compiler warning

πŸ”„ Dynamic Reloading

βœ”οΈ Cerbi auto-reloads JSON rules at runtime.
βœ”οΈ Changes are applied without restart.
βœ”οΈ Great for DevOps or governance teams managing live updates.


πŸ”— Powered by CerbiStream

The GovernanceAnalyzer is designed to work hand-in-hand with CerbiStream, a high-performance, encrypted logging library.

CerbiStream provides:

  • βœ… Structured logging with consistent metadata (UserType, Feature, RetryAttempt, etc.)
  • βœ… Built-in encryption (Base64, AES)
  • βœ… Developer presets (BenchmarkMode, MinimalMode)
  • βœ… Cloud-agnostic routing (Kafka, RabbitMQ, Azure, AWS, GCP)

By combining CerbiStream + GovernanceAnalyzer:

  • πŸ” You enforce what gets logged
  • πŸ“ You control how it’s structured
  • πŸš€ You get fast logs, validated before runtime

πŸ“¦ Add both packages for full governance + logging:

dotnet add package CerbiStream
dotnet add package CerbiStream.GovernanceAnalyzer

🧩 GovernanceAnalyzer validates logs at build time
🚚 CerbiStream routes and enriches logs at runtime

Together they create a full lifecycle solution for enterprise-grade logging.


🌍 Roadmap

  • 🧠 Analyzer support for missing context suggestions
  • πŸ“Š Governance dashboard (via CerbiShield)
  • βš™οΈ Build fail metrics and GitHub CI integrations

πŸ§ͺ Sample LogGovernanceAnalyzer.cs

[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class LogGovernanceAnalyzer : DiagnosticAnalyzer
{
    public override void Initialize(AnalysisContext context)
    {
        context.RegisterSyntaxNodeAction(AnalyzeLogStatements, SyntaxKind.InvocationExpression);
    }

    private void AnalyzeLogStatements(SyntaxNodeAnalysisContext context)
    {
        // ... Check for required fields and allowed levels
    }
}

πŸ“¬ Contact & Community

πŸ”– MIT Licensed Β· 🧠 Built for the future of observability

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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.0.5 109 3/28/2025
1.0.4 447 3/26/2025
1.0.3 139 3/23/2025
1.0.2 135 3/20/2025
1.0.1 191 3/19/2025
1.0.0 134 3/19/2025