@@ -839,7 +839,7 @@ function renderThresholdResults(
839839 : formatter . decorate ( failMark , 'red' ) ;
840840
841841 const sourceText = formatter . decorate (
842- `'${ threshold . source } '` ,
842+ `'${ threshold . source . trim ( ) } '` ,
843843 'white' ,
844844 ) ;
845845
@@ -941,13 +941,16 @@ function renderMetricValueForThresholds(
941941 info ,
942942 formatter ,
943943) {
944- const { trendStats, trendCols, nonTrendValues, nonTrendExtras} = info ;
944+ const { trendStats, trendCols, trendKeys , nonTrendValues, nonTrendExtras} = info ;
945945 const thresholdAgg = threshold . source . split ( / [ = > < ] / ) [ 0 ] . trim ( ) ;
946946
947947 let value ;
948948 switch ( metric . type ) {
949949 case 'trend' :
950- value = trendCols [ metric . name ] [ trendStats . indexOf ( thresholdAgg ) ]
950+ const trendStatIndex = trendStats . indexOf ( thresholdAgg ) ;
951+ value = ( trendStatIndex !== - 1 )
952+ ? trendCols [ metric . name ] ?. [ trendStatIndex ]
953+ : trendKeys [ metric . name ] ?. [ thresholdAgg ] ;
951954 break ;
952955 case 'counter' :
953956 value = ( thresholdAgg === 'count' )
@@ -1042,6 +1045,7 @@ function renderTrendValue(value, stat, metric, options) {
10421045 * @property {Object } nonTrendValues - The non-trend metric values.
10431046 * @property {Object } nonTrendExtras - The non-trend metric extras.
10441047 * @property {Object } trendCols - The trend columns.
1048+ * @property {Object } trendKeys - The trend keys (values that aren't included within `trendStats`).
10451049 * @property {number[] } trendColMaxLens - The trend column maximum lengths.
10461050 * @property {number } numTrendColumns - The number of trend columns.
10471051 * @property {string[] } trendStats - The trend statistics.
@@ -1061,6 +1065,10 @@ function computeSummaryInfo(metrics, renderContext, options) {
10611065 const nonTrendExtras = { } ;
10621066 const trendCols = { } ;
10631067
1068+ // While "trendCols" contain the values for each "trendStats" aggregation (e.g. p(90) as a sorted array,
1069+ // "trendKeys" is used to store specific aggregation values that aren't part of "trendStats"; mainly for thresholds.
1070+ const trendKeys = { } ;
1071+
10641072 let maxNameWidth = 0 ;
10651073 let maxNonTrendValueLen = 0 ;
10661074 let nonTrendExtraMaxLens = [ ] ; // FIXME: "lens"?
@@ -1082,6 +1090,13 @@ function computeSummaryInfo(metrics, renderContext, options) {
10821090 maxNameWidth = Math . max ( maxNameWidth , strWidth ( displayName ) ) ;
10831091
10841092 if ( metric . type === 'trend' ) {
1093+ const keys = Object . keys ( metric . values ) . reduce ( ( acc , key ) => {
1094+ if ( ! trendStats . includes ( key ) ) {
1095+ acc [ key ] = renderTrendValue ( metric . values [ key ] , key , metric , options ) ;
1096+ }
1097+ return acc ;
1098+ } , { } ) ;
1099+
10851100 const cols = trendStats . map ( ( stat ) =>
10861101 renderTrendValue ( metric . values [ stat ] , stat , metric , options ) ,
10871102 ) ;
@@ -1094,6 +1109,7 @@ function computeSummaryInfo(metrics, renderContext, options) {
10941109 ) ;
10951110 } ) ;
10961111 trendCols [ name ] = cols ;
1112+ trendKeys [ name ] = keys ;
10971113 } else {
10981114 const values = nonTrendMetricValueForSum (
10991115 metric ,
@@ -1127,6 +1143,7 @@ function computeSummaryInfo(metrics, renderContext, options) {
11271143 nonTrendExtras,
11281144 trendCols,
11291145 trendColMaxLens,
1146+ trendKeys,
11301147 numTrendColumns,
11311148 trendStats,
11321149 maxNonTrendValueLen,
0 commit comments