From 91c44807d10afa8d0dff2f1d3f80d1bcea4501c5 Mon Sep 17 00:00:00 2001 From: Aaron Prindle Date: Sun, 2 May 2021 16:00:17 -0700 Subject: [PATCH] update otel libs from v0.13.0 -> v0.20.0 (#5757) What is the problem being solved? Part of #5756, adding opentelemetry trace information to skaffold commands. Updating out libs to the latest otel version adds additional useful functionality for tracing. Why is this the best approach? This approach uses go mod (updated via "go get ") and minor API changes to our otel API usage for the update. What other approaches did you consider? N/A What side effects will this approach have? There shouldn't be any side effects w/ this approach, the changes to otel's API were renaming/moving things (packages, functions, etc.). The only option removed was stdout Quantile aggregation (stdout.WithQuantiles) but I do not think this will have side effects. See https://github.com/open-telemetry/opentelemetry-go/commit/49f699d65742e144cf19b5dd28f3d3a0891bf200#diff-2b283a7fb9f9b66e31a2b51a9ae9cad3599650a633f02fea9a956c4f6a714c6c What future work remains to be done? N/A --- go.mod | 16 ++-- go.sum | 31 +++++--- pkg/skaffold/instrumentation/export.go | 81 +++++++++++---------- pkg/skaffold/instrumentation/export_test.go | 31 ++++---- 4 files changed, 84 insertions(+), 75 deletions(-) diff --git a/go.mod b/go.mod index 254d48f09ac..7493b3fcfe6 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cloud.google.com/go v0.72.0 cloud.google.com/go/storage v1.10.0 github.com/AlecAivazis/survey/v2 v2.2.7 - github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.13.0 + github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.20.0 github.com/aws/aws-sdk-go v1.36.30 // indirect github.com/blang/semver v3.5.1+incompatible github.com/bmatcuk/doublestar v1.2.4 @@ -36,7 +36,7 @@ require ( github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e github.com/golang/protobuf v1.4.3 - github.com/google/go-cmp v0.5.4 + github.com/google/go-cmp v0.5.5 github.com/google/go-containerregistry v0.4.1-0.20210128200529-19c2b639fab1 github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20210216200643-d81088d9983e // indirect github.com/google/go-github v17.0.0+incompatible @@ -57,7 +57,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.0.1 github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/rjeczalik/notify v0.9.3-0.20201210012515-e2a77dcc14cf github.com/russross/blackfriday/v2 v2.0.1 @@ -65,12 +65,14 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.1.3 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.7.0 // indirect github.com/tektoncd/pipeline v0.5.1-0.20190731183258-9d7e37e85bf8 github.com/xeipuuv/gojsonschema v1.2.0 - go.opentelemetry.io/otel v0.13.0 - go.opentelemetry.io/otel/exporters/stdout v0.13.0 - go.opentelemetry.io/otel/sdk v0.13.0 + go.opentelemetry.io/otel v0.20.0 + go.opentelemetry.io/otel/exporters/stdout v0.20.0 + go.opentelemetry.io/otel/metric v0.20.0 + go.opentelemetry.io/otel/sdk v0.20.0 + go.opentelemetry.io/otel/sdk/metric v0.20.0 + go.opentelemetry.io/otel/trace v0.20.0 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect golang.org/x/mod v0.4.1 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect diff --git a/go.sum b/go.sum index cfee1763867..cb72dec0ee1 100644 --- a/go.sum +++ b/go.sum @@ -125,15 +125,13 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= -github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/Djarvur/go-err113 v0.1.0/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20191009163259-e802c2cb94ae/go.mod h1:mjwGPas4yKduTyubHvD1Atl9r1rUq8DfVy+gkVvZ+oo= github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534/go.mod h1:iroGtC8B3tQiqtds1l+mgk/BBOrxbqjH+eUfFQYRc14= github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20200415212048-7901bc822317/go.mod h1:DF8FZRxMHMGv/vP2lQP6h+dYzzjpuRn24VeRiYn3qjQ= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.13.0 h1:RbaN+/fPE1Rv/ZC/Z1vcD/qsd4XyYmzlTRqIPXnCAE0= -github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.13.0/go.mod h1:8MmJ2gqHtCH9fdAkpsnSYPdgn47SXsBodhYk6JfzA3M= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.20.0 h1:H4Hs0jLf0IcQ96dgx3gPFRke2zyjrzpYMecVsrWKrAc= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.20.0/go.mod h1:3DfYfW/GJ2p+Yd1vGImcFO1jKaqvZmAMMIdWk8BJsjw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= @@ -644,8 +642,9 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-containerregistry v0.0.0-20191010200024-a3d713f9b7f8/go.mod h1:KyKXa9ciM8+lgMXwOVsXi7UxGrsf9mM61Mzs+xKUrKE= github.com/google/go-containerregistry v0.1.2/go.mod h1:GPivBPgdAyd2SU+vf6EpsgOtWDuPqjW0hJZt4rNdTZ4= github.com/google/go-containerregistry v0.2.1/go.mod h1:Ts3Wioz1r5ayWx8sS6vLcWltWcM1aqFjd/eVrkFhrWM= @@ -1336,12 +1335,22 @@ go.opencensus.io v0.22.4-0.20200608061201-1901b56b9515/go.mod h1:yxeiOL68Rb0Xd1d go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= -go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel/exporters/stdout v0.13.0 h1:A+XiGIPQbGoJoBOJfKAKnZyiUSjSWvL3XWETUvtom5k= -go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= -go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ= -go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= +go.opentelemetry.io/otel v0.20.0 h1:eaP0Fqu7SXHwvjiqDq83zImeehOHX8doTvU9AwXON8g= +go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= +go.opentelemetry.io/otel/exporters/stdout v0.20.0 h1:NXKkOWV7Np9myYrQE0wqRS3SbwzbupHu07rDONKubMo= +go.opentelemetry.io/otel/exporters/stdout v0.20.0/go.mod h1:t9LUU3JvYlmoPA61abhvsXxKh58xdyi3nMtI6JiR8v0= +go.opentelemetry.io/otel/metric v0.20.0 h1:4kzhXFP+btKm4jwxpjIqjs41A7MakRFUS86bqLHTIw8= +go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= +go.opentelemetry.io/otel/oteltest v0.20.0 h1:HiITxCawalo5vQzdHfKeZurV8x7ljcqAgiWzF6Vaeaw= +go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= +go.opentelemetry.io/otel/sdk v0.20.0 h1:JsxtGXd06J8jrnya7fdI/U/MR6yXA5DtbZy+qoHQlr8= +go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= +go.opentelemetry.io/otel/sdk/export/metric v0.20.0 h1:c5VRjxCXdQlx1HjzwGdQHzZaVI82b5EbBgOu2ljD92g= +go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= +go.opentelemetry.io/otel/sdk/metric v0.20.0 h1:7ao1wpzHRVKf0OQ7GIxiQJA6X7DLX9o14gmVon7mMK8= +go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= +go.opentelemetry.io/otel/trace v0.20.0 h1:1DL6EXUdcg95gukhuRRvLDO/4X5THh/5dIV52lqtnbw= +go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= diff --git a/pkg/skaffold/instrumentation/export.go b/pkg/skaffold/instrumentation/export.go index 1967174797b..30667b4bf32 100644 --- a/pkg/skaffold/instrumentation/export.go +++ b/pkg/skaffold/instrumentation/export.go @@ -31,11 +31,12 @@ import ( "github.com/mitchellh/go-homedir" "github.com/rakyll/statik/fs" "github.com/sirupsen/logrus" - "go.opentelemetry.io/otel/api/global" - "go.opentelemetry.io/otel/api/metric" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/exporters/stdout" - "go.opentelemetry.io/otel/label" - "go.opentelemetry.io/otel/sdk/metric/controller/push" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/global" + "go.opentelemetry.io/otel/sdk/metric/controller/basic" "google.golang.org/api/option" "github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/statik" @@ -90,11 +91,11 @@ func exportMetrics(ctx context.Context, filename string, meter skaffoldMeter) er } start := time.Now() - p.Start() + p.Start(ctx) for _, m := range meters { createMetrics(ctx, m) } - p.Stop() + p.Stop(ctx) logrus.Debugf("metrics uploading complete in %s", time.Since(start).String()) if fileExists { @@ -103,7 +104,7 @@ func exportMetrics(ctx context.Context, filename string, meter skaffoldMeter) er return nil } -func initCloudMonitoringExporterMetrics() (*push.Controller, error) { +func initCloudMonitoringExporterMetrics() (*basic.Controller, error) { statikFS, err := statik.FS() if err != nil { return nil, err @@ -127,7 +128,7 @@ func initCloudMonitoringExporterMetrics() (*push.Controller, error) { return fmt.Sprintf("custom.googleapis.com/skaffold/%s", desc.Name()) } - global.SetErrorHandler(errHandler{}) + otel.SetErrorHandler(errHandler{}) return mexporter.InstallNewPipeline( []mexporter.Option{ mexporter.WithProjectID(c.ProjectID), @@ -140,14 +141,14 @@ func initCloudMonitoringExporterMetrics() (*push.Controller, error) { ) } -func devStdOutExporter() (*push.Controller, error) { +func devStdOutExporter() (*basic.Controller, error) { // export metrics to std out if local env is set. if _, ok := os.LookupEnv("SKAFFOLD_EXPORT_TO_STDOUT"); ok { - return stdout.InstallNewPipeline([]stdout.Option{ - stdout.WithQuantiles([]float64{0.5}), + _, controller, err := stdout.InstallNewPipeline([]stdout.Option{ stdout.WithPrettyPrint(), stdout.WithWriter(os.Stdout), }, nil) + return controller, err } return nil, nil } @@ -157,25 +158,25 @@ func createMetrics(ctx context.Context, meter skaffoldMeter) { // A metric is uniquely identified by the metric name and the labels and corresponding values // This random number is used as a label to differentiate the metrics per user so if two users // run `skaffold build` at the same time they will both have their metrics recorded - randLabel := label.String("randomizer", strconv.Itoa(rand.Intn(75000))) + randLabel := attribute.String("randomizer", strconv.Itoa(rand.Intn(75000))) m := global.Meter("skaffold") // cloud monitoring only supports string type labels - labels := []label.KeyValue{ - label.String("version", meter.Version), - label.String("os", meter.OS), - label.String("arch", meter.Arch), - label.String("command", meter.Command), - label.String("error", meter.ErrorCode.String()), - label.String("platform_type", meter.PlatformType), - label.String("config_count", strconv.Itoa(meter.ConfigCount)), + labels := []attribute.KeyValue{ + attribute.String("version", meter.Version), + attribute.String("os", meter.OS), + attribute.String("arch", meter.Arch), + attribute.String("command", meter.Command), + attribute.String("error", meter.ErrorCode.String()), + attribute.String("platform_type", meter.PlatformType), + attribute.String("config_count", strconv.Itoa(meter.ConfigCount)), } - sharedLabels := []label.KeyValue{ + sharedLabels := []attribute.KeyValue{ randLabel, } if _, ok := allowedUsers[meter.User]; ok { - sharedLabels = append(sharedLabels, label.String("user", meter.User)) + sharedLabels = append(sharedLabels, attribute.String("user", meter.User)) } labels = append(labels, sharedLabels...) @@ -201,24 +202,24 @@ func createMetrics(ctx context.Context, meter skaffoldMeter) { } } -func flagMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, randLabel label.KeyValue) { +func flagMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, randLabel attribute.KeyValue) { flagCounter := metric.Must(m).NewInt64ValueRecorder("flags", metric.WithDescription("Tracks usage of enum flags")) for k, v := range meter.EnumFlags { - labels := []label.KeyValue{ - label.String("flag_name", k), - label.String("flag_value", v), - label.String("command", meter.Command), - label.String("error", meter.ErrorCode.String()), + labels := []attribute.KeyValue{ + attribute.String("flag_name", k), + attribute.String("flag_value", v), + attribute.String("command", meter.Command), + attribute.String("error", meter.ErrorCode.String()), randLabel, } flagCounter.Record(ctx, 1, labels...) } } -func commandMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...label.KeyValue) { +func commandMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...attribute.KeyValue) { commandCounter := metric.Must(m).NewInt64ValueRecorder(meter.Command, metric.WithDescription(fmt.Sprintf("Number of times %s is used", meter.Command))) - labels = append(labels, label.String("error", meter.ErrorCode.String())) + labels = append(labels, attribute.String("error", meter.ErrorCode.String())) commandCounter.Record(ctx, 1, labels...) if meter.Command == "dev" || meter.Command == "debug" { @@ -238,42 +239,42 @@ func commandMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, la for errorCode, count := range errorCounts { iterationCounter.Record(ctx, int64(count), append(labels, - label.String("intent", intention), - label.String("error", errorCode.String()), + attribute.String("intent", intention), + attribute.String("error", errorCode.String()), )...) } } } } -func deployerMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...label.KeyValue) { +func deployerMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...attribute.KeyValue) { deployerCounter := metric.Must(m).NewInt64ValueRecorder("deployer", metric.WithDescription("Deployers used")) for _, deployer := range meter.Deployers { - deployerCounter.Record(ctx, 1, append(labels, label.String("deployer", deployer))...) + deployerCounter.Record(ctx, 1, append(labels, attribute.String("deployer", deployer))...) } if meter.HelmReleasesCount > 0 { multiReleasesCounter := metric.Must(m).NewInt64ValueRecorder("helmReleases", metric.WithDescription("Multiple helm releases used")) - multiReleasesCounter.Record(ctx, 1, append(labels, label.Int("count", meter.HelmReleasesCount))...) + multiReleasesCounter.Record(ctx, 1, append(labels, attribute.Int("count", meter.HelmReleasesCount))...) } } -func builderMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...label.KeyValue) { +func builderMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...attribute.KeyValue) { builderCounter := metric.Must(m).NewInt64ValueRecorder("builders", metric.WithDescription("Builders used")) artifactCounter := metric.Must(m).NewInt64ValueRecorder("artifacts", metric.WithDescription("Number of artifacts used")) dependenciesCounter := metric.Must(m).NewInt64ValueRecorder("artifact-dependencies", metric.WithDescription("Number of artifacts with dependencies")) for builder, count := range meter.Builders { - bLabel := label.String("builder", builder) + bLabel := attribute.String("builder", builder) builderCounter.Record(ctx, 1, append(labels, bLabel)...) artifactCounter.Record(ctx, int64(count), append(labels, bLabel)...) dependenciesCounter.Record(ctx, int64(meter.BuildDependencies[builder]), append(labels, bLabel)...) } } -func errorMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...label.KeyValue) { +func errorMetrics(ctx context.Context, meter skaffoldMeter, m metric.Meter, labels ...attribute.KeyValue) { errCounter := metric.Must(m).NewInt64ValueRecorder("errors", metric.WithDescription("Skaffold errors")) - errCounter.Record(ctx, 1, append(labels, label.String("error", meter.ErrorCode.String()))...) + errCounter.Record(ctx, 1, append(labels, attribute.String("error", meter.ErrorCode.String()))...) - labels = append(labels, label.String("command", meter.Command)) + labels = append(labels, attribute.String("command", meter.Command)) switch meter.ErrorCode { case proto.StatusCode_UNKNOWN_ERROR: diff --git a/pkg/skaffold/instrumentation/export_test.go b/pkg/skaffold/instrumentation/export_test.go index 455251f0ef5..91df8f8d530 100644 --- a/pkg/skaffold/instrumentation/export_test.go +++ b/pkg/skaffold/instrumentation/export_test.go @@ -28,7 +28,7 @@ import ( "time" "go.opentelemetry.io/otel/exporters/stdout" - "go.opentelemetry.io/otel/sdk/metric/controller/push" + "go.opentelemetry.io/otel/sdk/metric/controller/basic" "github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/statik" "github.com/GoogleContainerTools/skaffold/proto/v1" @@ -162,12 +162,12 @@ func TestExportMetrics(t *testing.T) { if err != nil { t.Error(err) } - t.Override(&initExporter, func() (*push.Controller, error) { - return stdout.InstallNewPipeline([]stdout.Option{ - stdout.WithQuantiles([]float64{0.5}), + t.Override(&initExporter, func() (*basic.Controller, error) { + _, controller, err := stdout.InstallNewPipeline([]stdout.Option{ stdout.WithPrettyPrint(), stdout.WithWriter(tmpFile), }, nil) + return controller, err }) } if len(test.savedMetrics) > 0 { @@ -320,12 +320,12 @@ func TestUserMetricReported(t *testing.T) { if err != nil { t.Error(err) } - t.Override(&initExporter, func() (*push.Controller, error) { - return stdout.InstallNewPipeline([]stdout.Option{ - stdout.WithQuantiles([]float64{0.5}), + t.Override(&initExporter, func() (*basic.Controller, error) { + _, controller, err := stdout.InstallNewPipeline([]stdout.Option{ stdout.WithPrettyPrint(), stdout.WithWriter(tmpFile), }, nil) + return controller, err }) _ = exportMetrics(context.Background(), tmp.Path(filename), test.meter) @@ -459,15 +459,12 @@ func checkUser(t *testutil.T, user string, b []byte) { // Derived from go.opentelemetry.io/otel/exporters/stdout/metric.go type line struct { - Name string `json:"Name"` - Count interface{} `json:"Count,omitempty"` - Quantiles []quantile `json:"Quantiles,omitempty"` - Labels map[string]string -} - -type quantile struct { - Quantile interface{} `json:"Quantile"` - Value interface{} `json:"Value"` + Name string `json:"Name"` + Min interface{} `json:"Min,omitempty"` + Max interface{} `json:"Max,omitempty"` + Sum interface{} `json:"Sum,omitempty"` + Count interface{} `json:"Count,omitempty"` + Labels map[string]string } func (l *line) initLine() { @@ -484,5 +481,5 @@ func (l *line) initLine() { } func (l *line) value() interface{} { - return l.Quantiles[0].Value + return l.Max }