Skip to content

Commit

Permalink
Check length of binary estimator to find overflow (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahsivjar authored Jul 28, 2023
1 parent 165b0f9 commit 1a9fbd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions aggregators/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func CombinedMetricsToBatch(

batchSize := 0
// service_summary overflow metric
if cm.OverflowServiceInstancesEstimator != nil {
if len(cm.OverflowServiceInstancesEstimator) > 0 {
batchSize++
}

Expand All @@ -156,13 +156,13 @@ func CombinedMetricsToBatch(
if sm.OverflowGroups == nil {
continue
}
if sm.OverflowGroups.OverflowTransactionsEstimator != nil {
if len(sm.OverflowGroups.OverflowTransactionsEstimator) > 0 {
batchSize++
}
if sm.OverflowGroups.OverflowServiceTransactionsEstimator != nil {
if len(sm.OverflowGroups.OverflowServiceTransactionsEstimator) > 0 {
batchSize++
}
if sm.OverflowGroups.OverflowSpansEstimator != nil {
if len(sm.OverflowGroups.OverflowSpansEstimator) > 0 {
batchSize++
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func CombinedMetricsToBatch(
if sm.OverflowGroups == nil {
continue
}
if sm.OverflowGroups.OverflowTransactionsEstimator != nil {
if len(sm.OverflowGroups.OverflowTransactionsEstimator) > 0 {
estimator := hllSketch(sm.OverflowGroups.OverflowTransactionsEstimator)
event := getBaseEvent(sk)
overflowTxnMetricsToAPMEvent(
Expand All @@ -225,7 +225,7 @@ func CombinedMetricsToBatch(
)
b = append(b, event)
}
if sm.OverflowGroups.OverflowServiceTransactionsEstimator != nil {
if len(sm.OverflowGroups.OverflowServiceTransactionsEstimator) > 0 {
estimator := hllSketch(
sm.OverflowGroups.OverflowServiceTransactionsEstimator,
)
Expand All @@ -239,7 +239,7 @@ func CombinedMetricsToBatch(
)
b = append(b, event)
}
if sm.OverflowGroups.OverflowSpansEstimator != nil {
if len(sm.OverflowGroups.OverflowSpansEstimator) > 0 {
estimator := hllSketch(sm.OverflowGroups.OverflowSpansEstimator)
event := getBaseEvent(sk)
overflowSpanMetricsToAPMEvent(
Expand All @@ -252,7 +252,7 @@ func CombinedMetricsToBatch(
b = append(b, event)
}
}
if cm.OverflowServiceInstancesEstimator != nil {
if len(cm.OverflowServiceInstancesEstimator) > 0 {
estimator := hllSketch(cm.OverflowServiceInstancesEstimator)
getOverflowBaseEvent := func() *modelpb.APMEvent {
return &modelpb.APMEvent{
Expand All @@ -270,7 +270,7 @@ func CombinedMetricsToBatch(
aggIntervalStr,
)
b = append(b, event)
if cm.OverflowServices.OverflowTransactionsEstimator != nil {
if len(cm.OverflowServices.OverflowTransactionsEstimator) > 0 {
estimator := hllSketch(cm.OverflowServices.OverflowTransactionsEstimator)
event := getOverflowBaseEvent()
overflowTxnMetricsToAPMEvent(
Expand All @@ -283,7 +283,7 @@ func CombinedMetricsToBatch(
b = append(b, event)

}
if cm.OverflowServices.OverflowServiceTransactionsEstimator != nil {
if len(cm.OverflowServices.OverflowServiceTransactionsEstimator) > 0 {
estimator := hllSketch(
cm.OverflowServices.OverflowServiceTransactionsEstimator,
)
Expand All @@ -297,7 +297,7 @@ func CombinedMetricsToBatch(
)
b = append(b, event)
}
if cm.OverflowServices.OverflowSpansEstimator != nil {
if len(cm.OverflowServices.OverflowSpansEstimator) > 0 {
estimator := hllSketch(cm.OverflowServices.OverflowSpansEstimator)
event := getOverflowBaseEvent()
overflowSpanMetricsToAPMEvent(
Expand Down
2 changes: 1 addition & 1 deletion aggregators/merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (m *combinedMetricsMerger) merge(from *aggregationpb.CombinedMetrics) {
}
// If there is overflow due to max services in either of the buckets being
// merged then we can merge the overflow buckets without considering any other scenarios.
if from.OverflowServiceInstancesEstimator != nil {
if len(from.OverflowServiceInstancesEstimator) > 0 {
mergeOverflow(&m.metrics.OverflowServices, from.OverflowServices)
mergeEstimator(
&m.metrics.OverflowServiceInstancesEstimator,
Expand Down

0 comments on commit 1a9fbd2

Please sign in to comment.