using System.Collections.Generic;
using System.Diagnostics.Metrics;

namespace StellaOps.Feedser.Storage.Mongo.Aliases;

internal static class AliasStoreMetrics
{
    private static readonly Meter Meter = new("StellaOps.Feedser.Merge");

    internal static readonly Counter<long> AliasCollisionCounter = Meter.CreateCounter<long>(
        "feedser.merge.alias_conflict",
        unit: "count",
        description: "Number of alias collisions detected when the same alias maps to multiple advisories.");

    public static void RecordCollision(string scheme, int advisoryCount)
    {
        AliasCollisionCounter.Add(
            1,
            new KeyValuePair<string, object?>("scheme", scheme),
            new KeyValuePair<string, object?>("advisory_count", advisoryCount));
    }
}
