Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable push frequency for exporters #504

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exporter/metric/dogstatsd/dogstatsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Hour)
rebeccajae marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return controller, err
}
Expand All @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion exporter/metric/dogstatsd/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"log"
"sync"
"time"

"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/metric"
Expand Down Expand Up @@ -45,7 +46,7 @@ func ExampleNew() {
// In real code, use the URL field:
//
// URL: fmt.Sprint("unix://", path),
})
}, time.Hour)
if err != nil {
log.Fatal("Could not initialize dogstatsd exporter:", err)
}
Expand Down
6 changes: 3 additions & 3 deletions exporter/metric/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Second)
rebeccajae marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return controller, hf, err
}
Expand All @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion exporter/metric/stdout/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package stdout_test
import (
"context"
"log"
"time"

"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/metric"
Expand All @@ -14,7 +15,7 @@ func ExampleNewExportPipeline() {
pusher, err := stdout.NewExportPipeline(stdout.Config{
PrettyPrint: true,
DoNotPrintTime: true,
})
}, time.Second)
if err != nil {
log.Fatal("Could not initialize stdout exporter:", err)
}
Expand Down
6 changes: 3 additions & 3 deletions exporter/metric/stdout/stdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Second)
if err != nil {
return controller, err
}
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion sdk/metric/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package metric_test
import (
"context"
"fmt"
"time"

"go.opentelemetry.io/otel/api/key"
"go.opentelemetry.io/otel/api/metric"
Expand All @@ -27,7 +28,7 @@ func ExampleNew() {
pusher, err := stdout.NewExportPipeline(stdout.Config{
PrettyPrint: true,
DoNotPrintTime: true, // This makes the output deterministic
})
}, time.Second)
if err != nil {
panic(fmt.Sprintln("Could not initialize stdout exporter:", err))
}
Expand Down