diff --git a/examples/echo/echo.go b/examples/echo/echo.go index d8d48bb..769debd 100644 --- a/examples/echo/echo.go +++ b/examples/echo/echo.go @@ -20,6 +20,7 @@ import ( "regexp" "github.com/ServiceWeaver/weaver" + "github.com/ServiceWeaver/weaver-gke/internal/store" "github.com/ServiceWeaver/weaver/metrics" ) @@ -28,7 +29,7 @@ import ( var stringLength = metrics.NewHistogram( "echo_string_length", "The length of strings passed to the Echo method", - metrics.NonNegativeBuckets, + store.GeneratedBuckets, ) type echoOptions struct { diff --git a/examples/echo/weaver_gen.go b/examples/echo/weaver_gen.go index 36c5259..9bb6fb4 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.6 (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..79e1c62 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.6 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..7cdcf2c 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.6 h1:KSIbxVabeT8nGbdn5hrzk+FZ8TDoafj1RXhV9Wf+O7U= +github.com/ServiceWeaver/weaver v0.24.6/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..6638b39 100644 --- a/internal/store/metrics.go +++ b/internal/store/metrics.go @@ -37,12 +37,12 @@ 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", @@ -141,3 +141,22 @@ func (m *metricsWrapper) Delete(ctx context.Context, key string) error { func (m *metricsWrapper) List(ctx context.Context, opts ListOptions) ([]string, error) { return m.store.List(ctx, opts) } + +// GeneratedBuckets provides rounded bucket boundaries for histograms +// that will only store non-negative values. +// +// Note that these buckets are intended to be used only by the metrics generated +// by the weaver runtime. +var 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 +} diff --git a/internal/tool/testprogram/weaver_gen.go b/internal/tool/testprogram/weaver_gen.go index e0dccfc..c234637 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.6 (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.