namespace ZB.MOM.WW.Telemetry;

/// <summary>
/// Selects how instrumentation data is exported.
/// </summary>
public enum ZbExporter
{
    /// <summary>
    /// Prometheus scrape endpoint (default). Call <c>app.MapZbMetrics()</c> to mount <c>/metrics</c>.
    /// </summary>
    Prometheus,

    /// <summary>
    /// OTLP gRPC export. Set <see cref="ZbTelemetryOptions.OtlpEndpoint"/>
    /// (e.g. <c>"http://collector:4317"</c>).
    /// </summary>
    Otlp,
}

/// <summary>
/// Options for <c>AddZbTelemetry</c>. All properties feed the shared OpenTelemetry Resource.
/// </summary>
public sealed class ZbTelemetryOptions
{
    /// <summary>
    /// Required. Short lower-case app identifier — e.g. <c>"otopcua"</c>, <c>"mxgateway"</c>,
    /// <c>"scadabridge"</c>. Populates OTel Resource <c>service.name</c>.
    /// </summary>
    public string ServiceName { get; set; } = "";

    /// <summary>
    /// Fleet-wide namespace. Default <c>"ZB.MOM.WW"</c>. Do not override per-app.
    /// Populates OTel Resource <c>service.namespace</c>.
    /// </summary>
    public string ServiceNamespace { get; set; } = "ZB.MOM.WW";

    /// <summary>
    /// Optional. Populate from <c>AssemblyInformationalVersion</c>.
    /// Populates OTel Resource <c>service.version</c>.
    /// </summary>
    public string? ServiceVersion { get; set; }

    /// <summary>
    /// Optional. Physical or logical site identifier.
    /// Populates OTel Resource <c>site.id</c>.
    /// </summary>
    public string? SiteId { get; set; }

    /// <summary>
    /// Optional. Node function: <c>"central"</c>, <c>"site"</c>, <c>"hub"</c>, <c>"standalone"</c>.
    /// Populates OTel Resource <c>node.role</c>.
    /// </summary>
    public string? NodeRole { get; set; }

    /// <summary>
    /// App-specific Meter names to register with the OTel MeterProvider. Standard instrumentation
    /// meters are added automatically (ASP.NET Core, HttpClient, runtime, process).
    /// </summary>
    public string[] Meters { get; set; } = [];

    /// <summary>
    /// App-specific ActivitySource names to register with the OTel TracerProvider.
    /// </summary>
    public string[] ActivitySources { get; set; } = [];

    /// <summary>
    /// Export path. Default Prometheus; use <see cref="ZbExporter.Otlp"/> for a real collector.
    /// </summary>
    public ZbExporter Exporter { get; set; } = ZbExporter.Prometheus;

    /// <summary>
    /// Required when <see cref="Exporter"/> = <see cref="ZbExporter.Otlp"/>.
    /// OTLP gRPC endpoint, e.g. <c>"http://collector:4317"</c>.
    /// </summary>
    public string? OtlpEndpoint { get; set; }
}
