@@ -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,15 +796,20 @@ 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 {
803805 if stat .Count == 0 {
804806 continue
805807 }
806808
809+ if stat .IsWatchAPI () {
810+ highLatency = true
811+ }
812+
807813 requestCount += stat .Count
808814
809815 if stat .Count == 1 {
@@ -814,7 +820,7 @@ func aggregateStats(stats []http.RequestStat) (int, *ddsketch.DDSketch) {
814820 latencies .MergeWith (scaled )
815821 }
816822 }
817- return requestCount , latencies
823+ return requestCount , latencies , highLatency
818824}
819825
820826func aggregateHTTPTraceObservations (httpObservations []http.TransactionObservation ) map [connKey ][]* model.HTTPTraceObservation {
@@ -1016,6 +1022,8 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10161022 return connStats
10171023 }
10181024
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}
10191027 for statKey , statsByCode := range httpStats {
10201028 for statusCodeClass := uint16 (100 ); statusCodeClass <= 500 ; statusCodeClass += 100 {
10211029 stat := statsByCode .Data [statusCodeClass ]
@@ -1030,6 +1038,7 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10301038
10311039 connStats = appendStatsForStatusGroup (connStats , statusCodeGroup , statKey , stat )
10321040
1041+ // Key: struct{Tuple} -> Value: map[struct{Path(optional), Method, StatusCode}][]struct{Latency, Count, StaticTags}
10331042 regroupedStats [connKey ] = connStats
10341043 }
10351044 }
@@ -1039,7 +1048,10 @@ func aggregateHTTPStats(httpStats map[http.Key]*http.RequestStats, sendForPath b
10391048 for connKey , statsByTags := range regroupedStats {
10401049 for tagsKey , stats := range statsByTags {
10411050 data := tagsKey .toMap ()
1042- requestCount , latencies := aggregateStats (stats )
1051+ requestCount , latencies , highLatency := aggregateStats (stats )
1052+ if highLatency {
1053+ data [httpHighLatencyTag ] = "true"
1054+ }
10431055 result [connKey ] = append (result [connKey ],
10441056 makeConnectionMetricWithNumber (
10451057 httpRequestsDelta , data ,
0 commit comments