From bf636aa3a4a6e92c4193a8956745285ac533e08c Mon Sep 17 00:00:00 2001 From: Robert Grandl Date: Fri, 12 Jul 2024 11:10:49 -0700 Subject: [PATCH] Update weaver version and buckets --- examples/echo/echo.go | 2 +- examples/echo/weaver_gen.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/store/metrics.go | 20 ++++++++++++++++++-- internal/tool/testprogram/weaver_gen.go | 2 +- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/echo/echo.go b/examples/echo/echo.go index d8d48bb..66c3ac7 100644 --- a/examples/echo/echo.go +++ b/examples/echo/echo.go @@ -28,7 +28,7 @@ import ( var stringLength = metrics.NewHistogram( "echo_string_length", "The length of strings passed to the Echo method", - metrics.NonNegativeBuckets, + []float64{1, 10, 100, 1000, 10000, 100000, 1000000}, ) type echoOptions struct { diff --git a/examples/echo/weaver_gen.go b/examples/echo/weaver_gen.go index 36c5259..d28ad8f 100644 --- a/examples/echo/weaver_gen.go +++ b/examples/echo/weaver_gen.go @@ -176,7 +176,7 @@ var _ weaver.Main = (*main_client_stub)(nil) // you run "go build" or "go run". var _ codegen.LatestVersion = codegen.Version[[0][24]struct{}](` -ERROR: You generated this file with 'weaver generate' v0.24.2 (codegen +ERROR: You generated this file with 'weaver generate' v0.24.3 (codegen version v0.24.0). The generated code is incompatible with the version of the github.com/ServiceWeaver/weaver module that you're using. The weaver module version can be found in your go.mod file or by running the following command. diff --git a/go.mod b/go.mod index ffee840..2f2f8c9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( cloud.google.com/go/monitoring v1.15.1 cloud.google.com/go/security v1.15.1 github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.11.0 - github.com/ServiceWeaver/weaver v0.24.2 + github.com/ServiceWeaver/weaver v0.24.3 github.com/golang/protobuf v1.5.3 github.com/google/cel-go v0.17.1 github.com/google/go-cmp v0.5.9 diff --git a/go.sum b/go.sum index 9e85476..4ec4f29 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,8 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0 github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.35.0/go.mod h1:/u5+zrOXintMHE97lVsaKZpwDIfGOBClYrCD/borbi8= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.35.0 h1:vjtrvX7B3S+uqTIOvOUfqsMCa3eEtEOOQWm7ERI1pxg= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.35.0/go.mod h1:H785fvlgotVZqht+1rHhXSs8EJ8uPVmpBYkTYO3ccpc= -github.com/ServiceWeaver/weaver v0.24.2 h1:GXapIUCLlN8YYLjH2fvbw0lR77wM5uZOrvCBNG8YZYE= -github.com/ServiceWeaver/weaver v0.24.2/go.mod h1:twEFAFbylAXe9l1Zc5qrLOBfQvw2dKAGVFOyPzS0tFE= +github.com/ServiceWeaver/weaver v0.24.3 h1:pLF0k9TtAJDwJLr2653HU0LM+91AlklxK+Rzlu7bEoA= +github.com/ServiceWeaver/weaver v0.24.3/go.mod h1:twEFAFbylAXe9l1Zc5qrLOBfQvw2dKAGVFOyPzS0tFE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= diff --git a/internal/store/metrics.go b/internal/store/metrics.go index 26c7e0c..1d068a6 100644 --- a/internal/store/metrics.go +++ b/internal/store/metrics.go @@ -37,17 +37,33 @@ var ( requestLatencies = metrics.NewHistogramMap[storeLabels]( "serviceweaver_store_request_latency_micros", "Latency of store requests, in microseconds, by operation", - metrics.NonNegativeBuckets, + generatedBuckets, ) valueSizes = metrics.NewHistogramMap[storeLabels]( "serviceweaver_store_value_size_bytes", "Size of values, in bytes, by operation", - metrics.NonNegativeBuckets, + generatedBuckets, ) staleCounts = metrics.NewCounterMap[storeLabels]( "serviceweaver_store_stale_count", "Number of stale puts", ) + + // generatedBuckets provides rounded bucket boundaries for histograms + // that will only store non-negative values. + generatedBuckets = []float64{ + // Adjacent buckets differ from each other by 2x or 2.5x. + 1, 2, 5, + 10, 20, 50, + 100, 200, 500, + 1000, 2000, 5000, + 10000, 20000, 50000, + 100000, 200000, 500000, + 1000000, 2000000, 5000000, + 10000000, 20000000, 50000000, + 100000000, 200000000, 500000000, + 1000000000, 2000000000, 5000000000, // i.e., 5e9 + } ) // WithMetrics returns the provided store, but with methods augmented to update diff --git a/internal/tool/testprogram/weaver_gen.go b/internal/tool/testprogram/weaver_gen.go index e0dccfc..eb96ca2 100644 --- a/internal/tool/testprogram/weaver_gen.go +++ b/internal/tool/testprogram/weaver_gen.go @@ -61,7 +61,7 @@ var _ weaver.Main = (*main_client_stub)(nil) // you run "go build" or "go run". var _ codegen.LatestVersion = codegen.Version[[0][24]struct{}](` -ERROR: You generated this file with 'weaver generate' v0.24.2 (codegen +ERROR: You generated this file with 'weaver generate' v0.24.3 (codegen version v0.24.0). The generated code is incompatible with the version of the github.com/ServiceWeaver/weaver module that you're using. The weaver module version can be found in your go.mod file or by running the following command.