net8.0net9.0
An Aspire component to add an OpenTelemetry Collector into the OTLP pipeline
Published
Oct 27, 2025
11mo ago
Total Downloads
71.9K
71,948
Install
dotnet add package CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector --version 9.8.1-beta.417
| 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 v9.8.1-beta.414 and v9.8.1-beta.417.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 2 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.