diff --git a/exporter/metric/dogstatsd/dogstatsd.go b/exporter/metric/dogstatsd/dogstatsd.go index f07e33b9785..449559031d1 100644 --- a/exporter/metric/dogstatsd/dogstatsd.go +++ b/exporter/metric/dogstatsd/dogstatsd.go @@ -75,7 +75,7 @@ func NewRawExporter(config Config) (*Exporter, error) { // defer pipeline.Stop() // ... Done func InstallNewPipeline(config Config) (*push.Controller, error) { - controller, err := NewExportPipeline(config) + controller, err := NewExportPipeline(config, time.Minute) if err != nil { return controller, err } @@ -85,7 +85,7 @@ func InstallNewPipeline(config Config) (*push.Controller, error) { // NewExportPipeline sets up a complete export pipeline with the recommended setup, // chaining a NewRawExporter into the recommended selectors and batchers. -func NewExportPipeline(config Config) (*push.Controller, error) { +func NewExportPipeline(config Config, period time.Duration) (*push.Controller, error) { selector := simple.NewWithExactMeasure() exporter, err := NewRawExporter(config) if err != nil { @@ -99,7 +99,7 @@ func NewExportPipeline(config Config) (*push.Controller, error) { // The pusher automatically recognizes that the exporter // implements the LabelEncoder interface, which ensures the // export encoding for labels is encoded in the LabelSet. - pusher := push.New(batcher, exporter, time.Hour) + pusher := push.New(batcher, exporter, period) pusher.Start() return pusher, nil diff --git a/exporter/metric/dogstatsd/example_test.go b/exporter/metric/dogstatsd/example_test.go index 5a3c290ad48..86c7cf6fc8f 100644 --- a/exporter/metric/dogstatsd/example_test.go +++ b/exporter/metric/dogstatsd/example_test.go @@ -6,6 +6,7 @@ import ( "io" "log" "sync" + "time" "go.opentelemetry.io/otel/api/key" "go.opentelemetry.io/otel/api/metric" @@ -45,7 +46,7 @@ func ExampleNew() { // In real code, use the URL field: // // URL: fmt.Sprint("unix://", path), - }) + }, time.Minute) if err != nil { log.Fatal("Could not initialize dogstatsd exporter:", err) } diff --git a/exporter/metric/prometheus/prometheus.go b/exporter/metric/prometheus/prometheus.go index 2c464e0a3f4..56bf6c37e21 100644 --- a/exporter/metric/prometheus/prometheus.go +++ b/exporter/metric/prometheus/prometheus.go @@ -128,7 +128,7 @@ func NewRawExporter(config Config) (*Exporter, error) { // defer pipeline.Stop() // ... Done func InstallNewPipeline(config Config) (*push.Controller, http.HandlerFunc, error) { - controller, hf, err := NewExportPipeline(config) + controller, hf, err := NewExportPipeline(config, time.Minute) if err != nil { return controller, hf, err } @@ -138,7 +138,7 @@ func InstallNewPipeline(config Config) (*push.Controller, http.HandlerFunc, erro // NewExportPipeline sets up a complete export pipeline with the recommended setup, // chaining a NewRawExporter into the recommended selectors and batchers. -func NewExportPipeline(config Config) (*push.Controller, http.HandlerFunc, error) { +func NewExportPipeline(config Config, period time.Duration) (*push.Controller, http.HandlerFunc, error) { selector := simple.NewWithExactMeasure() exporter, err := NewRawExporter(config) if err != nil { @@ -154,7 +154,7 @@ func NewExportPipeline(config Config) (*push.Controller, http.HandlerFunc, error // // Gauges (or LastValues) and Summaries are an exception to this and have different behaviors. batcher := defaultkeys.New(selector, sdkmetric.NewDefaultLabelEncoder(), true) - pusher := push.New(batcher, exporter, time.Second) + pusher := push.New(batcher, exporter, period) pusher.Start() return pusher, exporter.ServeHTTP, nil diff --git a/exporter/metric/stdout/example_test.go b/exporter/metric/stdout/example_test.go index c900fd5dcdb..5034146c880 100644 --- a/exporter/metric/stdout/example_test.go +++ b/exporter/metric/stdout/example_test.go @@ -3,6 +3,7 @@ package stdout_test import ( "context" "log" + "time" "go.opentelemetry.io/otel/api/key" "go.opentelemetry.io/otel/api/metric" @@ -14,7 +15,7 @@ func ExampleNewExportPipeline() { pusher, err := stdout.NewExportPipeline(stdout.Config{ PrettyPrint: true, DoNotPrintTime: true, - }) + }, time.Minute) if err != nil { log.Fatal("Could not initialize stdout exporter:", err) } diff --git a/exporter/metric/stdout/stdout.go b/exporter/metric/stdout/stdout.go index ab6fc32c0fe..bc42ea54b39 100644 --- a/exporter/metric/stdout/stdout.go +++ b/exporter/metric/stdout/stdout.go @@ -115,7 +115,7 @@ func NewRawExporter(config Config) (*Exporter, error) { // defer pipeline.Stop() // ... Done func InstallNewPipeline(config Config) (*push.Controller, error) { - controller, err := NewExportPipeline(config) + controller, err := NewExportPipeline(config, time.Minute) if err != nil { return controller, err } @@ -125,14 +125,14 @@ func InstallNewPipeline(config Config) (*push.Controller, error) { // NewExportPipeline sets up a complete export pipeline with the recommended setup, // chaining a NewRawExporter into the recommended selectors and batchers. -func NewExportPipeline(config Config) (*push.Controller, error) { +func NewExportPipeline(config Config, period time.Duration) (*push.Controller, error) { selector := simple.NewWithExactMeasure() exporter, err := NewRawExporter(config) if err != nil { return nil, err } batcher := ungrouped.New(selector, true) - pusher := push.New(batcher, exporter, time.Second) + pusher := push.New(batcher, exporter, period) pusher.Start() return pusher, nil diff --git a/sdk/metric/example_test.go b/sdk/metric/example_test.go index cda8e3d1470..f1b30ee9985 100644 --- a/sdk/metric/example_test.go +++ b/sdk/metric/example_test.go @@ -17,6 +17,7 @@ package metric_test import ( "context" "fmt" + "time" "go.opentelemetry.io/otel/api/key" "go.opentelemetry.io/otel/api/metric" @@ -27,7 +28,7 @@ func ExampleNew() { pusher, err := stdout.NewExportPipeline(stdout.Config{ PrettyPrint: true, DoNotPrintTime: true, // This makes the output deterministic - }) + }, time.Minute) if err != nil { panic(fmt.Sprintln("Could not initialize stdout exporter:", err)) }