net8.0net9.0net10.0
An Aspire component to add an OpenTelemetry Collector into the OTLP pipeline
Published
Jan 16, 2026
9mo ago
Total Downloads
71.9K
71,948
Install
dotnet add package CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector --version 13.1.1
| Product | Versions |
|---|---|
| .NET |
README
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector
Overview
This .NET Aspire Integration can be used to include OpenTelemetry Collector in a container.
Usage
Example 1: Add OpenTelemetry Collector without automatic redirection
In this approach, only the projects and resource that you forward the collector to will have their telemetry forwarded to the collector.
var builder = DistributedApplication.CreateBuilder(args);
var collector = builder.AddOpenTelemetryCollector("opentelemetry-collector")
.WithConfig("./config.yaml");
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_OpenTelemetryCollector_Api>("api")
.WithOpenTelemetryCollectorRouting(collector);
builder.Build().Run();
Example 2: Add OpenTelemetry Collector with automatic redirection
In this approach, all projects and resources that have the OtlpExporterAnnotation will have their telemetry forwarded to the collector.
var builder = DistributedApplication.CreateBuilder(args);
var collector = builder.AddOpenTelemetryCollector("opentelemetry-collector")
.WithConfig("./config.yaml")
.WithAppForwarding();
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_OpenTelemetryCollector_Api>("api");
builder.Build().Run();
Changes from Previous Version
No structural changes between v13.1.1-beta.502 and v13.1.1.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.