using System;
namespace Svrnty.CQRS.Events.Abstractions.Streaming;
///
/// Metrics collection interface for event streaming operations.
/// Provides observability into stream performance, consumer behavior, and error rates.
///
///
///
/// Phase 6 Feature:
/// This interface enables monitoring and observability for event streaming.
/// Implementations should integrate with telemetry systems like OpenTelemetry, Prometheus, etc.
///
///
/// Key Metrics Categories:
/// - Throughput: Events published/consumed per second
/// - Lag: Consumer offset delta from stream head
/// - Latency: Time from event publish to acknowledgment
/// - Errors: Failed operations and retry counts
///
///
public interface IEventStreamMetrics
{
///
/// Records an event being published to a stream.
///
/// Name of the stream.
/// Type name of the event.
void RecordEventPublished(string streamName, string eventType);
///
/// Records an event being consumed from a subscription.
///
/// Name of the stream.
/// ID of the subscription.
/// Type name of the event.
void RecordEventConsumed(string streamName, string subscriptionId, string eventType);
///
/// Records the processing latency for an event (time from publish to acknowledgment).
///
/// Name of the stream.
/// ID of the subscription.
/// Processing duration.
void RecordProcessingLatency(string streamName, string subscriptionId, TimeSpan latency);
///
/// Records consumer lag (offset delta from stream head).
///
/// Name of the stream.
/// ID of the subscription.
/// Number of events the consumer is behind.
void RecordConsumerLag(string streamName, string subscriptionId, long lag);
///
/// Records an error during event processing.
///
/// Name of the stream.
/// ID of the subscription (or null for publish errors).
/// Type or category of error.
void RecordError(string streamName, string? subscriptionId, string errorType);
///
/// Records a retry attempt for failed event processing.
///
/// Name of the stream.
/// ID of the subscription.
/// Retry attempt number (1-based).
void RecordRetry(string streamName, string subscriptionId, int attemptNumber);
///
/// Records the current stream length (total events).
///
/// Name of the stream.
/// Current length of the stream.
void RecordStreamLength(string streamName, long length);
///
/// Records the number of active consumers for a subscription.
///
/// Name of the stream.
/// ID of the subscription.
/// Number of active consumers.
void RecordActiveConsumers(string streamName, string subscriptionId, int consumerCount);
}