diff --git a/aggregators/aggregator_test.go b/aggregators/aggregator_test.go index 12631b2..f617e08 100644 --- a/aggregators/aggregator_test.go +++ b/aggregators/aggregator_test.go @@ -313,14 +313,14 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(count), + DocCount: uint64(count), }, Span: &modelpb.Span{ Name: "service-A:" + destinationX, DestinationService: &modelpb.DestinationService{ Resource: destinationX, ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count) * duration), }, }, @@ -341,14 +341,14 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(count), + DocCount: uint64(count), }, Span: &modelpb.Span{ Name: "service-A:" + destinationZ, DestinationService: &modelpb.DestinationService{ Resource: destinationZ, ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count) * duration), }, }, @@ -369,14 +369,14 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(3 * count), + DocCount: uint64(3 * count), }, Span: &modelpb.Span{ Name: "service-A:" + destinationZ, DestinationService: &modelpb.DestinationService{ Resource: destinationZ, ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(3 * count), + Count: uint64(3 * count), Sum: durationpb.New(time.Duration(3*count) * duration), }, }, @@ -397,14 +397,14 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(count), + DocCount: uint64(count), }, Span: &modelpb.Span{ Name: "service-B:" + destinationZ, DestinationService: &modelpb.DestinationService{ Resource: destinationZ, ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count) * duration), }, }, @@ -455,13 +455,13 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(count), + DocCount: uint64(count), }, Span: &modelpb.Span{ Name: "service-A:", DestinationService: &modelpb.DestinationService{ ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count) * duration), }, }, @@ -500,14 +500,14 @@ func TestAggregateSpanMetrics(t *testing.T) { Metricset: &modelpb.Metricset{ Name: "service_destination", Interval: formatDuration(ivl), - DocCount: int64(count), + DocCount: uint64(count), }, Span: &modelpb.Span{ Name: "service-A:" + destinationZ, DestinationService: &modelpb.DestinationService{ Resource: destinationZ, ResponseTime: &modelpb.AggregatedDuration{ - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count) * duration), }, }, @@ -896,7 +896,7 @@ func TestAggregateAndHarvest(t *testing.T) { }, DurationHistogram: &modelpb.Histogram{ Values: []float64{100351}, - Counts: []int64{1}, + Counts: []uint64{1}, }, }, Service: &modelpb.Service{ @@ -952,7 +952,7 @@ func TestAggregateAndHarvest(t *testing.T) { }, DurationHistogram: &modelpb.Histogram{ Values: []float64{100351}, - Counts: []int64{1}, + Counts: []uint64{1}, }, }, Service: &modelpb.Service{ diff --git a/aggregators/converter.go b/aggregators/converter.go index f1f0dd9..d19925e 100644 --- a/aggregators/converter.go +++ b/aggregators/converter.go @@ -838,7 +838,7 @@ func svcTxnMetricsToAPMEvent( baseEvent.Event.SuccessCount = modelpb.SummaryMetricFromVTPool() } baseEvent.Event.SuccessCount.Count = - int64(math.Round(metrics.SuccessCount + metrics.FailureCount)) + uint64(math.Round(metrics.SuccessCount + metrics.FailureCount)) baseEvent.Event.SuccessCount.Sum = math.Round(metrics.SuccessCount) } @@ -863,7 +863,7 @@ func spanMetricsToAPMEvent( baseEvent.Metricset = modelpb.MetricsetFromVTPool() } baseEvent.Metricset.Name = spanMetricsetName - baseEvent.Metricset.DocCount = int64(math.Round(metrics.Count)) + baseEvent.Metricset.DocCount = uint64(math.Round(metrics.Count)) baseEvent.Metricset.Interval = intervalStr if baseEvent.Span == nil { @@ -880,7 +880,7 @@ func spanMetricsToAPMEvent( modelpb.AggregatedDurationFromVTPool() } baseEvent.Span.DestinationService.ResponseTime.Count = - int64(math.Round(metrics.Count)) + uint64(math.Round(metrics.Count)) baseEvent.Span.DestinationService.ResponseTime.Sum = durationpb.New(time.Duration(math.Round(metrics.Sum))) @@ -995,7 +995,7 @@ func overflowSpanMetricsToAPMEvent( baseEvent.Metricset = modelpb.MetricsetFromVTPool() } baseEvent.Metricset.Samples = append(baseEvent.Metricset.Samples, sample) - baseEvent.Metricset.DocCount = int64(overflowCount) + baseEvent.Metricset.DocCount = overflowCount } func marshalEventGlobalLabels(e *modelpb.APMEvent) ([]byte, error) { diff --git a/aggregators/converter_test.go b/aggregators/converter_test.go index 792e37b..ead44de 100644 --- a/aggregators/converter_test.go +++ b/aggregators/converter_test.go @@ -685,7 +685,7 @@ func createTestServiceTransactionMetric( Event: &modelpb.Event{ SuccessCount: &modelpb.SummaryMetric{ // test code generates all success events - Count: int64(count), + Count: uint64(count), Sum: float64(count), }, }, @@ -720,7 +720,7 @@ func createTestSpanMetric( Name: "service_destination", Interval: formatDuration(ivl), Samples: metricsetSamples, - DocCount: int64(count), + DocCount: uint64(count), }, Service: &modelpb.Service{ Name: svcName, @@ -732,7 +732,7 @@ func createTestSpanMetric( Resource: span.Resource, ResponseTime: &modelpb.AggregatedDuration{ // test code generates 1 count for 1 ns - Count: int64(count), + Count: uint64(count), Sum: durationpb.New(time.Duration(count)), }, }, diff --git a/aggregators/internal/hdrhistogram/hdrhistogram.go b/aggregators/internal/hdrhistogram/hdrhistogram.go index 7f91f94..229dba0 100644 --- a/aggregators/internal/hdrhistogram/hdrhistogram.go +++ b/aggregators/internal/hdrhistogram/hdrhistogram.go @@ -117,11 +117,11 @@ func (h *HistogramRepresentation) Merge(from *HistogramRepresentation) { // Buckets converts the histogram into ordered slices of counts // and values per bar along with the total count. -func (h *HistogramRepresentation) Buckets() (int64, []int64, []float64) { - counts := make([]int64, 0, h.CountsRep.Len()) +func (h *HistogramRepresentation) Buckets() (uint64, []uint64, []float64) { + counts := make([]uint64, 0, h.CountsRep.Len()) values := make([]float64, 0, h.CountsRep.Len()) - var totalCount int64 + var totalCount uint64 var prevBucket int32 iter := h.iterator() iter.nextCountAtIdx() @@ -130,7 +130,7 @@ func (h *HistogramRepresentation) Buckets() (int64, []int64, []float64) { return } if iter.advance(int(bucket - prevBucket)) { - count := int64(math.Round(float64(scaledCounts) / histogramCountScale)) + count := uint64(math.Round(float64(scaledCounts) / histogramCountScale)) counts = append(counts, count) values = append(values, float64(iter.highestEquivalentValue)) totalCount += count diff --git a/aggregators/internal/hdrhistogram/hdrhistogram_test.go b/aggregators/internal/hdrhistogram/hdrhistogram_test.go index 8a17b54..c028caa 100644 --- a/aggregators/internal/hdrhistogram/hdrhistogram_test.go +++ b/aggregators/internal/hdrhistogram/hdrhistogram_test.go @@ -34,17 +34,17 @@ func TestMerge(t *testing.T) { } func TestBuckets(t *testing.T) { - buckets := func(h *hdrhistogram.Histogram) (int64, []int64, []float64) { + buckets := func(h *hdrhistogram.Histogram) (uint64, []uint64, []float64) { distribution := h.Distribution() - counts := make([]int64, 0, len(distribution)) + counts := make([]uint64, 0, len(distribution)) values := make([]float64, 0, len(distribution)) - var totalCount int64 + var totalCount uint64 for _, b := range distribution { if b.Count <= 0 { continue } - count := int64(math.Round(float64(b.Count) / histogramCountScale)) + count := uint64(math.Round(float64(b.Count) / histogramCountScale)) counts = append(counts, count) values = append(values, float64(b.To)) totalCount += count diff --git a/go.mod b/go.mod index 073ec11..47ee3fd 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/axiomhq/hyperloglog v0.0.0-20230201085229-3ddf4bad03dc github.com/cespare/xxhash/v2 v2.2.0 github.com/cockroachdb/pebble v0.0.0-20230627193317-c807f60529a3 - github.com/elastic/apm-data v0.1.1-0.20230728063148-1076ea8b4db0 + github.com/elastic/apm-data v0.1.1-0.20230803060036-9180b59d7888 github.com/google/go-cmp v0.5.9 github.com/stretchr/testify v1.8.4 go.elastic.co/apm/module/apmotel/v2 v2.4.3 diff --git a/go.sum b/go.sum index f69dfa6..66f3cc6 100644 --- a/go.sum +++ b/go.sum @@ -103,8 +103,8 @@ github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsY github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= -github.com/elastic/apm-data v0.1.1-0.20230728063148-1076ea8b4db0 h1:dJEhfgmABnNyC//PM/CDCEEMg5l6I+KjHGDR6o1WMx4= -github.com/elastic/apm-data v0.1.1-0.20230728063148-1076ea8b4db0/go.mod h1:lMTMoCWNadiDJih/tLechuMTtumEeedtKJlBOYAv030= +github.com/elastic/apm-data v0.1.1-0.20230803060036-9180b59d7888 h1:R2HpM1KxROvzvMHq/3XmuT/Y6oTcTteUFMJtQCP04GM= +github.com/elastic/apm-data v0.1.1-0.20230803060036-9180b59d7888/go.mod h1:lMTMoCWNadiDJih/tLechuMTtumEeedtKJlBOYAv030= github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO+s0= github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=