CerbiStream.GovernanceAnalyzer
1.0.4
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
<PackageReference Include="CerbiStream.GovernanceAnalyzer" Version="1.0.4" />
<PackageVersion Include="CerbiStream.GovernanceAnalyzer" Version="1.0.4" />
<PackageReference Include="CerbiStream.GovernanceAnalyzer" />
paket add CerbiStream.GovernanceAnalyzer --version 1.0.4
#r "nuget: CerbiStream.GovernanceAnalyzer, 1.0.4"
#addin nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.4
#tool nuget:?package=CerbiStream.GovernanceAnalyzer&version=1.0.4
CerbiStream Governance Analyzer
π‘οΈ 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
- Website: Cerbi-CerbiStream
- NuGet: CerbiStream.GovernanceAnalyzer
- Email: Cerbi
π MIT Licensed Β· π§ Built for the future of observability
Product | Versions 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. |
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 4.13.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.