Beispiel #1
0
        public static List <EgressTelemetry> ToEgressTelemetry(this List <StreamingEndpointRequestLog> egressMetrics, string originId, int originReservedUnits)
        {
            var result = new List <EgressTelemetry>();

            foreach (var egressMetric in egressMetrics)
            {
                var metricName = string.Format("{0}{1}", MetricConstants.HttpStatusCodeMetricNamePrefix, egressMetric.StatusCode);
                var telemetry  = new EgressTelemetry
                {
                    OriginId      = egressMetric.EntityId.ToString(),
                    Timestamp     = egressMetric.ObservedTime,
                    MetricName    = metricName,
                    Value         = egressMetric.RequestCount,
                    Miscellaneous = originReservedUnits
                };
                result.Add(telemetry);

                metricName = string.Format("{0}{1}{2}", MetricConstants.HttpStatusCodeMetricNamePrefix, egressMetric.StatusCode, MetricConstants.HttpStatusCodeBytesSentMetricNameSuffix);
                telemetry  = new EgressTelemetry
                {
                    OriginId      = egressMetric.EntityId.ToString(),
                    Timestamp     = egressMetric.ObservedTime,
                    MetricName    = metricName,
                    Value         = Math.Round(egressMetric.BytesSent * 8m / (1024 * 1024), 3),
                    Miscellaneous = originReservedUnits
                };
                result.Add(telemetry);

                metricName = string.Format("{0}{1}{2}", MetricConstants.HttpStatusCodeMetricNamePrefix, egressMetric.StatusCode, MetricConstants.HttpStatusCodeServerLatencyMetricNameSuffix);
                telemetry  = new EgressTelemetry
                {
                    OriginId      = egressMetric.EntityId.ToString(),
                    Timestamp     = egressMetric.ObservedTime,
                    MetricName    = metricName,
                    Value         = egressMetric.ServerLatency,
                    Miscellaneous = originReservedUnits
                };
                result.Add(telemetry);

                metricName = string.Format("{0}{1}{2}", MetricConstants.HttpStatusCodeMetricNamePrefix, egressMetric.StatusCode, MetricConstants.HttpStatusCodeE2ELatencyMetricNameSuffix);
                telemetry  = new EgressTelemetry
                {
                    OriginId      = egressMetric.EntityId.ToString(),
                    Timestamp     = egressMetric.ObservedTime,
                    MetricName    = metricName,
                    Value         = egressMetric.ServerLatency,
                    Miscellaneous = originReservedUnits
                };
                result.Add(telemetry);
            }

            return(result);
        }
 private static string GetGroupName(EgressTelemetry telemetry)
 {
     if (telemetry.MetricName.StartsWith("Http"))
     {
         return(telemetry.MetricName.Substring(4, 3));
     }
     else if (telemetry.MetricName.StartsWith("Failed"))
     {
         return(MetricConstants.FailedRequessMetricDisplayName);
     }
     else if (telemetry.MetricName.Equals(MetricConstants.BytesSentUtilizationRatioMetricName))
     {
         return(MetricConstants.BytesSentUtilizationRatioMetricDisplayName); // global metrics.
     }
     else
     {
         return(MetricConstants.TotalRequestsMetricName);
     }
 }