Skip to content

Commit

Permalink
integration test and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinskiy committed Feb 21, 2025
1 parent 9adabdb commit 0716975
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ jobs:
version: v0.4.7
install-go: false
- run: go test -v ./...
statshouse-client-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- run: go run github.com/vkcom/statshouse/cmd/statshouse-client-test@f7765f65593fd613afbed14378fdd76bbeb78eaf --network=tcp
5 changes: 3 additions & 2 deletions client_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ func (m *MetricRef) write(tsUnixSec uint32, fn func(*bucket)) {
if !tsZeroOrEqual {
m.mu.Unlock()
b := bucket{
k: m.k,
kn: m.kn,
k: m.k,
kn: m.kn,
maxSize: c.maxBucketSize,
}
fn(&b)
b.swapToSend(tsUnixSec)
Expand Down
24 changes: 24 additions & 0 deletions statshouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ func ValueHistoric(name string, tags Tags, value float64, tsUnixSec uint32) {
globalClient.ValueHistoric(name, tags, value, tsUnixSec)
}

func Values(name string, tags Tags, values []float64) {
globalClient.Values(name, tags, values)
}

func ValuesHistoric(name string, tags Tags, values []float64, tsUnixSec uint32) {
globalClient.ValuesHistoric(name, tags, values, tsUnixSec)
}

func NamedValue(name string, tags NamedTags, value float64) {
globalClient.NamedValue(name, tags, value)
}
Expand All @@ -163,6 +171,14 @@ func NamedValueHistoric(name string, tags NamedTags, value float64, tsUnixSec ui
globalClient.NamedValueHistoric(name, tags, value, tsUnixSec)
}

func NamedValues(name string, tags NamedTags, values []float64) {
globalClient.NamedValues(name, tags, values)
}

func NamedValuesHistoric(name string, tags NamedTags, values []float64, tsUnixSec uint32) {
globalClient.NamedValuesHistoric(name, tags, values, tsUnixSec)
}

func Unique(name string, tags Tags, value int64) {
globalClient.Unique(name, tags, value)
}
Expand All @@ -183,6 +199,14 @@ func NamedUniqueHistoric(name string, tags NamedTags, value int64, tsUnixSec uin
globalClient.NamedUniqueHistoric(name, tags, value, tsUnixSec)
}

func NamedUniques(name string, tags NamedTags, values []int64) {
globalClient.NamedUniques(name, tags, values)
}

func NamedUniquesHistoric(name string, tags NamedTags, values []int64, tsUnixSec uint32) {
globalClient.NamedUniquesHistoric(name, tags, values, tsUnixSec)
}

func StringTop(name string, tags Tags, value string) {
globalClient.StringTop(name, tags, value)
}
Expand Down
38 changes: 38 additions & 0 deletions test_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"time"

"github.com/vkcom/statshouse-go"
)

func main() {
c := statshouse.NewClientEx(statshouse.ConfigureArgs{StatsHouseAddr: statshouse.DefaultAddr, Network: "tcp"})
defer c.Close()
var t statshouse.NamedTags
for i := 0; i < {{.NumberOfIterations}}; i++ {
{{- range $v := .Metrics }}
t = statshouse.NamedTags{
{{- range $i, $v := $v.Tags -}}
{{ if $i }}, {{ end }}{"{{ index $v 0 }}", "{{ index $v 1 }}"}
{{- end -}}
}
{{- if eq $v.Kind 2 }}
c.NamedUniquesHistoric("{{ $v.Name }}", t, []int64{
{{- range $i, $v := $v.Uniques -}}
{{ if $i }}, {{ end }}{{ $v }}
{{- end -}}
}, {{ $v.Timestamp }})
{{- else if eq $v.Kind 1 }}
c.NamedValuesHistoric("{{ $v.Name }}", t, []float64{
{{- range $i, $v := $v.Values -}}
{{ if $i }}, {{ end }}{{ $v }}
{{- end -}}
}, {{ $v.Timestamp }})
{{- else }}
c.NamedCountHistoric("{{ $v.Name }}", t, {{ printf "%.1f" $v.Count }}, {{ $v.Timestamp }})
{{- end }}
time.Sleep(time.Millisecond)
{{- end }}
}
}

0 comments on commit 0716975

Please sign in to comment.