Skip to content

Commit

Permalink
exporter: swap pusher for exporter (open-telemetry#1656)
Browse files Browse the repository at this point in the history
to provide consistent naming across the code base, deprecate pusher in
favor of exporter naming convention.

Signed-off-by: ldelossa <ldelossa@redhat.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
ldelossa and MrAlias committed Mar 8, 2021
1 parent 5690485 commit bd0bba4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed

- The SimpleSpanProcessor will now shut down the enclosed `SpanExporter` and gracefully ignore subsequent calls to `OnEnd` after `Shutdown` is called. (#1612)
- `"go.opentelemetry.io/sdk/metric/controller.basic".WithPusher` is replaced with `WithExporter` to provide consistent naming across project. (#1656)
- Added non-empty string check for trace `Attribute` keys. (#1659)
- Add `description` to SpanStatus only when `StatusCode` is set to error. (#1662)

Expand Down Expand Up @@ -76,7 +77,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
"otel/sdk/trace".ReadOnlySpan
"otel/sdk/trace".ReadWriteSpan
```

### Removed

- Removed attempt to resample spans upon changing the span name with `span.SetName()`. (#1545)
Expand Down
2 changes: 1 addition & 1 deletion example/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func initProvider() func() {
simple.NewWithExactDistribution(),
exp,
),
controller.WithPusher(exp),
controller.WithExporter(exp),
controller.WithCollectPeriod(2*time.Second),
)

Expand Down
2 changes: 1 addition & 1 deletion example/prom-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func initMeter() {
processor.WithMemory(true),
),
controller.WithResource(res),
controller.WithPusher(otlpExporter),
controller.WithExporter(otlpExporter),
)

if err := cont.Start(context.Background()); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/internal/otlptest/otlptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlp.Exporter, mcTr

selector := simple.NewWithInexpensiveDistribution()
processor := processor.New(selector, exportmetric.StatelessExportKindSelector())
cont := controller.New(processor, controller.WithPusher(exp))
cont := controller.New(processor, controller.WithExporter(exp))
require.NoError(t, cont.Start(ctx))

meter := cont.MeterProvider().Meter("test-meter")
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpgrpc/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func Example_withDifferentSignalCollectors() {
simple.NewWithExactDistribution(),
exp,
),
controller.WithPusher(exp),
controller.WithExporter(exp),
controller.WithCollectPeriod(2*time.Second),
)
global.SetMeterProvider(pusher.MeterProvider())
Expand Down
2 changes: 1 addition & 1 deletion exporters/stdout/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewExportPipeline(exportOpts []Option, pushOpts []controller.Option) (trace
),
append(
pushOpts,
controller.WithPusher(exporter),
controller.WithExporter(exporter),
)...,
)
err = pusher.Start(context.Background())
Expand Down
18 changes: 9 additions & 9 deletions sdk/metric/controller/basic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ type Config struct {
// Default value is 10s. If zero, no Collect timeout is applied.
CollectTimeout time.Duration

// Pusher is used for exporting metric data.
// Exporter 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
Exporter export.Exporter

// PushTimeout is the timeout of the Context when a Pusher is configured.
// PushTimeout is the timeout of the Context when a exporter is configured.
//
// Default value is 10s. If zero, no Export timeout is applied.
PushTimeout time.Duration
Expand Down Expand Up @@ -97,15 +97,15 @@ 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}
// WithExporter sets the exporter configuration option of a Config.
func WithExporter(exporter export.Exporter) Option {
return exporterOption{exporter}
}

type pusherOption struct{ pusher export.Exporter }
type exporterOption struct{ exporter export.Exporter }

func (o pusherOption) Apply(config *Config) {
config.Pusher = o.pusher
func (o exporterOption) Apply(config *Config) {
config.Exporter = o.exporter
}

// WithPushTimeout sets the PushTimeout configuration option of a Config.
Expand Down
14 changes: 7 additions & 7 deletions sdk/metric/controller/basic/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var ErrControllerStarted = fmt.Errorf("controller already started")
// both "pull" and "push" configurations. This supports two distinct
// modes:
//
// - Push and Pull: Start() must be called to begin calling the pusher;
// - Push and Pull: Start() must be called to begin calling the exporter;
// Collect() is called periodically by a background thread after starting
// the controller.
// - Pull-Only: Start() is optional in this case, to call Collect periodically.
Expand All @@ -59,7 +59,7 @@ type Controller struct {
accumulator *sdk.Accumulator
provider *registry.MeterProvider
checkpointer export.Checkpointer
pusher export.Exporter
exporter export.Exporter
wg sync.WaitGroup
stopCh chan struct{}
clock controllerTime.Clock
Expand All @@ -70,12 +70,12 @@ type Controller struct {
pushTimeout time.Duration

// collectedTime is used only in configurations with no
// pusher, when ticker != nil.
// exporter, when ticker != nil.
collectedTime time.Time
}

// New constructs a Controller using the provided checkpointer and
// options (including optional Pusher) to configure a metric
// options (including optional exporter) to configure a metric
// export pipeline.
func New(checkpointer export.Checkpointer, opts ...Option) *Controller {
c := &Config{
Expand All @@ -98,7 +98,7 @@ func New(checkpointer export.Checkpointer, opts ...Option) *Controller {
provider: registry.NewMeterProvider(impl),
accumulator: impl,
checkpointer: checkpointer,
pusher: c.Pusher,
exporter: c.Exporter,
stopCh: nil,
clock: controllerTime.RealClock{},

Expand Down Expand Up @@ -193,7 +193,7 @@ func (c *Controller) collect(ctx context.Context) error {
}); err != nil {
return err
}
if c.pusher == nil {
if c.exporter == nil {
return nil
}
// Note: this is not subject to collectTimeout. This blocks the next
Expand Down Expand Up @@ -259,7 +259,7 @@ func (c *Controller) export(ctx context.Context) error {
defer cancel()
}

return c.pusher.Export(ctx, ckpt)
return c.exporter.Export(ctx, ckpt)
}

// Foreach gives the caller read-locked access to the current
Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/controller/basic/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func TestExportTimeout(t *testing.T) {
),
controller.WithCollectPeriod(time.Second),
controller.WithPushTimeout(time.Millisecond),
controller.WithPusher(exporter),
controller.WithExporter(exporter),
controller.WithResource(resource.Empty()),
)
mock := controllertest.NewMockClock()
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestCollectAfterStopThenStartAgain(t *testing.T) {
exp,
),
controller.WithCollectPeriod(time.Second),
controller.WithPusher(exp),
controller.WithExporter(exp),
controller.WithResource(resource.Empty()),
)
mock := controllertest.NewMockClock()
Expand Down
8 changes: 4 additions & 4 deletions sdk/metric/controller/basic/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestPushDoubleStop(t *testing.T) {
ctx := context.Background()
exporter := newExporter()
checkpointer := newCheckpointer()
p := controller.New(checkpointer, controller.WithPusher(exporter))
p := controller.New(checkpointer, controller.WithExporter(exporter))
require.NoError(t, p.Start(ctx))
require.NoError(t, p.Stop(ctx))
require.NoError(t, p.Stop(ctx))
Expand All @@ -95,7 +95,7 @@ func TestPushDoubleStart(t *testing.T) {
ctx := context.Background()
exporter := newExporter()
checkpointer := newCheckpointer()
p := controller.New(checkpointer, controller.WithPusher(exporter))
p := controller.New(checkpointer, controller.WithExporter(exporter))
require.NoError(t, p.Start(ctx))
err := p.Start(ctx)
require.Error(t, err)
Expand All @@ -108,7 +108,7 @@ func TestPushTicker(t *testing.T) {
checkpointer := newCheckpointer()
p := controller.New(
checkpointer,
controller.WithPusher(exporter),
controller.WithExporter(exporter),
controller.WithCollectPeriod(time.Second),
controller.WithResource(testResource),
)
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestPushExportError(t *testing.T) {
checkpointer := processor.New(processortest.AggregatorSelector(), exporter)
p := controller.New(
checkpointer,
controller.WithPusher(exporter),
controller.WithExporter(exporter),
controller.WithCollectPeriod(time.Second),
controller.WithResource(testResource),
)
Expand Down

0 comments on commit bd0bba4

Please sign in to comment.