Skip to content

Commit

Permalink
Fix historic data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
razmser committed Nov 14, 2024
1 parent 8094ae8 commit a0d8e78
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions statshouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,8 @@ func (m *MetricRef) Count(n float64) {

func (m *MetricRef) CountHistoric(n float64, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.count += n
})
}
Expand Down Expand Up @@ -998,6 +1000,8 @@ func (m *MetricRef) Value(value float64) {

func (m *MetricRef) ValueHistoric(value float64, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.value = append(b.value, value)
})
}
Expand Down Expand Up @@ -1031,6 +1035,8 @@ func (m *MetricRef) Values(values []float64) {

func (m *MetricRef) ValuesHistoric(values []float64, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.value = append(b.value, values...)
})
}
Expand Down Expand Up @@ -1064,6 +1070,8 @@ func (m *MetricRef) Unique(value int64) {

func (m *MetricRef) UniqueHistoric(value int64, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.unique = append(b.unique, value)
})
}
Expand Down Expand Up @@ -1097,6 +1105,8 @@ func (m *MetricRef) Uniques(values []int64) {

func (m *MetricRef) UniquesHistoric(values []int64, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.unique = append(b.unique, values...)
})
}
Expand Down Expand Up @@ -1130,6 +1140,8 @@ func (m *MetricRef) StringTop(value string) {

func (m *MetricRef) StringTopHistoric(value string, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.stop = append(b.stop, value)
})
}
Expand Down Expand Up @@ -1163,6 +1175,8 @@ func (m *MetricRef) StringsTop(values []string) {

func (m *MetricRef) StringsTopHistoric(values []string, tsUnixSec uint32) {
m.write(tsUnixSec, func(b *bucket) {
b.k = m.k
b.kn = m.kn
b.stop = append(b.stop, values...)
})
}
Expand Down Expand Up @@ -1201,6 +1215,7 @@ func (m *MetricRef) write(tsUnixSec uint32, fn func(*bucket)) {
m.mu.Unlock()
var b bucket
fn(&b)
b.swapToSend(tsUnixSec)
c.transportMu.Lock()
b.send(c, tsUnixSec)
c.transportMu.Unlock()
Expand Down

0 comments on commit a0d8e78

Please sign in to comment.