using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Amazon.Runtime { /// /// Metrics collected by the SDK on a per-request basis. /// /// /// Each request made to an AWS service by the SDK can have metrics /// collected and logged. This interface represents the collected /// metrics for a request. The metrics include properties (i.e. request id /// and other metadata), timings for each stage of the request, and counters. /// public interface IRequestMetrics { /// /// Collection of properties being tracked /// Dictionary> Properties { get; } /// /// Timings for metrics being tracked /// Dictionary> Timings { get; } /// /// Counters being tracked /// Dictionary Counters { get; } /// /// Whether metrics are enabled for the request /// bool IsEnabled { get; } /// /// JSON representation of the current metrics /// /// JSON string string ToJSON(); } /// /// Represents how long a phase of an SDK request took. /// public interface IMetricsTiming { /// /// Whether the timing has been stopped /// bool IsFinished { get; } /// /// Elapsed ticks from start to stop. /// If timing hasn't been stopped yet, returns 0. /// long ElapsedTicks { get; } /// /// Elapsed time from start to stop. /// If timing hasn't been stopped yet, returns TimeSpan.Zero /// TimeSpan ElapsedTime { get; } } /// /// User supplied type to perform metrics formatting. /// public interface IMetricsFormatter { /// /// Produce custom formatting for SDK metrics. /// /// /// If defined, this method will be called for every request made by the SDK. /// /// An instance of IRequestMetrics produced by the SDK /// formatted string representation of the metrics string FormatMetrics(IRequestMetrics metrics); } /// /// Predefined request metrics that are collected by the SDK. /// public enum Metric { // response enums AWSErrorCode, AWSRequestID, AmzId2, BytesProcessed, Exception, RedirectLocation, ResponseProcessingTime, ResponseUnmarshallTime, ResponseReadTime, StatusCode, // request enums AttemptCount, CredentialsRequestTime, HttpRequestTime, ProxyHost, ProxyPort, RequestSigningTime, RetryPauseTime, StringToSign, CanonicalRequest, // CSM metric added to measure the latency of each http // request CSMAttemptLatency, // overall enums AsyncCall, ClientExecuteTime, MethodName, ServiceEndpoint, ServiceName, RequestSize, AmzCfId, } }