CerbiStream 1.0.9

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

CerbiStream Logging Library

NuGet NuGet Downloads License: MIT .NET

CerbiStream is a next-generation logging solution built for structured logs, governance enforcement, and multi-destination routing. It ensures secure, consistent, and high-performance logging for cloud, on-prem, and hybrid environments.


πŸš€ What's New?

  • Readme Update only

Updates included from previous version:

  • Telemetry Context Enrichment – Automatically include metadata like ServiceName, OriginApp, UserType, Feature, IsRetry, and RetryAttempt.
  • Static Enrichment – All telemetry context fields are set once and injected into logs automatically.
  • Retry Metadata – Integrated with Polly and middleware to track retries at the log level.
  • Telemetry Support – Seamless integration with AWS CloudWatch, GCP Cloud Trace, Azure Application Insights, and Datadog.
  • Configurable Telemetry Providers – Easily plug in multiple providers.
  • Optimized Telemetry – Exclude noisy events (e.g., DebugLog, HealthCheck) and enable sampling for cost control.

🧰 Getting Started

CerbiStream works out-of-the-box. Install, configure, and start logging:

  1. Install the NuGet package
  2. Set your queue and enrichment metadata
  3. Start logging with ILogger<T>

β†’ For governance enforcement, install the GovernanceAnalyzer.

🧠 High-Level Architecture

CerbiStream is designed to separate concerns between:

  • βœ… Logging (CerbiStream)
  • βœ… Governance (GovernanceAnalyzer)
  • βœ… Telemetry Routing (via optional config or CerbIQ (coming soon))

πŸ“¦ Installation

Install CerbiStream from NuGet:

dotnet add package CerbiStream

If you want Governance Enforcement, also install:

GovernanceAnalyzer NuGet

dotnet add package CerbiStream.GovernanceAnalyzer

⚑ Quick Start (Minimal Setup) With CerbiStream, you can integrate logging in seconds.

using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using CerbiStream.Logging.Extensions;

```csharp
class Program
{
    static void Main()
    {
        var serviceProvider = new ServiceCollection()
        .AddLogging(builder =>
    {
        builder.AddConsole();
        builder.AddCerbiStream(options =>
        {
            options.SetQueue("RabbitMQ", "localhost", "logs-queue");
            options.EnableDevMode();
            options.EnableGovernance();

            // Set once, reused for all logs
            TelemetryContext.ServiceName = "CheckoutService";
            TelemetryContext.OriginApp = "MyFrontendApp";
            TelemetryContext.UserType = "InternalUser"; // System | ApiConsumer | Guest
        });
    })
    .BuildServiceProvider();

var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
logger.LogInformation("App started");
    }
}

πŸ› οΈ Advanced Configuration

If you need more control, you can configure CerbiStream dynamically.

var config = new CerbiStreamOptions();
config.SetQueue("Kafka", "kafka://broker-url", "app-logs");
config.DisableDevMode();
config.EnableGovernance();
config.IncludeAdvancedMetadata();

var logger = new CerbiStreamLogger(config);

🌐 Supported Logging Destinations

Queue Type Example Usage
RabbitMQ QueueType = "RabbitMQ"
Kafka QueueType = "Kafka"
Azure Queue Storage QueueType = "AzureQueue"
Azure Service Bus QueueType = "AzureServiceBus"
AWS SQS QueueType = "AWS_SQS"
AWS Kinesis QueueType = "AWS_Kinesis"
Google Pub/Sub QueueType = "GooglePubSub"

πŸ” Automatic Metadata (No Setup Required)

Metadata Field Auto-Detected? Example Value
CloudProvider βœ… Yes AWS, Azure, GCP, On-Prem
Region βœ… Yes us-east-1, eu-west-2
Environment βœ… Yes Development, Production
ApplicationVersion βœ… Yes v1.2.3
RequestId βœ… Yes (Generated) abc123
TransactionType ❌ Developer Sets REST, gRPC, Kafka
TransactionStatus ❌ Developer Sets Success, Failed

βœ… Telemetry Context Fields (Auto-Enriched)

  • Field Description
  • ServiceName - Logical name of the service
  • OriginApp - Source app triggering the log
  • UserType - System, ApiConsumer, etc.
  • Feature - Business context like Checkout
  • IsRetry - true if retrying the operation
  • RetryAttempt - Number of retry attempts

🧩 Feature & Business Area Enum

Use a shared enum for consistency:

Always show details

Copy
public enum FeatureArea
{
    Checkout,
    Login,
    Search,
    DataExport,
    Onboarding
}

Set it before logging:

TelemetryContext.Feature = FeatureArea.Checkout.ToString();
logger.LogInformation("Item added to cart");

πŸ” Retry Metadata (e.g., Polly Integration)

Policy
  .Handle<Exception>()
  .WaitAndRetry(3, _ => TimeSpan.FromSeconds(1), (ex, _, attempt, _) =>
  {
      TelemetryContext.IsRetry = true;
      TelemetryContext.RetryAttempt = attempt;
  });

πŸ” Governance & Structured Logging

Governance allows organizations to enforce structured logging signatures by:

  • βœ… Defining required fields (e.g., every log must include UserId, RequestId, etc.).
  • βœ… Allowing optional fields that developers can extend dynamically.
  • βœ… Using a governance configuration file (cerbi_governance.json) for dynamic updates. Example Governance JSON:
{
  "LoggingProfiles": {
    "TransactionLog": {
      "RequiredFields": ["TransactionId", "UserId", "Amount"],
      "OptionalFields": ["DiscountCode"]
    },
    "SecurityLog": {
      "RequiredFields": ["UserId", "IPAddress"],
      "OptionalFields": ["DeviceType"]
    }
  }
}

If GovernanceEnabled = true, logs must match the configured structure.

βœ… Governance Analyzer (Build-Time Validation)

CerbiStream GovernanceAnalyzer uses Roslyn to validate log compliance at build time. This ensures structured logs without runtime overhead.

πŸ›  Debug Mode (Local Development) CerbiStream prevents queue logging while debugging. This is enabled by default (EnableDevMode = true).

var config = new CerbiStreamOptions();
config.EnableDevMode();

var logger = new CerbiStreamLogger(config);
await logger.LogEventAsync("Debugging locally", LogLevel.Debug);

πŸ“Š Meta Data Sharing (Opt-In)

CerbiStream collects aggregate trends across applications for AI-powered insights. βœ… No Personally Identifiable Information (PII) is stored.

If enabled, your logs contribute to global analytics (Error Trends, Cloud Performance, API Response Issues). If disabled, your logs remain 100% private.

var config = new CerbiStreamOptions();
config.IncludeAdvancedMetadata();
config.IncludeSecurityMetadata();

πŸ“Š Telemetry Support (Optional)

CerbiStream now supports distributed tracing and application performance monitoring through multiple telemetry providers.

Supported Telemetry Providers

Provider Status
Azure Application Insights βœ… Supported
AWS CloudWatch βœ… Supported
Google Cloud Trace βœ… Supported
Datadog βœ… Supported
OpenTelemetry (default) βœ… Supported

πŸ›  Configuring Telemetry in CerbiStream

To enable telemetry, specify a provider in the CerbiStreamOptions configuration:

var config = new CerbiStreamOptions();
config.SetTelemetryProvider(new AppInsightsTelemetryProvider()); // Choose from AppInsights, AWS, GCP, Datadog, etc.
config.SetQueue("RabbitMQ", "localhost", "logs-queue");
config.EnableGovernance();

var logger = new CerbiStreamLogger(config);

🌍 Multi-Cloud Telemetry Routing

You can route different types of logs to different telemetry providers for better visibility.

Log Type Default Destination
Application Logs Google Cloud Trace
Infrastructure Logs AWS CloudWatch
Security & Audit Logs Azure Application Insights
Performance Metrics Datadog

To customize this, configure the routing rules in your governance JSON file:

{
  "TelemetryRouting": {
    "ApplicationLogs": "GoogleCloud",
    "InfraLogs": "AWS",
    "SecurityLogs": "Azure",
    "PerformanceMetrics": "Datadog"
  }
}

⚑ Optimized Telemetry Collection

CerbiStream minimizes unnecessary logging noise while ensuring critical events are captured.

  • βœ… Event Sampling – Configurable rate limiting to balance cost & observability.
  • βœ… Noise Reduction – Filters out low-priority logs like HealthCheck & DebugLog.
  • βœ… Auto-Enabled for Supported Providers – Telemetry is automatically enabled when a supported provider is detected (AWS, GCP, Azure).

πŸ”„ Auto-Enabled Telemetry Providers

CerbiStream detects and configures telemetry based on your cloud environment.

Cloud Provider Auto-Enabled Telemetry Service
AWS CloudWatch
Azure Application Insights
Google Cloud Stackdriver Trace
On-Prem OpenTelemetry (Custom Configuration)

Developers can override these settings to manually specify their preferred telemetry provider.

πŸ”Œ Multi-Telemetry Provider Setup

CerbiStream allows you to integrate multiple telemetry providers for better observability across cloud environments.

πŸš€ Example: Using OptimizedTelemetryProvider, AWS CloudWatch & Azure Application Insights

using CerbiStream.Configuration;
using CerbiStream.Interfaces;
using CerbiStream.Classes.OpenTelemetry;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

class Program
{
    static void Main()
    {
        var serviceProvider = new ServiceCollection()
            .AddLogging(builder =>
            {
                builder.AddConsole();
                builder.AddCerbiStream(options =>
                {
                    options.SetQueue("RabbitMQ", "localhost", "logs-queue");
                    options.EnableDevMode();
                    options.EnableGovernance();

                    // βœ… Optimized telemetry provider (efficient tracing with sampling)
                    options.AddTelemetryProvider(new OptimizedTelemetryProvider(samplingRate: 0.5));  

                    // βœ… Add multiple telemetry providers
                    options.AddTelemetryProvider(new CloudWatchTelemetryProvider());  
                    options.AddTelemetryProvider(new AppInsightsTelemetryProvider());  
                });
            })
            .BuildServiceProvider();

        var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

        logger.LogInformation("Application started successfully!");
        logger.LogError("Critical error detected in system.");
    }
}

You can enable, disable, or prioritize telemetry providers as needed.


options.EnableTelemetry(); // Enable all auto-detected telemetry providers  
options.DisableTelemetry(); // Disable all telemetry tracking  
options.SetTelemetrySamplingRate(0.3); // 30% sampling for cost optimization  

Example: Using OptimizedTelemetryProvider

options.AddTelemetryProvider(new OptimizedTelemetryProvider(samplingRate: 0.5));

πŸ“ˆ Rollup & Multi-Project Visibility

CerbiStream supports centralized telemetry aggregation, allowing you to visualize logs, metrics, and traces from multiple services or microservices in one place.

This is especially useful for:

  • πŸš€ Microservices Architectures
  • 🧩 Distributed Systems
  • πŸ› οΈ Multi-Environment Monitoring (Dev / QA / Prod)

🧭 Example: Using Application Insights for Rollups

With Azure Application Insights, all telemetry (from different apps) can be grouped under a single Application Map:

options.AddTelemetryProvider(new AppInsightsTelemetryProvider());

Be sure to:

Use the same Instrumentation Key or Connection String across services. Tag logs with AppName, Environment, or Component for grouping:

var metadata = new Dictionary<string, string>
{
    { "AppName", "CheckoutService" },
    { "Environment", "Production" },
    { "Component", "PaymentProcessor" }
};

logger.LogEvent("Payment failed", LogLevel.Error, metadata);

🧠 Global Observability (Optional) (coming soon)

With IncludeAdvancedMetadata(), your logs can contribute (without PII) to:

Industry-wide error trends

ML-driven root cause patterns

Performance benchmarking across cloud platforms

config.IncludeAdvancedMetadata();

πŸ”₯ Why Use CerbiStream?

  • βœ… Structured Logs by Default – Consistent schema with contextual metadata like Feature, ServiceName, and RetryAttempt.
  • βœ… Multi-Cloud Ready – Route telemetry to Azure, AWS, GCP, Datadog, or OpenTelemetry.
  • βœ… NPI-Free Insights – Built from the ground up to exclude personally identifiable information.
  • βœ… Business-Aware Logging – Capture UserType, OriginApp, and FeatureArea for analytics and ML without leaking sensitive data.
  • βœ… Central Rollups Across Microservices – Logs can be grouped by service, app, or feature to enable intelligent visualization and trend detection.
  • βœ… No External Dependencies – Just install & start logging.
  • πŸš€ Optimized Performance – Uses static enrichment and telemetry sampling to reduce overhead.
  • πŸ”’ Security First – Optional field-level encryption and governance enforcement.
  • 🌍 Global Insights – Enables anonymized, cross-client trend discovery (if opted-in).
  • ⚑ Minimal Setup – Works out-of-the-box with simple constructor injection.

πŸ“œ License CerbiStream is open-source and available under the MIT License.


πŸ“£ Want to contribute?
Star the repo ⭐, open an issue πŸ›, or suggest a feature 🧠!

Cerbi Homepage

πŸ§‘β€πŸ’» Created by @Zeroshi

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.15 0 4/7/2025
1.0.14 37 4/6/2025
1.0.13 97 3/28/2025
1.0.12 92 3/27/2025
1.0.11 427 3/26/2025
1.0.10 450 3/25/2025
1.0.9 122 3/23/2025
1.0.8 39 3/22/2025
1.0.7 102 3/21/2025
1.0.6 112 3/20/2025
1.0.5 118 3/20/2025
1.0.4 110 3/19/2025
1.0.3 110 3/19/2025
1.0.2 129 3/12/2025
1.0.1 119 3/12/2025