From dfece3d2b97fd38ac9182db978dbacd953e58f4a Mon Sep 17 00:00:00 2001 From: Joshua MacDonald Date: Wed, 13 Jan 2021 14:07:44 -0800 Subject: [PATCH] Combine the Push and Pull metric controllers (#1378) * Push->basic * Repackage * Rename away from push * Make exporter optional; export from a separate goroutine * Move pull_test into controller_test * Precommit pass * New OTLP/Prom example * Precommit * Fix the example * Shorten the example * Test starting controller w/o exporter * Test export timeout * Remove ancient example & lint * go.mod revert & tidy * Comments * Tidy a diff * Tidy a diff * Move export kind selector in the new example * Split this test into its original parts * Reduce diff size * Changelog * Remove extra Add/Done pair * Remove unused stopCh param; document the Stop behavior * Typo * Use ctx * Missed v0.15 * Apply PR feedback * Precommit pass * 0.14 -> 0.15 in new file * Remove diff chunk markers * Fix OTLP example * Upstream * dashpole comments * aneurysm9 feedback * Tidy go.sum --- .github/dependabot.yml | 2 +- .gitignore | 6 +- CHANGELOG.md | 5 +- example/basic/go.mod | 15 - example/basic/go.sum | 17 - example/basic/main.go | 117 ----- example/otel-collector/main.go | 19 +- example/prom-collector/README.md | 3 + example/prom-collector/go.mod | 18 + example/prom-collector/go.sum | 443 ++++++++++++++++++ example/prom-collector/main.go | 123 +++++ exporters/metric/prometheus/example_test.go | 4 +- exporters/metric/prometheus/prometheus.go | 42 +- .../metric/prometheus/prometheus_test.go | 8 +- exporters/otlp/internal/otlptest/otlptest.go | 11 +- exporters/otlp/otlpgrpc/example_test.go | 29 +- exporters/stdout/example_test.go | 7 +- exporters/stdout/exporter.go | 24 +- sdk/metric/controller/basic/config.go | 120 +++++ .../controller/{push => basic}/config_test.go | 2 +- sdk/metric/controller/basic/controller.go | 308 ++++++++++++ .../controller/basic/controller_test.go | 352 ++++++++++++++ .../controller/{pull => basic}/pull_test.go | 31 +- .../controller/{push => basic}/push_test.go | 65 +-- sdk/metric/controller/pull/config.go | 64 --- sdk/metric/controller/pull/pull.go | 118 ----- sdk/metric/controller/push/config.go | 75 --- sdk/metric/controller/push/push.go | 153 ------ sdk/metric/sdk.go | 3 +- 29 files changed, 1510 insertions(+), 674 deletions(-) delete mode 100644 example/basic/go.mod delete mode 100644 example/basic/go.sum delete mode 100644 example/basic/main.go create mode 100644 example/prom-collector/README.md create mode 100644 example/prom-collector/go.mod create mode 100644 example/prom-collector/go.sum create mode 100644 example/prom-collector/main.go create mode 100644 sdk/metric/controller/basic/config.go rename sdk/metric/controller/{push => basic}/config_test.go (98%) create mode 100644 sdk/metric/controller/basic/controller.go create mode 100644 sdk/metric/controller/basic/controller_test.go rename sdk/metric/controller/{pull => basic}/pull_test.go (85%) rename sdk/metric/controller/{push => basic}/push_test.go (76%) delete mode 100644 sdk/metric/controller/pull/config.go delete mode 100644 sdk/metric/controller/pull/pull.go delete mode 100644 sdk/metric/controller/push/config.go delete mode 100644 sdk/metric/controller/push/push.go diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7c5633720..aa5a78781 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -48,7 +48,7 @@ updates: interval: weekly - package-ecosystem: gomod - directory: /example/basic + directory: /example/prom-collector labels: - dependencies - go diff --git a/.gitignore b/.gitignore index bae4b8ea4..068606829 100644 --- a/.gitignore +++ b/.gitignore @@ -10,10 +10,14 @@ coverage.* gen/ -/example/basic/basic +/example/grpc/client/client +/example/grpc/server/server +/example/http/client/client +/example/http/server/server /example/jaeger/jaeger /example/namedtracer/namedtracer /example/opencensus/opencensus /example/prometheus/prometheus +/example/prom-collector/prom-collector /example/zipkin/zipkin /example/otel-collector/otel-collector diff --git a/CHANGELOG.md b/CHANGELOG.md index d2cd98304..e50b85df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `SamplingResult` now passed a `Tracestate` from the parent `SpanContext` (#1432) - Moved gRPC driver for OTLP exporter to `exporters/otlp/otlpgrpc`. (#1420) - The `TraceContext` propagator now correctly propagates `TraceState` through the `SpanContext`. (#1447) +- Metric Push and Pull Controller components are combined into a single "basic" Controller: + - `WithExporter()` and `Start()` to configure Push behavior + - `Start()` is optional; use `Collect()` and `ForEach()` for Pull behavior + - `Start()` and `Stop()` accept Context. (#1378) ### Removed @@ -58,7 +62,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Bump `github.com/google/go-cmp` from 0.5.3 to 0.5.4 (#1374) - Bump `github.com/golangci/golangci-lint` in `/internal/tools` (#1375) - ### Fixed - Metric SDK `SumObserver` and `UpDownSumObserver` instruments correctness fixes. (#1381) diff --git a/example/basic/go.mod b/example/basic/go.mod deleted file mode 100644 index 98d079030..000000000 --- a/example/basic/go.mod +++ /dev/null @@ -1,15 +0,0 @@ -module go.opentelemetry.io/otel/example/basic - -go 1.14 - -replace ( - go.opentelemetry.io/otel => ../.. - go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - go.opentelemetry.io/otel/sdk => ../../sdk -) - -require ( - go.opentelemetry.io/otel v0.15.0 - go.opentelemetry.io/otel/exporters/stdout v0.15.0 - go.opentelemetry.io/otel/sdk v0.15.0 -) diff --git a/example/basic/go.sum b/example/basic/go.sum deleted file mode 100644 index ea37d8353..000000000 --- a/example/basic/go.sum +++ /dev/null @@ -1,17 +0,0 @@ -github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/example/basic/main.go b/example/basic/main.go deleted file mode 100644 index 865caedb8..000000000 --- a/example/basic/main.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "context" - "log" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/baggage" - "go.opentelemetry.io/otel/exporters/stdout" - "go.opentelemetry.io/otel/label" - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/sdk/metric/controller/push" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" - "go.opentelemetry.io/otel/sdk/metric/selector/simple" - sdktrace "go.opentelemetry.io/otel/sdk/trace" - "go.opentelemetry.io/otel/trace" -) - -var ( - fooKey = label.Key("ex.com/foo") - barKey = label.Key("ex.com/bar") - lemonsKey = label.Key("ex.com/lemons") - anotherKey = label.Key("ex.com/another") -) - -func main() { - exporter, err := stdout.NewExporter([]stdout.Option{ - stdout.WithPrettyPrint(), - }...) - if err != nil { - log.Fatalf("failed to initialize stdout export pipeline: %v", err) - } - - bsp := sdktrace.NewBatchSpanProcessor(exporter) - tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(bsp)) - defer func() { _ = tp.Shutdown(context.Background()) }() - pusher := push.New( - basic.New( - simple.NewWithExactDistribution(), - exporter, - ), - exporter, - ) - pusher.Start() - defer pusher.Stop() - otel.SetTracerProvider(tp) - otel.SetMeterProvider(pusher.MeterProvider()) - - // set global propagator to baggage (the default is no-op). - otel.SetTextMapPropagator(propagation.Baggage{}) - tracer := otel.Tracer("ex.com/basic") - meter := otel.Meter("ex.com/basic") - - commonLabels := []label.KeyValue{lemonsKey.Int(10), label.String("A", "1"), label.String("B", "2"), label.String("C", "3")} - - oneMetricCB := func(_ context.Context, result metric.Float64ObserverResult) { - result.Observe(1, commonLabels...) - } - _ = metric.Must(meter).NewFloat64ValueObserver("ex.com.one", oneMetricCB, - metric.WithDescription("A ValueObserver set to 1.0"), - ) - - valuerecorderTwo := metric.Must(meter).NewFloat64ValueRecorder("ex.com.two") - - ctx := context.Background() - ctx = baggage.ContextWithValues(ctx, fooKey.String("foo1"), barKey.String("bar1")) - - valuerecorder := valuerecorderTwo.Bind(commonLabels...) - defer valuerecorder.Unbind() - - err = func(ctx context.Context) error { - var span trace.Span - ctx, span = tracer.Start(ctx, "operation") - defer span.End() - - span.AddEvent("Nice operation!", trace.WithAttributes(label.Int("bogons", 100))) - span.SetAttributes(anotherKey.String("yes")) - - meter.RecordBatch( - // Note: call-site variables added as context Entries: - baggage.ContextWithValues(ctx, anotherKey.String("xyz")), - commonLabels, - - valuerecorderTwo.Measurement(2.0), - ) - - return func(ctx context.Context) error { - var span trace.Span - ctx, span = tracer.Start(ctx, "Sub operation...") - defer span.End() - - span.SetAttributes(lemonsKey.String("five")) - span.AddEvent("Sub span event") - valuerecorder.Record(ctx, 1.3) - - return nil - }(ctx) - }(ctx) - if err != nil { - panic(err) - } -} diff --git a/example/otel-collector/main.go b/example/otel-collector/main.go index d4f31d72a..249ca9e85 100644 --- a/example/otel-collector/main.go +++ b/example/otel-collector/main.go @@ -31,8 +31,8 @@ import ( "go.opentelemetry.io/otel/label" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/sdk/metric/controller/push" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" @@ -73,28 +73,27 @@ func initProvider() func() { sdktrace.WithSpanProcessor(bsp), ) - pusher := push.New( - basic.New( + cont := controller.New( + processor.New( simple.NewWithExactDistribution(), exp, ), - exp, - push.WithPeriod(2*time.Second), + controller.WithPusher(exp), + controller.WithCollectPeriod(2*time.Second), ) // set global propagator to tracecontext (the default is no-op). otel.SetTextMapPropagator(propagation.TraceContext{}) otel.SetTracerProvider(tracerProvider) - otel.SetMeterProvider(pusher.MeterProvider()) - pusher.Start() + otel.SetMeterProvider(cont.MeterProvider()) + handleErr(cont.Start(context.Background()), "failed to start controller") return func() { // Shutdown will flush any remaining spans. handleErr(tracerProvider.Shutdown(ctx), "failed to shutdown TracerProvider") // Push any last metric events to the exporter. - pusher.Stop() - handleErr(exp.Shutdown(ctx), "failed to stop exporter") + handleErr(cont.Stop(context.Background()), "failed to stop controller") } } diff --git a/example/prom-collector/README.md b/example/prom-collector/README.md new file mode 100644 index 000000000..465342382 --- /dev/null +++ b/example/prom-collector/README.md @@ -0,0 +1,3 @@ +This example demonstrates a metrics export pipeline that supports +Prometheus (pull) and simultaneously exports OTLP to an OpenTelemetry +endpoint (push). diff --git a/example/prom-collector/go.mod b/example/prom-collector/go.mod new file mode 100644 index 000000000..ca7502039 --- /dev/null +++ b/example/prom-collector/go.mod @@ -0,0 +1,18 @@ +module go.opentelemetry.io/otel/example/prom-collector + +go 1.14 + +replace ( + go.opentelemetry.io/otel => ../.. + go.opentelemetry.io/otel/exporters/metric/prometheus => ../../exporters/metric/prometheus + go.opentelemetry.io/otel/exporters/otlp => ../../exporters/otlp + go.opentelemetry.io/otel/sdk => ../../sdk +) + +require ( + go.opentelemetry.io/otel v0.15.0 + go.opentelemetry.io/otel/exporters/metric/prometheus v0.15.0 + go.opentelemetry.io/otel/exporters/otlp v0.15.0 + go.opentelemetry.io/otel/sdk v0.15.0 + google.golang.org/grpc v1.34.0 +) diff --git a/example/prom-collector/go.sum b/example/prom-collector/go.sum new file mode 100644 index 000000000..df8bd344d --- /dev/null +++ b/example/prom-collector/go.sum @@ -0,0 +1,443 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +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= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= +github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= +github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= +github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs= +golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.34.0 h1:raiipEjMOIC/TO2AvyTxP25XFdLxNIBwzDh3FM3XztI= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/example/prom-collector/main.go b/example/prom-collector/main.go new file mode 100644 index 000000000..e4efbfcb5 --- /dev/null +++ b/example/prom-collector/main.go @@ -0,0 +1,123 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "context" + "log" + "math/rand" + "net/http" + "time" + + "google.golang.org/grpc" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/metric/prometheus" + "go.opentelemetry.io/otel/exporters/otlp" + "go.opentelemetry.io/otel/exporters/otlp/otlpgrpc" + "go.opentelemetry.io/otel/label" + "go.opentelemetry.io/otel/metric" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/selector/simple" + "go.opentelemetry.io/otel/sdk/resource" +) + +func initMeter() { + ctx := context.Background() + + res, err := resource.New( + ctx, + resource.WithAttributes(label.String("R", "V")), + ) + if err != nil { + log.Fatal("could not initialize resource:", err) + } + + driver := otlpgrpc.NewDriver( + otlpgrpc.WithInsecure(), + otlpgrpc.WithEndpoint("localhost:30080"), + otlpgrpc.WithDialOption(grpc.WithBlock()), // useful for testing + ) + otlpExporter, err := otlp.NewExporter(ctx, driver) + + if err != nil { + log.Fatal("could not initialize OTLP:", err) + } + + cont := controller.New( + processor.New( + simple.NewWithHistogramDistribution([]float64{ + 0.001, 0.01, 0.1, 1, 10, 100, 1000, + }), + otlpExporter, // otlpExporter is an ExportKindSelector + processor.WithMemory(true), + ), + controller.WithResource(res), + controller.WithPusher(otlpExporter), + ) + + if err := cont.Start(context.Background()); err != nil { + log.Fatal("could not start controller:", err) + } + + promExporter, err := prometheus.NewExporter(prometheus.Config{}, cont) + if err != nil { + log.Fatal("could not initialize prometheus:", err) + } + http.HandleFunc("/", promExporter.ServeHTTP) + go func() { + log.Fatal(http.ListenAndServe(":17000", nil)) + }() + + otel.SetMeterProvider(cont.MeterProvider()) + + log.Println("Prometheus server running on :17000") + log.Println("Exporting OTLP to :30080") +} + +func main() { + initMeter() + + labels := []label.KeyValue{ + label.String("label1", "value1"), + } + + meter := otel.Meter("ex.com/prom-collector") + _ = metric.Must(meter).NewFloat64ValueObserver( + "randval", + func(_ context.Context, result metric.Float64ObserverResult) { + result.Observe( + rand.Float64(), + labels..., + ) + }, + metric.WithDescription("A random value"), + ) + + temperature := metric.Must(meter).NewFloat64ValueRecorder("temperature") + interrupts := metric.Must(meter).NewInt64Counter("interrupts") + + ctx := context.Background() + + log.Println("Example is running, please visit :17000") + + for { + temperature.Record(ctx, 100+10*rand.NormFloat64(), labels...) + interrupts.Add(ctx, int64(rand.Intn(100)), labels...) + + time.Sleep(time.Second * time.Duration(rand.Intn(10))) + } +} diff --git a/exporters/metric/prometheus/example_test.go b/exporters/metric/prometheus/example_test.go index 921a777b1..3eb264393 100644 --- a/exporters/metric/prometheus/example_test.go +++ b/exporters/metric/prometheus/example_test.go @@ -25,7 +25,7 @@ import ( "go.opentelemetry.io/otel/exporters/metric/prometheus" "go.opentelemetry.io/otel/label" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/sdk/metric/controller/pull" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/resource" ) @@ -50,7 +50,7 @@ func ExampleNewExportPipeline() { // Create a meter exporter, err := prometheus.NewExportPipeline( prometheus.Config{}, - pull.WithResource(res), + controller.WithResource(res), ) if err != nil { panic(err) diff --git a/exporters/metric/prometheus/prometheus.go b/exporters/metric/prometheus/prometheus.go index 5ed0e778b..7924c8c1d 100644 --- a/exporters/metric/prometheus/prometheus.go +++ b/exporters/metric/prometheus/prometheus.go @@ -32,8 +32,8 @@ import ( "go.opentelemetry.io/otel/metric/number" export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/export/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/controller/pull" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" ) @@ -51,7 +51,7 @@ type Exporter struct { // struct allows the exporter to potentially support multiple // controllers (e.g., with different resources). lock sync.RWMutex - controller *pull.Controller + controller *controller.Controller defaultHistogramBoundaries []float64 } @@ -87,9 +87,9 @@ type Config struct { DefaultHistogramBoundaries []float64 } -// NewExportPipeline sets up a complete export pipeline with the recommended setup, -// using the recommended selector and standard processor. See the pull.Options. -func NewExportPipeline(config Config, options ...pull.Option) (*Exporter, error) { +// NewExporter returns a new Prometheus exporter using the configured +// metric controller. See controller.New(). +func NewExporter(config Config, controller *controller.Controller) (*Exporter, error) { if config.Registry == nil { config.Registry = prometheus.NewRegistry() } @@ -106,20 +106,25 @@ func NewExportPipeline(config Config, options ...pull.Option) (*Exporter, error) handler: promhttp.HandlerFor(config.Gatherer, promhttp.HandlerOpts{}), registerer: config.Registerer, gatherer: config.Gatherer, + controller: controller, defaultHistogramBoundaries: config.DefaultHistogramBoundaries, } c := &collector{ exp: e, } - e.SetController(config, options...) if err := config.Registerer.Register(c); err != nil { return nil, fmt.Errorf("cannot register the collector: %w", err) } - return e, nil } +// NewExportPipeline sets up a complete export pipeline with the recommended setup, +// using the recommended selector and standard processor. See the controller.Options. +func NewExportPipeline(config Config, options ...controller.Option) (*Exporter, error) { + return NewExporter(config, defaultController(config, options...)) +} + // InstallNewPipeline instantiates a NewExportPipeline and registers it globally. // Typically called as: // @@ -131,7 +136,7 @@ func NewExportPipeline(config Config, options ...pull.Option) (*Exporter, error) // http.HandleFunc("/metrics", hf) // defer pipeline.Stop() // ... Done -func InstallNewPipeline(config Config, options ...pull.Option) (*Exporter, error) { +func InstallNewPipeline(config Config, options ...controller.Option) (*Exporter, error) { exp, err := NewExportPipeline(config, options...) if err != nil { return nil, err @@ -140,17 +145,14 @@ func InstallNewPipeline(config Config, options ...pull.Option) (*Exporter, error return exp, nil } -// SetController sets up a standard *pull.Controller as the metric provider -// for this exporter. -func (e *Exporter) SetController(config Config, options ...pull.Option) { - e.lock.Lock() - defer e.lock.Unlock() - - e.controller = pull.New( - basic.New( +// defaultController returns a standard *controller.Controller for use +// with Prometheus. +func defaultController(config Config, options ...controller.Option) *controller.Controller { + return controller.New( + processor.New( simple.NewWithHistogramDistribution(config.DefaultHistogramBoundaries), - e, - basic.WithMemory(true), + export.CumulativeExportKindSelector(), + processor.WithMemory(true), ), options..., ) @@ -162,7 +164,7 @@ func (e *Exporter) MeterProvider() metric.MeterProvider { } // Controller returns the controller object that coordinates collection for the SDK. -func (e *Exporter) Controller() *pull.Controller { +func (e *Exporter) Controller() *controller.Controller { e.lock.RLock() defer e.lock.RUnlock() return e.controller diff --git a/exporters/metric/prometheus/prometheus_test.go b/exporters/metric/prometheus/prometheus_test.go index 547b9fd64..fec47e217 100644 --- a/exporters/metric/prometheus/prometheus_test.go +++ b/exporters/metric/prometheus/prometheus_test.go @@ -29,7 +29,7 @@ import ( "go.opentelemetry.io/otel/exporters/metric/prometheus" "go.opentelemetry.io/otel/label" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/sdk/metric/controller/pull" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/resource" ) @@ -42,8 +42,8 @@ func TestPrometheusExporter(t *testing.T) { prometheus.Config{ DefaultHistogramBoundaries: []float64{-0.5, 1}, }, - pull.WithCachePeriod(0), - pull.WithResource(resource.NewWithAttributes(label.String("R", "V"))), + controller.WithCollectPeriod(0), + controller.WithResource(resource.NewWithAttributes(label.String("R", "V"))), ) require.NoError(t, err) @@ -116,7 +116,7 @@ func TestPrometheusStatefulness(t *testing.T) { // Create a meter exporter, err := prometheus.NewExportPipeline( prometheus.Config{}, - pull.WithCachePeriod(0), + controller.WithCollectPeriod(0), ) require.NoError(t, err) diff --git a/exporters/otlp/internal/otlptest/otlptest.go b/exporters/otlp/internal/otlptest/otlptest.go index 5c5ec8139..e3ced22c1 100644 --- a/exporters/otlp/internal/otlptest/otlptest.go +++ b/exporters/otlp/internal/otlptest/otlptest.go @@ -21,6 +21,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/exporters/otlp" commonpb "go.opentelemetry.io/otel/exporters/otlp/internal/opentelemetry-proto-gen/common/v1" @@ -28,7 +29,7 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/number" exportmetric "go.opentelemetry.io/otel/sdk/export/metric" - "go.opentelemetry.io/otel/sdk/metric/controller/push" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" "go.opentelemetry.io/otel/sdk/resource" @@ -75,10 +76,10 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlp.Exporter, mcTr selector := simple.NewWithInexpensiveDistribution() processor := processor.New(selector, exportmetric.StatelessExportKindSelector()) - pusher := push.New(processor, exp) - pusher.Start() + cont := controller.New(processor, controller.WithPusher(exp)) + require.NoError(t, cont.Start(ctx)) - meter := pusher.MeterProvider().Meter("test-meter") + meter := cont.MeterProvider().Meter("test-meter") labels := []label.KeyValue{label.Bool("test", true)} type data struct { @@ -137,7 +138,7 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlp.Exporter, mcTr } // Flush and close. - pusher.Stop() + require.NoError(t, cont.Stop(ctx)) func() { ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() diff --git a/exporters/otlp/otlpgrpc/example_test.go b/exporters/otlp/otlpgrpc/example_test.go index d77e120ea..2b8962d4a 100644 --- a/exporters/otlp/otlpgrpc/example_test.go +++ b/exporters/otlp/otlpgrpc/example_test.go @@ -26,8 +26,8 @@ import ( "go.opentelemetry.io/otel/exporters/otlp" "go.opentelemetry.io/otel/exporters/otlp/otlpgrpc" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/sdk/metric/controller/push" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" sdktrace "go.opentelemetry.io/otel/sdk/trace" ) @@ -179,24 +179,33 @@ func Example_withDifferentSignalCollectors() { }() otel.SetTracerProvider(tp) - pusher := push.New( - basic.New( + pusher := controller.New( + processor.New( simple.NewWithExactDistribution(), exp, ), - exp, - push.WithPeriod(2*time.Second), + controller.WithPusher(exp), + controller.WithCollectPeriod(2*time.Second), ) otel.SetMeterProvider(pusher.MeterProvider()) - pusher.Start() - defer pusher.Stop() // pushes any last exports to the receiver + if err := pusher.Start(ctx); err != nil { + log.Fatalf("could not start metric controoler: %v", err) + } + defer func() { + ctx, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() + // pushes any last exports to the receiver + if err := pusher.Stop(ctx); err != nil { + otel.Handle(err) + } + }() tracer := otel.Tracer("test-tracer") meter := otel.Meter("test-meter") // Recorder metric example - valuerecorder := metric.Must(meter). + counter := metric.Must(meter). NewFloat64Counter( "an_important_metric", metric.WithDescription("Measures the cumulative epicness of the app"), @@ -210,7 +219,7 @@ func Example_withDifferentSignalCollectors() { for i := 0; i < 10; i++ { _, iSpan := tracer.Start(ctx, fmt.Sprintf("Sample-%d", i)) log.Printf("Doing really hard work (%d / 10)\n", i+1) - valuerecorder.Add(ctx, 1.0) + counter.Add(ctx, 1.0) <-time.After(time.Second) iSpan.End() diff --git a/exporters/stdout/example_test.go b/exporters/stdout/example_test.go index 15e255587..39c906907 100644 --- a/exporters/stdout/example_test.go +++ b/exporters/stdout/example_test.go @@ -84,8 +84,11 @@ func Example() { if err != nil { log.Fatal("Could not initialize stdout exporter:", err) } - defer pusher.Stop() - ctx := context.Background() + log.Println("the answer is", add(ctx, multiply(ctx, multiply(ctx, 2, 2), 10), 2)) + + if err := pusher.Stop(ctx); err != nil { + log.Fatal("Could not stop stdout exporter:", err) + } } diff --git a/exporters/stdout/exporter.go b/exporters/stdout/exporter.go index 5f6b51020..930772047 100644 --- a/exporters/stdout/exporter.go +++ b/exporters/stdout/exporter.go @@ -15,11 +15,13 @@ package stdout // import "go.opentelemetry.io/otel/exporters/stdout" import ( + "context" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/sdk/export/metric" exporttrace "go.opentelemetry.io/otel/sdk/export/trace" - "go.opentelemetry.io/otel/sdk/metric/controller/push" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/trace" @@ -50,24 +52,26 @@ func NewExporter(options ...Option) (*Exporter, error) { // NewExportPipeline creates a complete export pipeline with the default // selectors, processors, and trace registration. It is the responsibility // of the caller to stop the returned push Controller. -func NewExportPipeline(exportOpts []Option, pushOpts []push.Option) (trace.TracerProvider, *push.Controller, error) { +func NewExportPipeline(exportOpts []Option, pushOpts []controller.Option) (trace.TracerProvider, *controller.Controller, error) { exporter, err := NewExporter(exportOpts...) if err != nil { return nil, nil, err } tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter)) - pusher := push.New( - basic.New( + pusher := controller.New( + processor.New( simple.NewWithInexpensiveDistribution(), exporter, ), - exporter, - pushOpts..., + append( + pushOpts, + controller.WithPusher(exporter), + )..., ) - pusher.Start() + err = pusher.Start(context.Background()) - return tp, pusher, nil + return tp, pusher, err } // InstallNewPipeline creates a complete export pipelines with defaults and @@ -82,7 +86,7 @@ func NewExportPipeline(exportOpts []Option, pushOpts []push.Option) (trace.Trace // } // defer pipeline.Stop() // ... Done -func InstallNewPipeline(exportOpts []Option, pushOpts []push.Option) (*push.Controller, error) { +func InstallNewPipeline(exportOpts []Option, pushOpts []controller.Option) (*controller.Controller, error) { tracerProvider, controller, err := NewExportPipeline(exportOpts, pushOpts) if err != nil { return controller, err diff --git a/sdk/metric/controller/basic/config.go b/sdk/metric/controller/basic/config.go new file mode 100644 index 000000000..4ccd3a68c --- /dev/null +++ b/sdk/metric/controller/basic/config.go @@ -0,0 +1,120 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package basic // import "go.opentelemetry.io/otel/sdk/metric/controller/basic" + +import ( + "time" + + export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/resource" +) + +// Config contains configuration for a basic Controller. +type Config struct { + // Resource is the OpenTelemetry resource associated with all Meters + // created by the Controller. + Resource *resource.Resource + + // CollectPeriod is the interval between calls to Collect a + // checkpoint. + // + // When pulling metrics and not exporting, this is the minimum + // time between calls to Collect. In a pull-only + // configuration, collection is performed on demand; set + // CollectPeriod to 0 always recompute the export record set. + // + // When exporting metrics, this must be > 0. + // + // Default value is 10s. + CollectPeriod time.Duration + + // CollectTimeout is the timeout of the Context passed to + // Collect() and subsequently to Observer instrument callbacks. + // + // Default value is 10s. If zero, no Collect timeout is applied. + CollectTimeout time.Duration + + // Pusher is used for exporting metric data. + // + // Note: Exporters such as Prometheus that pull data do not implement + // export.Exporter. These will directly call Collect() and ForEach(). + Pusher export.Exporter + + // PushTimeout is the timeout of the Context when a Pusher is configured. + // + // Default value is 10s. If zero, no Export timeout is applied. + PushTimeout time.Duration +} + +// Option is the interface that applies the value to a configuration option. +type Option interface { + // Apply sets the Option value of a Config. + Apply(*Config) +} + +// WithResource sets the Resource configuration option of a Config. +func WithResource(r *resource.Resource) Option { + return resourceOption{r} +} + +type resourceOption struct{ *resource.Resource } + +func (o resourceOption) Apply(config *Config) { + config.Resource = o.Resource +} + +// WithCollectPeriod sets the CollectPeriod configuration option of a Config. +func WithCollectPeriod(period time.Duration) Option { + return collectPeriodOption(period) +} + +type collectPeriodOption time.Duration + +func (o collectPeriodOption) Apply(config *Config) { + config.CollectPeriod = time.Duration(o) +} + +// WithCollectTimeout sets the CollectTimeout configuration option of a Config. +func WithCollectTimeout(timeout time.Duration) Option { + return collectTimeoutOption(timeout) +} + +type collectTimeoutOption time.Duration + +func (o collectTimeoutOption) Apply(config *Config) { + config.CollectTimeout = time.Duration(o) +} + +// WithPusher sets the Pusher configuration option of a Config. +func WithPusher(pusher export.Exporter) Option { + return pusherOption{pusher} +} + +type pusherOption struct{ pusher export.Exporter } + +func (o pusherOption) Apply(config *Config) { + config.Pusher = o.pusher +} + +// WithPushTimeout sets the PushTimeout configuration option of a Config. +func WithPushTimeout(timeout time.Duration) Option { + return pushTimeoutOption(timeout) +} + +type pushTimeoutOption time.Duration + +func (o pushTimeoutOption) Apply(config *Config) { + config.PushTimeout = time.Duration(o) +} diff --git a/sdk/metric/controller/push/config_test.go b/sdk/metric/controller/basic/config_test.go similarity index 98% rename from sdk/metric/controller/push/config_test.go rename to sdk/metric/controller/basic/config_test.go index 899d5ade4..b9210d6c3 100644 --- a/sdk/metric/controller/push/config_test.go +++ b/sdk/metric/controller/basic/config_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package push +package basic import ( "testing" diff --git a/sdk/metric/controller/basic/controller.go b/sdk/metric/controller/basic/controller.go new file mode 100644 index 000000000..5227d9ba4 --- /dev/null +++ b/sdk/metric/controller/basic/controller.go @@ -0,0 +1,308 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package basic // import "go.opentelemetry.io/otel/sdk/metric/controller/basic" + +import ( + "context" + "fmt" + "sync" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/registry" + export "go.opentelemetry.io/otel/sdk/export/metric" + sdk "go.opentelemetry.io/otel/sdk/metric" + controllerTime "go.opentelemetry.io/otel/sdk/metric/controller/time" +) + +// DefaultPeriod is used for: +// +// - the minimum time between calls to Collect() +// - the timeout for Export() +// - the timeout for Collect(). +const DefaultPeriod = 10 * time.Second + +// ErrControllerStarted indicates that a controller was started more +// than once. +var ErrControllerStarted = fmt.Errorf("controller already started") + +// Controller organizes and synchronizes collection of metric data in +// both "pull" and "push" configurations. This supports two distinct +// modes: +// +// - Push and Pull: Start() must be called to begin calling the pusher; +// Collect() is called periodically by a background thread after starting +// the controller. +// - Pull-Only: Start() is optional in this case, to call Collect periodically. +// If Start() is not called, Collect() can be called manually to initiate +// collection +// +// The controller supports mixing push and pull access to metric data +// using the export.CheckpointSet RWLock interface. Collection will +// be blocked by a pull request in the basic controller. +type Controller struct { + lock sync.Mutex + accumulator *sdk.Accumulator + provider *registry.MeterProvider + checkpointer export.Checkpointer + pusher export.Exporter + wg sync.WaitGroup + stopCh chan struct{} + clock controllerTime.Clock + ticker controllerTime.Ticker + + collectPeriod time.Duration + collectTimeout time.Duration + pushTimeout time.Duration + + // collectedTime is used only in configurations with no + // pusher, when ticker != nil. + collectedTime time.Time +} + +// New constructs a Controller using the provided checkpointer and +// options (including optional Pusher) to configure a metric +// export pipeline. +func New(checkpointer export.Checkpointer, opts ...Option) *Controller { + c := &Config{ + CollectPeriod: DefaultPeriod, + CollectTimeout: DefaultPeriod, + PushTimeout: DefaultPeriod, + } + for _, opt := range opts { + opt.Apply(c) + } + + impl := sdk.NewAccumulator( + checkpointer, + c.Resource, + ) + return &Controller{ + provider: registry.NewMeterProvider(impl), + accumulator: impl, + checkpointer: checkpointer, + pusher: c.Pusher, + stopCh: nil, + clock: controllerTime.RealClock{}, + + collectPeriod: c.CollectPeriod, + collectTimeout: c.CollectTimeout, + pushTimeout: c.PushTimeout, + } +} + +// SetClock supports setting a mock clock for testing. This must be +// called before Start(). +func (c *Controller) SetClock(clock controllerTime.Clock) { + c.lock.Lock() + defer c.lock.Unlock() + c.clock = clock +} + +// MeterProvider returns a MeterProvider instance for this controller. +func (c *Controller) MeterProvider() metric.MeterProvider { + return c.provider +} + +// Start begins a ticker that periodically collects and exports +// metrics with the configured interval. This is required for calling +// a configured Exporter (see WithExporter) and is otherwise optional +// when only pulling metric data. +// +// The passed context is passed to Collect() and subsequently to +// asynchronous instrument callbacks. Returns an error when the +// controller was already started. +// +// Note that it is not necessary to Start a controller when only +// pulling data; use the Collect() and ForEach() methods directly in +// this case. +func (c *Controller) Start(ctx context.Context) error { + c.lock.Lock() + defer c.lock.Unlock() + + if c.stopCh != nil { + return ErrControllerStarted + } + + c.wg.Add(1) + c.stopCh = make(chan struct{}) + c.ticker = c.clock.Ticker(c.collectPeriod) + go c.runTicker(ctx, c.stopCh) + return nil +} + +// Stop waits for the background goroutine to return and then collects +// and exports metrics one last time before returning. The passed +// context is passed to the final Collect() and subsequently to the +// final asynchronous instruments. +// +// Note that Stop() will not cancel an ongoing collection or export. +func (c *Controller) Stop(ctx context.Context) error { + c.lock.Lock() + defer c.lock.Unlock() + + if c.stopCh == nil { + return nil + } + + close(c.stopCh) + c.stopCh = nil + c.wg.Wait() + c.ticker.Stop() + c.ticker = nil + + return c.collect(ctx) +} + +// runTicker collection on ticker events until the stop channel is closed. +func (c *Controller) runTicker(ctx context.Context, stopCh chan struct{}) { + defer c.wg.Done() + for { + select { + case <-stopCh: + return + case <-c.ticker.C(): + if err := c.collect(ctx); err != nil { + otel.Handle(err) + } + } + } +} + +// collect computes a checkpoint and optionally exports it. +func (c *Controller) collect(ctx context.Context) error { + if err := c.checkpoint(ctx, func() bool { + return true + }); err != nil { + return err + } + if c.pusher == nil { + return nil + } + // Note: this is not subject to collectTimeout. This blocks the next + // collection despite collectTimeout because it holds a lock. + if err := c.export(ctx); err != nil { + return err + } + return nil +} + +// checkpoint calls the Accumulator and Checkpointer interfaces to +// compute the CheckpointSet. This applies the configured collection +// timeout. Note that this does not try to cancel a Collect or Export +// when Stop() is called. +func (c *Controller) checkpoint(ctx context.Context, cond func() bool) error { + ckpt := c.checkpointer.CheckpointSet() + ckpt.Lock() + defer ckpt.Unlock() + + if !cond() { + return nil + } + c.checkpointer.StartCollection() + + if c.collectTimeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, c.collectTimeout) + defer cancel() + } + + _ = c.accumulator.Collect(ctx) + + var err error + select { + case <-ctx.Done(): + err = ctx.Err() + default: + // The context wasn't done, ok. + } + + // Finish the checkpoint whether the accumulator timed out or not. + if cerr := c.checkpointer.FinishCollection(); cerr != nil { + if err == nil { + err = cerr + } else { + err = fmt.Errorf("%s: %w", cerr.Error(), err) + } + } + + return err +} + +// export calls the exporter with a read lock on the CheckpointSet, +// applying the configured export timeout. +func (c *Controller) export(ctx context.Context) error { + ckpt := c.checkpointer.CheckpointSet() + ckpt.RLock() + defer ckpt.RUnlock() + + if c.pushTimeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, c.pushTimeout) + defer cancel() + } + + return c.pusher.Export(ctx, ckpt) +} + +// Foreach gives the caller read-locked access to the current +// export.CheckpointSet. +func (c *Controller) ForEach(ks export.ExportKindSelector, f func(export.Record) error) error { + ckpt := c.checkpointer.CheckpointSet() + ckpt.RLock() + defer ckpt.RUnlock() + + return ckpt.ForEach(ks, f) +} + +// IsRunning returns true if the controller was started via Start(), +// indicating that the current export.CheckpointSet is being kept +// up-to-date. +func (c *Controller) IsRunning() bool { + c.lock.Lock() + defer c.lock.Unlock() + return c.ticker != nil +} + +// Collect requests a collection. The collection will be skipped if +// the last collection is aged less than the configured collection +// period. +func (c *Controller) Collect(ctx context.Context) error { + if c.IsRunning() { + // When there's a non-nil ticker, there's a goroutine + // computing checkpoints with the collection period. + return ErrControllerStarted + } + + return c.checkpoint(ctx, c.shouldCollect) +} + +// shouldCollect returns true if the collector should collect now, +// based on the timestamp, the last collection time, and the +// configured period. +func (c *Controller) shouldCollect() bool { + // This is called with the CheckpointSet exclusive + // lock held. + if c.collectPeriod == 0 { + return true + } + now := c.clock.Now() + if now.Sub(c.collectedTime) < c.collectPeriod { + return false + } + c.collectedTime = now + return true +} diff --git a/sdk/metric/controller/basic/controller_test.go b/sdk/metric/controller/basic/controller_test.go new file mode 100644 index 000000000..a1b3a7640 --- /dev/null +++ b/sdk/metric/controller/basic/controller_test.go @@ -0,0 +1,352 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package basic_test + +import ( + "context" + "errors" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/otel/label" + "go.opentelemetry.io/otel/metric" + export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/export/metric/aggregation" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" +) + +func getMap(t *testing.T, cont *controller.Controller) map[string]float64 { + out := processortest.NewOutput(label.DefaultEncoder()) + + require.NoError(t, cont.ForEach( + export.CumulativeExportKindSelector(), + func(record export.Record) error { + return out.AddRecord(record) + }, + )) + return out.Map() +} + +type testContextKey string + +func testContext() context.Context { + ctx := context.Background() + return context.WithValue(ctx, testContextKey("A"), "B") +} + +func checkTestContext(t *testing.T, ctx context.Context) { + require.Equal(t, "B", ctx.Value(testContextKey("A"))) +} + +func TestStartNoExporter(t *testing.T) { + cont := controller.New( + processor.New( + processortest.AggregatorSelector(), + export.CumulativeExportKindSelector(), + ), + controller.WithCollectPeriod(time.Second), + ) + mock := controllertest.NewMockClock() + cont.SetClock(mock) + + prov := cont.MeterProvider() + calls := int64(0) + + _ = metric.Must(prov.Meter("named")).NewInt64SumObserver("calls.lastvalue", + func(ctx context.Context, result metric.Int64ObserverResult) { + calls++ + checkTestContext(t, ctx) + result.Observe(calls, label.String("A", "B")) + }, + ) + + // Collect() has not been called. The controller is unstarted. + expect := map[string]float64{} + + // The time advances, but doesn't change the result (not collected). + require.EqualValues(t, expect, getMap(t, cont)) + mock.Add(time.Second) + require.EqualValues(t, expect, getMap(t, cont)) + mock.Add(time.Second) + + expect = map[string]float64{ + "calls.lastvalue/A=B/": 1, + } + + // Collect once + ctx := testContext() + + require.NoError(t, cont.Collect(ctx)) + + require.EqualValues(t, expect, getMap(t, cont)) + mock.Add(time.Second) + require.EqualValues(t, expect, getMap(t, cont)) + mock.Add(time.Second) + + // Again + expect = map[string]float64{ + "calls.lastvalue/A=B/": 2, + } + + require.NoError(t, cont.Collect(ctx)) + + require.EqualValues(t, expect, getMap(t, cont)) + mock.Add(time.Second) + require.EqualValues(t, expect, getMap(t, cont)) + + // Start the controller + require.NoError(t, cont.Start(ctx)) + + for i := 1; i <= 3; i++ { + expect = map[string]float64{ + "calls.lastvalue/A=B/": 2 + float64(i), + } + + mock.Add(time.Second) + require.EqualValues(t, expect, getMap(t, cont)) + } +} + +func TestObserverCanceled(t *testing.T) { + cont := controller.New( + processor.New( + processortest.AggregatorSelector(), + export.CumulativeExportKindSelector(), + ), + controller.WithCollectPeriod(0), + controller.WithCollectTimeout(time.Millisecond), + ) + + prov := cont.MeterProvider() + calls := int64(0) + + _ = metric.Must(prov.Meter("named")).NewInt64SumObserver("done.lastvalue", + func(ctx context.Context, result metric.Int64ObserverResult) { + <-ctx.Done() + calls++ + result.Observe(calls) + }, + ) + // This relies on the context timing out + err := cont.Collect(context.Background()) + require.Error(t, err) + require.True(t, errors.Is(err, context.DeadlineExceeded)) + + expect := map[string]float64{ + "done.lastvalue//": 1, + } + + require.EqualValues(t, expect, getMap(t, cont)) +} + +func TestObserverContext(t *testing.T) { + cont := controller.New( + processor.New( + processortest.AggregatorSelector(), + export.CumulativeExportKindSelector(), + ), + controller.WithCollectTimeout(0), + ) + + prov := cont.MeterProvider() + + _ = metric.Must(prov.Meter("named")).NewInt64SumObserver("done.lastvalue", + func(ctx context.Context, result metric.Int64ObserverResult) { + time.Sleep(10 * time.Millisecond) + checkTestContext(t, ctx) + result.Observe(1) + }, + ) + ctx := testContext() + + require.NoError(t, cont.Collect(ctx)) + + expect := map[string]float64{ + "done.lastvalue//": 1, + } + + require.EqualValues(t, expect, getMap(t, cont)) +} + +type blockingExporter struct { + calls int + exporter *processortest.Exporter +} + +func newBlockingExporter() *blockingExporter { + return &blockingExporter{ + exporter: processortest.NewExporter( + export.CumulativeExportKindSelector(), + label.DefaultEncoder(), + ), + } +} + +func (b *blockingExporter) Export(ctx context.Context, output export.CheckpointSet) error { + var err error + _ = b.exporter.Export(ctx, output) + if b.calls == 0 { + // timeout once + <-ctx.Done() + err = ctx.Err() + } + b.calls++ + return err +} + +func (*blockingExporter) ExportKindFor( + *metric.Descriptor, + aggregation.Kind, +) export.ExportKind { + return export.CumulativeExportKind +} + +func TestExportTimeout(t *testing.T) { + exporter := newBlockingExporter() + cont := controller.New( + processor.New( + processortest.AggregatorSelector(), + export.CumulativeExportKindSelector(), + ), + controller.WithCollectPeriod(time.Second), + controller.WithPushTimeout(time.Millisecond), + controller.WithPusher(exporter), + ) + mock := controllertest.NewMockClock() + cont.SetClock(mock) + + prov := cont.MeterProvider() + + calls := int64(0) + _ = metric.Must(prov.Meter("named")).NewInt64SumObserver("one.lastvalue", + func(ctx context.Context, result metric.Int64ObserverResult) { + calls++ + result.Observe(calls) + }, + ) + + require.NoError(t, cont.Start(context.Background())) + + // Initial empty state + expect := map[string]float64{} + require.EqualValues(t, expect, exporter.exporter.Values()) + + // Collect after 1s, timeout + mock.Add(time.Second) + + err := testHandler.Flush() + require.Error(t, err) + require.True(t, errors.Is(err, context.DeadlineExceeded)) + + expect = map[string]float64{ + "one.lastvalue//": 1, + } + require.EqualValues(t, expect, exporter.exporter.Values()) + + // Collect again + mock.Add(time.Second) + expect = map[string]float64{ + "one.lastvalue//": 2, + } + require.EqualValues(t, expect, exporter.exporter.Values()) + + err = testHandler.Flush() + require.NoError(t, err) +} + +func TestCollectAfterStopThenStartAgain(t *testing.T) { + exp := processortest.NewExporter( + export.CumulativeExportKindSelector(), + label.DefaultEncoder(), + ) + cont := controller.New( + processor.New( + processortest.AggregatorSelector(), + exp, + ), + controller.WithCollectPeriod(time.Second), + controller.WithPusher(exp), + ) + mock := controllertest.NewMockClock() + cont.SetClock(mock) + + prov := cont.MeterProvider() + + calls := 0 + _ = metric.Must(prov.Meter("named")).NewInt64SumObserver("one.lastvalue", + func(ctx context.Context, result metric.Int64ObserverResult) { + calls++ + result.Observe(int64(calls)) + }, + ) + + // No collections happen (because mock clock does not advance): + require.NoError(t, cont.Start(context.Background())) + require.True(t, cont.IsRunning()) + + // There's one collection run by Stop(): + require.NoError(t, cont.Stop(context.Background())) + + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 1, + }, exp.Values()) + require.NoError(t, testHandler.Flush()) + + // Manual collect after Stop still works, subject to + // CollectPeriod. + require.NoError(t, cont.Collect(context.Background())) + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 2, + }, getMap(t, cont)) + + require.NoError(t, testHandler.Flush()) + require.False(t, cont.IsRunning()) + + // Start again, see that collection proceeds. However, + // explicit collection should still fail. + require.NoError(t, cont.Start(context.Background())) + require.True(t, cont.IsRunning()) + err := cont.Collect(context.Background()) + require.Error(t, err) + require.Equal(t, controller.ErrControllerStarted, err) + + require.NoError(t, cont.Stop(context.Background())) + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 3, + }, exp.Values()) + require.False(t, cont.IsRunning()) + + // Time has not advanced yet. Now let the ticker perform + // collection: + require.NoError(t, cont.Start(context.Background())) + mock.Add(time.Second) + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 4, + }, exp.Values()) + + mock.Add(time.Second) + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 5, + }, exp.Values()) + require.NoError(t, cont.Stop(context.Background())) + require.EqualValues(t, map[string]float64{ + "one.lastvalue//": 6, + }, exp.Values()) +} diff --git a/sdk/metric/controller/pull/pull_test.go b/sdk/metric/controller/basic/pull_test.go similarity index 85% rename from sdk/metric/controller/pull/pull_test.go rename to sdk/metric/controller/basic/pull_test.go index 06988105d..1e0832356 100644 --- a/sdk/metric/controller/pull/pull_test.go +++ b/sdk/metric/controller/basic/pull_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package pull_test +package basic_test import ( "context" @@ -25,21 +25,20 @@ import ( "go.opentelemetry.io/otel/label" "go.opentelemetry.io/otel/metric" export "go.opentelemetry.io/otel/sdk/export/metric" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" - "go.opentelemetry.io/otel/sdk/metric/controller/pull" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" - selector "go.opentelemetry.io/otel/sdk/metric/selector/simple" ) -func TestPullNoCache(t *testing.T) { - puller := pull.New( - basic.New( - selector.NewWithExactDistribution(), +func TestPullNoCollect(t *testing.T) { + puller := controller.New( + processor.New( + processortest.AggregatorSelector(), export.CumulativeExportKindSelector(), - basic.WithMemory(true), + processor.WithMemory(true), ), - pull.WithCachePeriod(0), + controller.WithCollectPeriod(0), ) ctx := context.Background() @@ -67,14 +66,14 @@ func TestPullNoCache(t *testing.T) { }, records.Map()) } -func TestPullWithCache(t *testing.T) { - puller := pull.New( - basic.New( - selector.NewWithExactDistribution(), +func TestPullWithCollect(t *testing.T) { + puller := controller.New( + processor.New( + processortest.AggregatorSelector(), export.CumulativeExportKindSelector(), - basic.WithMemory(true), + processor.WithMemory(true), ), - pull.WithCachePeriod(time.Second), + controller.WithCollectPeriod(time.Second), ) mock := controllertest.NewMockClock() puller.SetClock(mock) diff --git a/sdk/metric/controller/push/push_test.go b/sdk/metric/controller/basic/push_test.go similarity index 76% rename from sdk/metric/controller/push/push_test.go rename to sdk/metric/controller/basic/push_test.go index 17c21f297..4add5f3f5 100644 --- a/sdk/metric/controller/push/push_test.go +++ b/sdk/metric/controller/basic/push_test.go @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package push_test +package basic_test import ( "context" + "errors" "fmt" "runtime" "sync" @@ -29,10 +30,10 @@ import ( "go.opentelemetry.io/otel/metric" export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/export/metric/aggregation" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" - "go.opentelemetry.io/otel/sdk/metric/controller/push" - "go.opentelemetry.io/otel/sdk/metric/processor/basic" - processorTest "go.opentelemetry.io/otel/sdk/metric/processor/processortest" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" ) @@ -64,48 +65,52 @@ func init() { otel.SetErrorHandler(testHandler) } -func newExporter() *processorTest.Exporter { - return processorTest.NewExporter( +func newExporter() *processortest.Exporter { + return processortest.NewExporter( export.StatelessExportKindSelector(), label.DefaultEncoder(), ) } func newCheckpointer() export.Checkpointer { - return processorTest.Checkpointer( - processorTest.NewProcessor( - processorTest.AggregatorSelector(), + return processortest.Checkpointer( + processortest.NewProcessor( + processortest.AggregatorSelector(), label.DefaultEncoder(), ), ) } func TestPushDoubleStop(t *testing.T) { + ctx := context.Background() exporter := newExporter() checkpointer := newCheckpointer() - p := push.New(checkpointer, exporter) - p.Start() - p.Stop() - p.Stop() + p := controller.New(checkpointer, controller.WithPusher(exporter)) + require.NoError(t, p.Start(ctx)) + require.NoError(t, p.Stop(ctx)) + require.NoError(t, p.Stop(ctx)) } func TestPushDoubleStart(t *testing.T) { + ctx := context.Background() exporter := newExporter() checkpointer := newCheckpointer() - p := push.New(checkpointer, exporter) - p.Start() - p.Start() - p.Stop() + p := controller.New(checkpointer, controller.WithPusher(exporter)) + require.NoError(t, p.Start(ctx)) + err := p.Start(ctx) + require.Error(t, err) + require.True(t, errors.Is(err, controller.ErrControllerStarted)) + require.NoError(t, p.Stop(ctx)) } func TestPushTicker(t *testing.T) { exporter := newExporter() checkpointer := newCheckpointer() - p := push.New( + p := controller.New( checkpointer, - exporter, - push.WithPeriod(time.Second), - push.WithResource(testResource), + controller.WithPusher(exporter), + controller.WithCollectPeriod(time.Second), + controller.WithResource(testResource), ) meter := p.MeterProvider().Meter("name") @@ -116,7 +121,7 @@ func TestPushTicker(t *testing.T) { counter := metric.Must(meter).NewInt64Counter("counter.sum") - p.Start() + require.NoError(t, p.Start(ctx)) counter.Add(ctx, 3) @@ -144,7 +149,7 @@ func TestPushTicker(t *testing.T) { require.Equal(t, 1, exporter.ExportCount()) exporter.Reset() - p.Stop() + require.NoError(t, p.Stop(ctx)) } func TestPushExportError(t *testing.T) { @@ -180,12 +185,12 @@ func TestPushExportError(t *testing.T) { // This test validates the error handling // behavior of the basic Processor is honored // by the push processor. - checkpointer := basic.New(processorTest.AggregatorSelector(), exporter) - p := push.New( + checkpointer := processor.New(processortest.AggregatorSelector(), exporter) + p := controller.New( checkpointer, - exporter, - push.WithPeriod(time.Second), - push.WithResource(testResource), + controller.WithPusher(exporter), + controller.WithCollectPeriod(time.Second), + controller.WithResource(testResource), ) mock := controllertest.NewMockClock() @@ -197,7 +202,7 @@ func TestPushExportError(t *testing.T) { counter1 := metric.Must(meter).NewInt64Counter("counter1.sum") counter2 := metric.Must(meter).NewInt64Counter("counter2.sum") - p.Start() + require.NoError(t, p.Start(ctx)) runtime.Gosched() counter1.Add(ctx, 3, label.String("X", "Y")) @@ -219,7 +224,7 @@ func TestPushExportError(t *testing.T) { require.Equal(t, tt.expectedError, err) } - p.Stop() + require.NoError(t, p.Stop(ctx)) }) } } diff --git a/sdk/metric/controller/pull/config.go b/sdk/metric/controller/pull/config.go deleted file mode 100644 index 363285bf8..000000000 --- a/sdk/metric/controller/pull/config.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pull // import "go.opentelemetry.io/otel/sdk/metric/controller/pull" - -import ( - "time" - - "go.opentelemetry.io/otel/sdk/resource" -) - -// Config contains configuration for a pull Controller. -type Config struct { - - // Resource is the OpenTelemetry resource associated with all Meters - // created by the Controller. - Resource *resource.Resource - - // CachePeriod is the period which a recently-computed result - // will be returned without gathering metric data again. - // - // If the period is zero, caching of the result is disabled. - // The default value is 10 seconds. - CachePeriod time.Duration -} - -// Option is the interface that applies the value to a configuration option. -type Option interface { - // Apply sets the Option value of a Config. - Apply(*Config) -} - -// WithResource sets the Resource configuration option of a Config. -func WithResource(r *resource.Resource) Option { - return resourceOption{r} -} - -type resourceOption struct{ *resource.Resource } - -func (o resourceOption) Apply(config *Config) { - config.Resource = o.Resource -} - -// WithCachePeriod sets the CachePeriod configuration option of a Config. -func WithCachePeriod(cachePeriod time.Duration) Option { - return cachePeriodOption(cachePeriod) -} - -type cachePeriodOption time.Duration - -func (o cachePeriodOption) Apply(config *Config) { - config.CachePeriod = time.Duration(o) -} diff --git a/sdk/metric/controller/pull/pull.go b/sdk/metric/controller/pull/pull.go deleted file mode 100644 index 68ea34b35..000000000 --- a/sdk/metric/controller/pull/pull.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pull // import "go.opentelemetry.io/otel/sdk/metric/controller/pull" - -import ( - "context" - "time" - - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/registry" - export "go.opentelemetry.io/otel/sdk/export/metric" - sdk "go.opentelemetry.io/otel/sdk/metric" - controllerTime "go.opentelemetry.io/otel/sdk/metric/controller/time" - "go.opentelemetry.io/otel/sdk/resource" -) - -// DefaultCachePeriod determines how long a recently-computed result -// will be returned without gathering metric data again. -const DefaultCachePeriod time.Duration = 10 * time.Second - -// Controller manages access to a *sdk.Accumulator and *basic.Processor. Use -// MeterProvider() for obtaining Meters. Use Foreach() for accessing current -// records. -type Controller struct { - accumulator *sdk.Accumulator - checkpointer export.Checkpointer - provider *registry.MeterProvider - period time.Duration - lastCollect time.Time - clock controllerTime.Clock - checkpoint export.CheckpointSet -} - -// New returns a *Controller configured with an export.Checkpointer. -// -// Pull controllers are typically used in an environment where there -// are multiple readers. It is common, therefore, when configuring a -// basic Processor for use with this controller, to use a -// CumulativeExport strategy and the basic.WithMemory(true) option, -// which ensures that every CheckpointSet includes full state. -func New(checkpointer export.Checkpointer, options ...Option) *Controller { - config := &Config{ - Resource: resource.Empty(), - CachePeriod: DefaultCachePeriod, - } - for _, opt := range options { - opt.Apply(config) - } - accum := sdk.NewAccumulator( - checkpointer, - config.Resource, - ) - return &Controller{ - accumulator: accum, - checkpointer: checkpointer, - provider: registry.NewMeterProvider(accum), - period: config.CachePeriod, - checkpoint: checkpointer.CheckpointSet(), - clock: controllerTime.RealClock{}, - } -} - -// SetClock sets the clock used for caching. For testing purposes. -func (c *Controller) SetClock(clock controllerTime.Clock) { - c.checkpointer.CheckpointSet().Lock() - defer c.checkpointer.CheckpointSet().Unlock() - c.clock = clock -} - -// MeterProvider returns a MeterProvider for the implementation managed by -// this controller. -func (c *Controller) MeterProvider() metric.MeterProvider { - return c.provider -} - -// Foreach gives the caller read-locked access to the current -// export.CheckpointSet. -func (c *Controller) ForEach(ks export.ExportKindSelector, f func(export.Record) error) error { - c.checkpointer.CheckpointSet().RLock() - defer c.checkpointer.CheckpointSet().RUnlock() - - return c.checkpoint.ForEach(ks, f) -} - -// Collect requests a collection. The collection will be skipped if -// the last collection is aged less than the CachePeriod. -func (c *Controller) Collect(ctx context.Context) error { - c.checkpointer.CheckpointSet().Lock() - defer c.checkpointer.CheckpointSet().Unlock() - - if c.period > 0 { - now := c.clock.Now() - elapsed := now.Sub(c.lastCollect) - - if elapsed < c.period { - return nil - } - c.lastCollect = now - } - - c.checkpointer.StartCollection() - c.accumulator.Collect(ctx) - err := c.checkpointer.FinishCollection() - c.checkpoint = c.checkpointer.CheckpointSet() - return err -} diff --git a/sdk/metric/controller/push/config.go b/sdk/metric/controller/push/config.go deleted file mode 100644 index d708780d6..000000000 --- a/sdk/metric/controller/push/config.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package push // import "go.opentelemetry.io/otel/sdk/metric/controller/push" - -import ( - "time" - - "go.opentelemetry.io/otel/sdk/resource" -) - -// Config contains configuration for a push Controller. -type Config struct { - // Resource is the OpenTelemetry resource associated with all Meters - // created by the Controller. - Resource *resource.Resource - - // Period is the interval between calls to Collect a checkpoint. - Period time.Duration - - // Timeout is the duration a collection (i.e. collect, accumulate, - // integrate, and export) can last before it is canceled. Defaults to - // the controller push period. - Timeout time.Duration -} - -// Option is the interface that applies the value to a configuration option. -type Option interface { - // Apply sets the Option value of a Config. - Apply(*Config) -} - -// WithResource sets the Resource configuration option of a Config. -func WithResource(r *resource.Resource) Option { - return resourceOption{r} -} - -type resourceOption struct{ *resource.Resource } - -func (o resourceOption) Apply(config *Config) { - config.Resource = o.Resource -} - -// WithPeriod sets the Period configuration option of a Config. -func WithPeriod(period time.Duration) Option { - return periodOption(period) -} - -type periodOption time.Duration - -func (o periodOption) Apply(config *Config) { - config.Period = time.Duration(o) -} - -// WithTimeout sets the Timeout configuration option of a Config. -func WithTimeout(timeout time.Duration) Option { - return timeoutOption(timeout) -} - -type timeoutOption time.Duration - -func (o timeoutOption) Apply(config *Config) { - config.Timeout = time.Duration(o) -} diff --git a/sdk/metric/controller/push/push.go b/sdk/metric/controller/push/push.go deleted file mode 100644 index 4350de32d..000000000 --- a/sdk/metric/controller/push/push.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package push // import "go.opentelemetry.io/otel/sdk/metric/controller/push" - -import ( - "context" - "sync" - "time" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/registry" - export "go.opentelemetry.io/otel/sdk/export/metric" - sdk "go.opentelemetry.io/otel/sdk/metric" - controllerTime "go.opentelemetry.io/otel/sdk/metric/controller/time" -) - -// DefaultPushPeriod is the default time interval between pushes. -const DefaultPushPeriod = 10 * time.Second - -// Controller organizes a periodic push of metric data. -type Controller struct { - lock sync.Mutex - accumulator *sdk.Accumulator - provider *registry.MeterProvider - checkpointer export.Checkpointer - exporter export.Exporter - wg sync.WaitGroup - ch chan struct{} - period time.Duration - timeout time.Duration - clock controllerTime.Clock - ticker controllerTime.Ticker -} - -// New constructs a Controller, an implementation of MeterProvider, using the -// provided checkpointer, exporter, and options to configure an SDK with -// periodic collection. -func New(checkpointer export.Checkpointer, exporter export.Exporter, opts ...Option) *Controller { - c := &Config{ - Period: DefaultPushPeriod, - } - for _, opt := range opts { - opt.Apply(c) - } - if c.Timeout == 0 { - c.Timeout = c.Period - } - - impl := sdk.NewAccumulator( - checkpointer, - c.Resource, - ) - return &Controller{ - provider: registry.NewMeterProvider(impl), - accumulator: impl, - checkpointer: checkpointer, - exporter: exporter, - ch: make(chan struct{}), - period: c.Period, - timeout: c.Timeout, - clock: controllerTime.RealClock{}, - } -} - -// SetClock supports setting a mock clock for testing. This must be -// called before Start(). -func (c *Controller) SetClock(clock controllerTime.Clock) { - c.lock.Lock() - defer c.lock.Unlock() - c.clock = clock -} - -// MeterProvider returns a MeterProvider instance for this controller. -func (c *Controller) MeterProvider() metric.MeterProvider { - return c.provider -} - -// Start begins a ticker that periodically collects and exports -// metrics with the configured interval. -func (c *Controller) Start() { - c.lock.Lock() - defer c.lock.Unlock() - - if c.ticker != nil { - return - } - - c.ticker = c.clock.Ticker(c.period) - c.wg.Add(1) - go c.run(c.ch) -} - -// Stop waits for the background goroutine to return and then collects -// and exports metrics one last time before returning. -func (c *Controller) Stop() { - c.lock.Lock() - defer c.lock.Unlock() - - if c.ch == nil { - return - } - - close(c.ch) - c.ch = nil - c.wg.Wait() - c.ticker.Stop() - - c.tick() -} - -func (c *Controller) run(ch chan struct{}) { - for { - select { - case <-ch: - c.wg.Done() - return - case <-c.ticker.C(): - c.tick() - } - } -} - -func (c *Controller) tick() { - ctx, cancel := context.WithTimeout(context.Background(), c.timeout) - defer cancel() - - ckpt := c.checkpointer.CheckpointSet() - ckpt.Lock() - defer ckpt.Unlock() - - c.checkpointer.StartCollection() - c.accumulator.Collect(ctx) - if err := c.checkpointer.FinishCollection(); err != nil { - otel.Handle(err) - } - - if err := c.exporter.Export(ctx, ckpt); err != nil { - otel.Handle(err) - } -} diff --git a/sdk/metric/sdk.go b/sdk/metric/sdk.go index 64bfa9b1d..14b381c33 100644 --- a/sdk/metric/sdk.go +++ b/sdk/metric/sdk.go @@ -412,8 +412,7 @@ func (m *Accumulator) observeAsyncInstruments(ctx context.Context) int { asyncCollected := 0 - // TODO: change this to `ctx` (in a separate PR, with tests) - m.asyncInstruments.Run(context.Background(), m) + m.asyncInstruments.Run(ctx, m) for _, inst := range m.asyncInstruments.Instruments() { if a := m.fromAsync(inst); a != nil {