| | | 1 | | using AsiBackbone.Core.Emissions; |
| | | 2 | | |
| | | 3 | | namespace AsiBackbone.OpenTelemetry; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Provides host-owned options for the OpenTelemetry governance emitter. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class OpenTelemetryGovernanceEmitterOptions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets or sets a value indicating whether activity events and activity tags should be emitted. |
| | | 12 | | /// </summary> |
| | 10 | 13 | | public bool EmitActivityEvents { get; set; } = true; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets or sets a value indicating whether low-cardinality counters and histograms should be emitted. |
| | | 17 | | /// </summary> |
| | 12 | 18 | | public bool EmitMetrics { get; set; } = true; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets or sets the provider name returned through provider-neutral emission results. |
| | | 22 | | /// </summary> |
| | 20 | 23 | | public string ProviderName { get; set; } = OpenTelemetryGovernanceInstrumentation.ProviderName; |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets or sets the activity name used when the envelope does not include an operation name. |
| | | 27 | | /// </summary> |
| | 16 | 28 | | public string DefaultActivityName { get; set; } = OpenTelemetryGovernanceInstrumentation.DefaultActivityName; |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets or sets an optional hook invoked before diagnostics are emitted. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <remarks> |
| | | 34 | | /// This hook is intended for tests and host-owned validation seams. It should not emit protected content. |
| | | 35 | | /// </remarks> |
| | 10 | 36 | | public Func<GovernanceEmissionEnvelope, CancellationToken, ValueTask>? BeforeEmitAsync { get; set; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Validates the configured options. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <exception cref="InvalidOperationException">Thrown when an option value is invalid.</exception> |
| | | 42 | | public void Validate() |
| | | 43 | | { |
| | 6 | 44 | | if (string.IsNullOrWhiteSpace(ProviderName)) |
| | | 45 | | { |
| | 0 | 46 | | throw new InvalidOperationException("OpenTelemetry governance provider name is required."); |
| | | 47 | | } |
| | | 48 | | |
| | 6 | 49 | | if (string.IsNullOrWhiteSpace(DefaultActivityName)) |
| | | 50 | | { |
| | 0 | 51 | | throw new InvalidOperationException("OpenTelemetry governance default activity name is required."); |
| | | 52 | | } |
| | 6 | 53 | | } |
| | | 54 | | } |