Class ValidationMeterProviderBuilderExtensions
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Extension methods for collecting Trellis validation metrics with OpenTelemetry.
public static class ValidationMeterProviderBuilderExtensions
- Inheritance
-
ValidationMeterProviderBuilderExtensions
- Inherited Members
Methods
AddTrellisValidationInstrumentation(MeterProviderBuilder)
Subscribes the meter provider to Trellis validation instruments.
public static MeterProviderBuilder AddTrellisValidationInstrumentation(this MeterProviderBuilder builder)
Parameters
builderMeterProviderBuilderThe OpenTelemetry.Metrics.MeterProviderBuilder to configure.
Returns
- MeterProviderBuilder
The same OpenTelemetry.Metrics.MeterProviderBuilder instance for method chaining.
Examples
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics => metrics
.AddTrellisValidationInstrumentation()
.AddOtlpExporter());
Remarks
Trellis counts a violation as each validation failure is created, but a Counter<T> with no listener records nothing. Until this is called the instrument is inert, and its absence is silent — there is no error and no warning, only a metric that never appears in the backend, which reads exactly like a rule that never fires. That ambiguity is the thing the counter exists to remove, so registering it is not optional if the dead-rule question is the reason you enabled it.
Equivalent to AddMeter("Trellis.Validation"); prefer this so the name is read from
MeterName and cannot drift from the meter Trellis publishes.