CasCap.Common.OpenTelemetry
4.11.0
Prefix Reserved
dotnet add package CasCap.Common.OpenTelemetry --version 4.11.0
NuGet\Install-Package CasCap.Common.OpenTelemetry -Version 4.11.0
<PackageReference Include="CasCap.Common.OpenTelemetry" Version="4.11.0" />
<PackageVersion Include="CasCap.Common.OpenTelemetry" Version="4.11.0" />
<PackageReference Include="CasCap.Common.OpenTelemetry" />
paket add CasCap.Common.OpenTelemetry --version 4.11.0
#r "nuget: CasCap.Common.OpenTelemetry, 4.11.0"
#:package CasCap.Common.OpenTelemetry@4.11.0
#addin nuget:?package=CasCap.Common.OpenTelemetry&version=4.11.0
#tool nuget:?package=CasCap.Common.OpenTelemetry&version=4.11.0
CasCap.Common.OpenTelemetry
Reusable OpenTelemetry configuration with standard metrics, traces, and log exporters via OTLP gRPC, built on top of CasCap.Common.Abstractions and CasCap.Common.Logging.Serilog.
Installation
dotnet add package CasCap.Common.OpenTelemetry
Purpose
Provides a single InitializeOpenTelemetry extension method on WebApplicationBuilder that registers the full OpenTelemetry pipeline (metrics, traces, and logs) with standard ASP.NET Core instrumentations. Configuration is driven by IMetricsConfig — the OTLP endpoint, service name, and metric prefix are all sourced from the application's configuration record.
Target frameworks: net8.0, net9.0, net10.0
Extensions
| Extension | Description |
|---|---|
OpenTelemetryExtensions.InitializeOpenTelemetry(builder, metricsConfig, connectionMultiplexer, gitMetadata, configureMetrics?, configureTracing?) |
Registers OpenTelemetry metrics, traces, and logs with OTLP gRPC export |
Behaviour
- Skips registration when
IMetricsConfig.OtlpExporterEndpointisnull— safe for development without an OTEL collector. - Development mode: Registers a Prometheus exporter for local
/metricsscraping. - Production mode: Adds ASP.NET Core, runtime, and process instrumentations for metrics; ASP.NET Core, HTTP client, and Redis instrumentations for traces.
- App-specific hooks: Optional
Action<MeterProviderBuilder>andAction<TracerProviderBuilder>callbacks for custom histogram views, additional trace sources, etc.
Configuration
The extension reads configuration from any IMetricsConfig implementation:
| Property | Type | Description |
|---|---|---|
MetricNamePrefix |
string |
Meter name and metric prefix (e.g. "haus", "cas") |
OtelServiceName |
string |
OpenTelemetry service name resource attribute |
OtlpExporterEndpoint |
Uri? |
OTLP gRPC endpoint (e.g. http://localhost:4317/). null disables telemetry. |
Configuration Examples
Minimal (disables telemetry):
{
"AppConfig": {
"MetricNamePrefix": "haus",
"OtelServiceName": "CasCap.App"
}
}
Fully configured:
{
"AppConfig": {
"MetricNamePrefix": "haus",
"OtelServiceName": "CasCap.App",
"OtlpExporterEndpoint": "http://opentelemetry-collector.monitoring.svc:4317"
}
}
Dependencies
NuGet Packages
| Package | Purpose |
|---|---|
| OpenTelemetry.Exporter.OpenTelemetryProtocol | OTLP gRPC exporter for metrics, traces, and logs |
| OpenTelemetry.Exporter.Prometheus.AspNetCore | Prometheus /metrics endpoint (development) |
| OpenTelemetry.Extensions.Hosting | AddOpenTelemetry() host integration |
| OpenTelemetry.Instrumentation.AspNetCore | HTTP request metrics and traces |
| OpenTelemetry.Instrumentation.Http | Outbound HTTP client traces |
| OpenTelemetry.Instrumentation.Process | CPU and memory utilization metrics |
| OpenTelemetry.Instrumentation.Runtime | GC, thread pool, and assembly metrics |
| OpenTelemetry.Instrumentation.StackExchangeRedis | Redis command traces |
| StackExchange.Redis | Redis connection multiplexer type |
Project References
| Project | Purpose |
|---|---|
CasCap.Common.Abstractions |
IMetricsConfig interface |
CasCap.Common.Logging.Serilog |
Serilog fallback warning when endpoint is null |
CasCap.Common.Services |
GitMetadata record for resource attributes |
| 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 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. |
-
net10.0
- CasCap.Common.Abstractions (>= 4.11.0)
- CasCap.Common.Logging.Serilog (>= 4.11.0)
- CasCap.Common.Services (>= 4.11.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.3-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.StackExchangeRedis (>= 1.15.1-beta.1)
- StackExchange.Redis (>= 2.12.14)
-
net8.0
- CasCap.Common.Abstractions (>= 4.11.0)
- CasCap.Common.Logging.Serilog (>= 4.11.0)
- CasCap.Common.Services (>= 4.11.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.3-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.StackExchangeRedis (>= 1.15.1-beta.1)
- StackExchange.Redis (>= 2.12.14)
-
net9.0
- CasCap.Common.Abstractions (>= 4.11.0)
- CasCap.Common.Logging.Serilog (>= 4.11.0)
- CasCap.Common.Services (>= 4.11.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.3-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.StackExchangeRedis (>= 1.15.1-beta.1)
- StackExchange.Redis (>= 2.12.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.