Gainsway.Observability
1.2.2
dotnet add package Gainsway.Observability --version 1.2.2
NuGet\Install-Package Gainsway.Observability -Version 1.2.2
<PackageReference Include="Gainsway.Observability" Version="1.2.2" />
paket add Gainsway.Observability --version 1.2.2
#r "nuget: Gainsway.Observability, 1.2.2"
// Install Gainsway.Observability as a Cake Addin #addin nuget:?package=Gainsway.Observability&version=1.2.2 // Install Gainsway.Observability as a Cake Tool #tool nuget:?package=Gainsway.Observability&version=1.2.2
lib-dotnet-observability
This library add open telemetry configuration extensions for .NET Core Api
Configuration
- Install
Gainsway.Observability
package in the target project
dotnet add package Gainsway.Observability
- Register the Observability services in the Infrastructure project:
# InfrastructureServiceExtensions.cs
var appMetadata = builder.Configuration.GetApplicationMetadata();
builder.AddObservability(serviceName: appMetadata.ServiceName, commitShortSha: appMetadata.CommitShortSha);
OPTIONAL To create tracing span for each method execution of a class, using .NET DI framework, the class's interface needs to be decorated by using one of the following extensions:
- Enable tracing for all services within a namespace
// Program.cs builder.Services.TraceAllServicesInNamespace("Gainsway");
- Enable tracing for services' interfaces decorated with Traceable attribute
// Program.cs builder.Services.TraceDecoratedServices();
// IMyService.cs [Traceable] public interface IMyService { // ... }
- Enable tracing for services explicitly defined in the config
// Program.cs builder.Services.TraceServices([typeof(IMyService), typeof(IOtherService)]);
OPTIONAL To create tracing span for each method execution of a class without using .NET DI framework:
using Gainsway.Observability // ... IMyService domainServiceInstance = new MyService(); IMyService decoratedInstance = TraceDecorator<IMyService>.Create(domainServiceInstance);
Environment variables
[!NOTE] In OpenTelemetry .NET environment variable keys are retrieved using
IConfiguration
which means they may be set using other mechanisms such as defined in appSettings.json or specified on the command-line.
Exporter configuration
The OpenTelemetry Specification defines environment variables which can be used to configure the OTLP exporter and its associated processor (logs & traces) or reader (metrics).
All signals
The following environment variables can be used to override the default values of the
OtlpExporterOptions
:Environment variable OtlpExporterOptions
propertyOTEL_EXPORTER_OTLP_ENDPOINT
Endpoint
OTEL_EXPORTER_OTLP_HEADERS
Headers
OTEL_EXPORTER_OTLP_TIMEOUT
TimeoutMilliseconds
OTEL_EXPORTER_OTLP_PROTOCOL
Protocol
(grpc
orhttp/protobuf
)Logs:
The following environment variables can be used to override the default values for the batch processor configured for logging:
Environment variable BatchExportLogRecordProcessorOptions
propertyOTEL_BLRP_SCHEDULE_DELAY
ScheduledDelayMilliseconds
OTEL_BLRP_EXPORT_TIMEOUT
ExporterTimeoutMilliseconds
OTEL_BLRP_MAX_QUEUE_SIZE
MaxQueueSize
OTEL_BLRP_MAX_EXPORT_BATCH_SIZE
MaxExportBatchSize
The following environment variables can be used to override the default values of the
OtlpExporterOptions
used for logging when using the UseOtlpExporter extension:Environment variable OtlpExporterOptions
propertyUseOtlpExporter AddOtlpExporter OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
Endpoint
Supported Not supported OTEL_EXPORTER_OTLP_LOGS_HEADERS
Headers
Supported Not supported OTEL_EXPORTER_OTLP_LOGS_TIMEOUT
TimeoutMilliseconds
Supported Not supported OTEL_EXPORTER_OTLP_LOGS_PROTOCOL
Protocol
(grpc
orhttp/protobuf
)Supported Not supported Metrics:
The following environment variables can be used to override the default value of the
TemporalityPreference
setting for the reader configured for metrics when using OTLP exporter:Environment variable MetricReaderOptions
propertyOTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
TemporalityPreference
The following environment variables can be used to override the default values of the periodic exporting metric reader configured for metrics:
Environment variable PeriodicExportingMetricReaderOptions
propertyOTEL_METRIC_EXPORT_INTERVAL
ExportIntervalMilliseconds
OTEL_METRIC_EXPORT_TIMEOUT
ExportTimeoutMilliseconds
The following environment variables can be used to override the default values of the
OtlpExporterOptions
used for metrics when using the UseOtlpExporter extension:Environment variable OtlpExporterOptions
propertyUseOtlpExporter AddOtlpExporter OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
Endpoint
Supported Not supported OTEL_EXPORTER_OTLP_METRICS_HEADERS
Headers
Supported Not supported OTEL_EXPORTER_OTLP_METRICS_TIMEOUT
TimeoutMilliseconds
Supported Not supported OTEL_EXPORTER_OTLP_METRICS_PROTOCOL
Protocol
(grpc
orhttp/protobuf
)Supported Not supported Tracing:
The following environment variables can be used to override the default values for the batch processor configured for tracing:
Environment variable BatchExportActivityProcessorOptions
propertyOTEL_BSP_SCHEDULE_DELAY
ScheduledDelayMilliseconds
OTEL_BSP_EXPORT_TIMEOUT
ExporterTimeoutMilliseconds
OTEL_BSP_MAX_QUEUE_SIZE
MaxQueueSize
OTEL_BSP_MAX_EXPORT_BATCH_SIZE
MaxExportBatchSize
The following environment variables can be used to override the default values of the
OtlpExporterOptions
used for tracing when using the UseOtlpExporter extension:Environment variable OtlpExporterOptions
propertyUseOtlpExporter AddOtlpExporter OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
Endpoint
Supported Not supported OTEL_EXPORTER_OTLP_TRACES_HEADERS
Headers
Supported Not supported OTEL_EXPORTER_OTLP_TRACES_TIMEOUT
TimeoutMilliseconds
Supported Not supported OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
Protocol
(grpc
orhttp/protobuf
)Supported Not supported
Attribute limits
The OpenTelemetry Specification defines environment variables which can be used to configure attribute limits.
The following environment variables can be used to configure default attribute limits:
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT
OTEL_ATTRIBUTE_COUNT_LIMIT
The following environment variables can be used to configure span limits used for tracing:
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT
OTEL_SPAN_EVENT_COUNT_LIMIT
OTEL_SPAN_LINK_COUNT_LIMIT
OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT
OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
The following environment variables can be used to configure log record limits used for logging:
OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT
OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- Npgsql.OpenTelemetry (>= 8.0.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.10.0)
- OpenTelemetry.Extensions.Hosting (>= 1.10.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.10.0)
- OpenTelemetry.Instrumentation.AWS (>= 1.10.0-beta.2)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.10.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.10.0)
- Scrutor (>= 5.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.