OpenTelemetryExtension.Configuration
1.0.1
See the version list below for details.
dotnet add package OpenTelemetryExtension.Configuration --version 1.0.1
NuGet\Install-Package OpenTelemetryExtension.Configuration -Version 1.0.1
<PackageReference Include="OpenTelemetryExtension.Configuration" Version="1.0.1" />
<PackageVersion Include="OpenTelemetryExtension.Configuration" Version="1.0.1" />
<PackageReference Include="OpenTelemetryExtension.Configuration" />
paket add OpenTelemetryExtension.Configuration --version 1.0.1
#r "nuget: OpenTelemetryExtension.Configuration, 1.0.1"
#:package OpenTelemetryExtension.Configuration@1.0.1
#addin nuget:?package=OpenTelemetryExtension.Configuration&version=1.0.1
#tool nuget:?package=OpenTelemetryExtension.Configuration&version=1.0.1
OpenTelemetryExtension.Configuration
Configurable OpenTelemetry setup for ASP.NET Core via appsettings.json — tracing, metrics and logging with a single AddTelemetry() call.
⭐ Features
- Tracing: ASP.NET Core, HttpClient and SqlClient instrumentation out of the box.
- Metrics: ASP.NET Core, HttpClient and .NET runtime metrics.
- Logging: Structured log export via OpenTelemetry Protocol (OTLP).
- Flexible configuration: Bind from
appsettings.jsonor configure inline in code. - Extensible: Register custom instrumentation via
ConfigureTracing,ConfigureMetricsandConfigureLoggingcallbacks. - Protocol support: HTTP/protobuf (port 4318) and gRPC (port 4317).
🚀 Getting Started
Installation
Install via NuGet:
dotnet add package OpenTelemetryExtension.Configuration
Register in Service Collection
Option A — via appsettings.json
builder.Services.AddTelemetry(builder.Configuration);
{
"Telemetry": {
"Endpoint": "http://localhost:4318",
"ServiceName": "my-api",
"EnvironmentName": "production"
}
}
Option B — inline in code
builder.Services.AddTelemetry(o =>
{
o.Endpoint = new Uri("http://localhost:4318");
o.ServiceName = "my-api";
o.EnvironmentName = "production";
});
⚙️ Configuration Reference
All options can be set via appsettings.json under the Telemetry key.
| Property | Type | Default | Description |
|---|---|---|---|
Enabled |
bool |
true |
Disables all telemetry when false. |
Endpoint |
Uri |
— (required) | OTLP collector endpoint, e.g. http://localhost:4318. |
Headers |
string |
"" |
Exporter headers, e.g. Authorization=Basic .... Format: key1=value1,key2=value2. |
Protocol |
string |
Grpc |
OTLP protocol. Valid values: HttpProtobuf, Grpc. |
ServiceName |
string? |
null |
Service name reported to the backend. |
EnvironmentName |
string? |
null |
Reported as deployment.environment resource attribute. |
EnableTracing |
bool |
true |
Enables distributed tracing. |
EnableMetrics |
bool |
true |
Enables metrics collection. |
EnableLogging |
bool |
true |
Enables log export. |
EnableAspNetCoreInstrumentation |
bool |
true |
Instruments incoming HTTP requests. |
EnableHttpClientInstrumentation |
bool |
true |
Instruments outgoing HttpClient requests. |
EnableSqlClientInstrumentation |
bool |
true |
Instruments SQL database calls. |
EnableRuntimeInstrumentation |
bool |
true |
Collects GC, memory and thread pool metrics. |
RecordExceptions |
bool |
true |
Records exceptions with stack traces on spans. |
ExcludeHealthChecks |
bool |
true |
Excludes /health endpoints from tracing. |
Note:
ConfigureTracing,ConfigureMetricsandConfigureLoggingcallbacks are only available when configuring inline in code — they cannot be set viaappsettings.json.
🔌 Custom Instrumentation
Register additional instrumentation libraries via the callbacks:
builder.Services.AddTelemetry(o =>
{
o.Endpoint = new Uri("http://localhost:4318");
// e.g. MySQL, Redis, MongoDB, ...
o.ConfigureTracing = tracing => tracing.AddSource("MyApp");
o.ConfigureMetrics = metrics => metrics.AddMeter("MyApp");
o.ConfigureLogging = logging => logging.AddConsole();
});
📡 Backend Examples
Run the helm charts or use docker deploy with the cmd scripts.
See the deploy folder for all configuration files and startup scripts,
and the sample project for the corresponding appsettings configurations.
.NET Aspire Dashboard
{
"Telemetry": {
"Endpoint": "http://localhost:18888",
"Protocol": "HttpProtobuf"
}
}
Jaeger
{
"Telemetry": {
"Endpoint": "http://localhost:4318",
"Protocol": "HttpProtobuf"
}
}
SigNoz
{
"Telemetry": {
"Endpoint": "http://localhost:50709"
}
}
OpenSearch
{
"Telemetry": {
"Endpoint": "http://localhost:30318",
"Protocol": "HttpProtobuf"
}
}
Grafana Loki
Loki supports OTLP for logs only. Tracing and metrics must be disabled.
{
"Telemetry": {
"Endpoint": "http://localhost:3100/otlp",
"Protocol": "HttpProtobuf",
"EnableTracing": false,
"EnableMetrics": false
}
}
OpenObserve — HTTP/protobuf
{
"Telemetry": {
"Endpoint": "http://localhost:30117/api/default",
"Protocol": "HttpProtobuf",
"Headers": "Authorization=Basic <base64>,stream-name=default"
}
}
OpenObserve — gRPC
{
"Telemetry": {
"Endpoint": "http://localhost:30118",
"Protocol": "Grpc",
"Headers": "Authorization=Basic <base64>,organization=default,stream-name=default"
}
}
🤝 How to Contribute
Contributions are welcome! If you'd like to improve the project, please:
- Check out our contributing guidelines.
- Ideally, open an issue before starting work.
- Submit a pull request with your changes.
Thank you for helping make OpenTelemetryExtension.Configuration better!
🐞 Report a Bug
If you encounter any issues or bugs, please report them here.
For additional licensing and attribution details, see NOTICE.md and THIRD_PARTY_LICENSES.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net10.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.15.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.