@@ -742,9 +742,10 @@ const (
742742 httpResponseTime metricName = "http_response_time_seconds"
743743 httpRequestsDelta metricName = "http_requests_delta"
744744
745- httpStatusCodeTag = "code"
746- httpPathTag = "path"
747- httpMethodTag = "method"
745+ httpStatusCodeTag = "code"
746+ httpPathTag = "path"
747+ httpMethodTag = "method"
748+ httpHighLatencyTag = "known_high_latency"
748749
749750 mongoResponseTime metricName = "mongo_response_time_seconds"
750751 mongoRequestsDelta metricName = "mongo_requests_delta"
@@ -795,25 +796,31 @@ func (k aggStatsKey) toMap() map[string]string {
795796// We need to transform the nanoseconds to seconds here
796797const nsToS float64 = 0.000000001
797798
798- func aggregateStats (stats []http.RequestStat ) (int , * ddsketch.DDSketch ) {
799+ func aggregateStats (stats []http.RequestStat ) (int , * ddsketch.DDSketch , bool ) {
799800 requestCount := 0
800801 latencies := emptySketch ()
802+ highLatency := false
801803
802804 for _ , stat := range stats {
803- requestCount += stat .Count
804805 if stat .Count == 0 {
805806 continue
806- } else if stat .Count == 1 {
807+ }
808+
809+ if stat .IsWatchAPI () {
810+ highLatency = true
811+ }
812+
813+ requestCount += stat .Count
814+
815+ if stat .Count == 1 {
807816 latencies .Add (stat .FirstLatencySample * nsToS )
808- } else {
809- if stat .Latencies != nil {
810- var scaled = emptySketch ()
811- scaled = stat .Latencies .ChangeMapping (scaled .IndexMapping , scaled .GetPositiveValueStore (), scaled .GetNegativeValueStore (), nsToS )
812- latencies .MergeWith (scaled )
813- }
817+ } else if stat .Latencies != nil {
818+ var scaled = emptySketch ()
819+ scaled = stat .Latencies .ChangeMapping (scaled .IndexMapping , scaled .GetPositiveValueStore (), scaled .GetNegativeValueStore (), nsToS )
820+ latencies .MergeWith (scaled )
814821 }
815822 }
816- return requestCount , latencies
823+ return requestCount , latencies , highLatency
817824}
818825
819826func aggregateHTTPTraceObservations (httpObservations []http.TransactionObservation ) map [connKey ][]* model.HTTPTraceObservation {
@@ -1015,6 +1022,8 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10151022 return connStats
10161023 }
10171024
1025+ // httpStats has the following structure: (coming from datadog tracer)
1026+ // Key: struct{Tuple, Path, Method} -> Value: map[code(100/200/300/...)]struct{Latency, Count, StaticTags}
10181027 for statKey , statsByCode := range httpStats {
10191028 for statusCodeClass := uint16 (100 ); statusCodeClass <= 500 ; statusCodeClass += 100 {
10201029 stat := statsByCode .Data [statusCodeClass ]
@@ -1024,14 +1033,12 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10241033 }
10251034
10261035 statusCodeGroup := statusCodeClassToString (statusCodeClass )
1027- if statusCodeGroup == "" {
1028- continue
1029- }
10301036 connKey := getConnectionKeyForHTTPStats (statKey )
10311037 connStats := regroupedStats [connKey ]
10321038
10331039 connStats = appendStatsForStatusGroup (connStats , statusCodeGroup , statKey , stat )
10341040
1041+ // Key: struct{Tuple} -> Value: map[struct{Path(optional), Method, StatusCode}][]struct{Latency, Count, StaticTags}
10351042 regroupedStats [connKey ] = connStats
10361043 }
10371044 }
@@ -1041,7 +1048,10 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10411048 for connKey , statsByTags := range regroupedStats {
10421049 for tagsKey , stats := range statsByTags {
10431050 data := tagsKey .toMap ()
1044- requestCount , latencies := aggregateStats (stats )
1051+ requestCount , latencies , highLatency := aggregateStats (stats )
1052+ if highLatency {
1053+ data [httpHighLatencyTag ] = "true"
1054+ }
10451055 result [connKey ] = append (result [connKey ],
10461056 makeConnectionMetricWithNumber (
10471057 httpRequestsDelta , data ,
0 commit comments