OpenTelemetry Module
Confinity supports OpenTelemetry to help you with insights. Add the package Confinity.OpenTelemetry which has useful helpers to make the integration easier.
Allows you to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior.
More information about OpenTelemetry and how it works can be found at https://opentelemetry.io/ .
Configuration
services.AddOpenTelemetryMetrics((builder) =>
builder
.AddConfinityInstrumentation()
.AddAspNetCoreInstrumentation() // optional
.AddHttpClientInstrumentation() // optional
.AddSomeExporter() // Todo: add Exporter
);
services.AddOpenTelemetryTracing((builder) => builder
.AddConfinityInstrumentation()
.AddHttpClientInstrumentation() // optional
.AddAspNetCoreInstrumentation() // optional
.AddSqlClientInstrumentation() // optional
.AddSomeExporter() // Todo: add Exporter
);
These packages allow you to get insights about your application with little effort:
- OpenTelemetry.Instrumentation.AspNetCore
- OpenTelemetry.Instrumentation.Http
- OpenTelemetry.Instrumentation.SqlClient
- OpenTelemetry.Instrumentation.EntityFrameworkCore
- OpenTelemetry.Instrumentation.Runtime
Example
Add OpenTelemetry to your DI.
services.AddOpenTelemetry()
.WithMetrics(b =>
{
b.AddConfinityInstrumentation(o =>
{
o.LogMetrics = true; // outputs metrics in the logs as an alternative to separate metrics collection.
})
// .AddAspNetCoreInstrumentation() // if you have OpenTelemetry.Instrumentation.AspNetCore
// .AddRuntimeInstrumentation() // if you have OpenTelemetry.Instrumentation.Runtime
// .AddHttpClientInstrumentation() // if you have OpenTelemetry.Instrumentation.Http
// others
;
})
.WithTracing(b =>
{
b.AddConfinityInstrumentation(o =>
{
/* ... */
})
// .AddConfinityInstrumentation()
// .AddHttpClientInstrumentation() // if you have OpenTelemetry.Instrumentation.Http
// .AddAspNetCoreInstrumentation() // if you have OpenTelemetry.Instrumentation.AspNetCore
// .AddSqlClientInstrumentation() // if you have OpenTelemetry.Instrumentation.SqlClient
// others
;
});