BuildingBlocks.Telemetry 1.0.2

dotnet add package BuildingBlocks.Telemetry --version 1.0.2
                    
NuGet\Install-Package BuildingBlocks.Telemetry -Version 1.0.2
                    
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="BuildingBlocks.Telemetry" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BuildingBlocks.Telemetry" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BuildingBlocks.Telemetry" />
                    
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 BuildingBlocks.Telemetry --version 1.0.2
                    
#r "nuget: BuildingBlocks.Telemetry, 1.0.2"
                    
#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.
#:package BuildingBlocks.Telemetry@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BuildingBlocks.Telemetry&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BuildingBlocks.Telemetry&version=1.0.2
                    
Install as a Cake Tool

BuildingBlocks.Telemetry

Config-driven OpenTelemetry traces, metrics, and logs for ASP.NET Core from one AddTelemetry call. Export OTLP to any backend. Requires IHostApplicationBuilder.

NuGet License: MIT

What's new in 1.0.2

  • IntegrateMcp (default false) adds ActivitySource BuildingBlocks.Mcp
  • TelemetryDefaults.McpActivitySource / TelemetryComponentTags.Mcp

What's new in 1.0.1

  • IntegrateMediator also AddMeter("BuildingBlocks.Mediator") so Send metrics export with traces
  • TelemetryDefaults.MediatorMeter (same name as the mediator ActivitySource)

Requirements

  • .NET 8, .NET 9, or .NET 10 (net8.0 / net9.0 / net10.0)
  • IHostApplicationBuilder (Microsoft.AspNetCore.App)

This package is not a SigNoz SDK. Local Aspire SigNoz: BuildingBlocks.Aspire.Hosting.SigNoz. Libraries emit with UseTelemetry(); this host exports when IntegrateMediator / IntegrateMcp is on.

Install

dotnet add package BuildingBlocks.Telemetry

Quick start

Defaults are enough for most hosts. Set OTEL_EXPORTER_OTLP_ENDPOINT for export. Do not call AddTelemetry twice.

builder.AddTelemetry(o =>
{
    o.IntegrateMediator = true;
    o.IntegrateMcp = true;               // default false
    o.Instrumentation.EventBus = true;   // default false
});

Quick start — all options

One AddTelemetry call. Values below are the defaults unless marked opt-in. Prefer OTEL_EXPORTER_OTLP_* over Exporters.Otlp.Endpoint. Do not call AddTelemetry twice (if your ServiceDefaults host already calls it, pass this callback there — AddServiceDefaults is not in this package).

builder.AddTelemetry(o =>
{
    // Resource (empty ServiceName → IHostEnvironment.ApplicationName)
    o.ServiceName = null;
    o.ServiceNamespace = null;
    o.ServiceVersion = null;
    o.ResourceAttributes["team"] = "platform"; // extra; deployment.environment / service.environment always set

    // Signals (all default true)
    o.EnableTracing = true;
    o.EnableMetrics = true;
    o.EnableLogging = true;

    // Library sources: emit with UseTelemetry() on Mediator/MCP; these flags export them
    o.IntegrateMediator = true;  // default true — AddSource + AddMeter BuildingBlocks.Mediator
    o.IntegrateMcp = true;       // default false — AddSource BuildingBlocks.Mcp

    o.Sources.Add("MyApp");      // extra ActivitySources
    o.Meters.Add("MyApp");       // extra meters

    o.TracesSamplerRatio = null;           // null: AlwaysOn in Development, SDK default otherwise
    o.AlwaysOnSamplerInDevelopment = true; // ignored when TracesSamplerRatio is set
    o.SetErrorStatusOnException = true;
    o.EnableTraceBasedExemplars = true;

    var i = o.Instrumentation;
    i.AspNetCore = true;
    i.HttpClient = true;
    i.Runtime = true;
    i.Npgsql = true;                    // default true
    i.IncludeFrameworkMeters = true;    // Hosting, Kestrel, Routing, Diagnostics, Auth, MemoryPool, Http, DNS
    i.FilterHealthCheckRequests = true; // /health, /alive, /ready, /metrics
    // i.ExcludedPathPrefixes.Add("/swagger");
    i.RecordException = true;           // before Configure* callbacks

    i.SqlClient = false;                // opt-in
    i.EventBus = true;                  // opt-in — ActivitySource "EventBus"
    i.MassTransit = false;              // opt-in — ActivitySource "MassTransit"

    // Code-only (not JSON). Order: Filter / RecordException → this callback → telemetry.component
    i.ConfigureAspNetCore = opts =>
        opts.EnrichWithHttpRequest = (activity, request) => activity.SetTag("http.route", request.Path);
    i.ConfigureHttpClient = opts => { };
    i.ConfigureSqlClient = opts =>
        opts.EnrichWithSqlCommand = (activity, command) =>
            activity.SetTag("db.command_type", command.CommandType.ToString());

    // Exporters — leave Otlp.Enabled false and set OTEL_EXPORTER_OTLP_ENDPOINT for the env fast-path
    o.Exporters.Otlp.Enabled = false;
    o.Exporters.Otlp.Endpoint = null;           // if set, per-signal AddOtlpExporter (no fast-path)
    o.Exporters.Otlp.Headers = null;            // same — forces per-signal path
    o.Exporters.Otlp.Protocol = TelemetryOtlpProtocol.Grpc; // ignored on env fast-path; use OTEL_EXPORTER_OTLP_PROTOCOL
    o.Exporters.Otlp.ProtocolName = null;       // appsettings "grpc" | "http/protobuf" wins over Protocol
    o.Exporters.Console.Enabled = false;        // local debug; also disables OTLP fast-path
    o.Exporters.AzureMonitor.Enabled = false;
    o.Exporters.AzureMonitor.ConnectionString = null; // or APPLICATIONINSIGHTS_CONNECTION_STRING
},
configureBuilder: t =>
{
    t.AddSource("DbMigrations");
    t.AddMeter("DbMigrations");
    t.ConfigureResource(r => { });
    t.ConfigureTracing(tr => tr
        .AddEntityFrameworkCoreInstrumentation()  // contrib — not shipped
        .AddRedisInstrumentation());
    t.ConfigureMetrics(m => { });
    t.ConfigureLogging(l => { });
});

using var activity = TelemetryActivity.Start("MyApp", "Checkout");
activity?.SetTag("order.id", id);
activity?.AddEvent("payment.started");
activity?.RecordException(ex);
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# OTEL_EXPORTER_OTLP_HEADERS=signoz-ingestion-key=...

Env-only OTLP uses UseOtlpExporter() for traces, metrics, and logs. Do not mix that with explicit Endpoint / Headers / Console.

ConfigureTracing / ConfigureMetrics must run while IServiceCollection is still open. EF Core, Redis, gRPC client, and Prometheus scrape are not first-class.

Mediator: cfg.UseTelemetry() then IntegrateMediator. MCP: builder UseTelemetry() then IntegrateMcp. Without Integrate*, spans stay in-process.

Configuration section (bindable)

Telemetry JSON / Telemetry__*. ConfigureAspNetCore / ConfigureHttpClient / ConfigureSqlClient are code-only.

{
  "Telemetry": {
    "ServiceName": null,
    "ServiceNamespace": null,
    "ServiceVersion": null,
    "EnableTracing": true,
    "EnableMetrics": true,
    "EnableLogging": true,
    "IntegrateMediator": true,
    "IntegrateMcp": false,
    "Sources": [ "MyApp" ],
    "Meters": [ "MyApp" ],
    "TracesSamplerRatio": null,
    "AlwaysOnSamplerInDevelopment": true,
    "SetErrorStatusOnException": true,
    "EnableTraceBasedExemplars": true,
    "Instrumentation": {
      "AspNetCore": true,
      "HttpClient": true,
      "Runtime": true,
      "Npgsql": true,
      "IncludeFrameworkMeters": true,
      "FilterHealthCheckRequests": true,
      "ExcludedPathPrefixes": [ "/health", "/alive", "/ready", "/metrics" ],
      "RecordException": true,
      "SqlClient": false,
      "EventBus": false,
      "MassTransit": false
    },
    "Exporters": {
      "Otlp": {
        "Enabled": false,
        "Endpoint": null,
        "Protocol": "Grpc",
        "ProtocolName": null,
        "Headers": null
      },
      "Console": { "Enabled": false },
      "AzureMonitor": { "Enabled": false, "ConnectionString": null }
    }
  }
}

Startup summary

One Information log after host start, e.g.:

BuildingBlocks.Telemetry ready for catalog-api in Development. Signals: traces, metrics, logs.
Exporters: OTLP (environment). Instrumentation: aspnetcore, httpclient, runtime, npgsql, framework-meters, mediator, mcp.

Endpoints, OTLP headers, and connection strings are never logged. Silence it with a log filter on BuildingBlocks.Telemetry.Internal.Pipeline.TelemetryStartupSummaryReporter. If signals are on but SigNoz is empty, the usual cause is no OTLP endpoint.

Docs

License

MIT — Copyright (c) 2026 Mohammad Hasan Hosseini

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 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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.2 44 8/29/2026
1.0.1 40 8/27/2026
1.0.0 42 8/27/2026

1.0.2: IntegrateMcp (opt-in ActivitySource BuildingBlocks.Mcp). https://github.com/Maxofpower/FeatureFusion/blob/main/CHANGELOG.md