You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-15 01:04:25 +02:00
exporter: swap pusher for exporter (#1656)
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>
This commit is contained in:
committed by
GitHub
parent
569048591c
commit
bd0bba43b5
@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- The SimpleSpanProcessor will now shut down the enclosed `SpanExporter` and gracefully ignore subsequent calls to `OnEnd` after `Shutdown` is called. (#1612)
|
- 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)
|
- Added non-empty string check for trace `Attribute` keys. (#1659)
|
||||||
- Add `description` to SpanStatus only when `StatusCode` is set to error. (#1662)
|
- Add `description` to SpanStatus only when `StatusCode` is set to error. (#1662)
|
||||||
|
|
||||||
@ -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".ReadOnlySpan
|
||||||
"otel/sdk/trace".ReadWriteSpan
|
"otel/sdk/trace".ReadWriteSpan
|
||||||
```
|
```
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- Removed attempt to resample spans upon changing the span name with `span.SetName()`. (#1545)
|
- Removed attempt to resample spans upon changing the span name with `span.SetName()`. (#1545)
|
||||||
|
@ -79,7 +79,7 @@ func initProvider() func() {
|
|||||||
simple.NewWithExactDistribution(),
|
simple.NewWithExactDistribution(),
|
||||||
exp,
|
exp,
|
||||||
),
|
),
|
||||||
controller.WithPusher(exp),
|
controller.WithExporter(exp),
|
||||||
controller.WithCollectPeriod(2*time.Second),
|
controller.WithCollectPeriod(2*time.Second),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func initMeter() {
|
|||||||
processor.WithMemory(true),
|
processor.WithMemory(true),
|
||||||
),
|
),
|
||||||
controller.WithResource(res),
|
controller.WithResource(res),
|
||||||
controller.WithPusher(otlpExporter),
|
controller.WithExporter(otlpExporter),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := cont.Start(context.Background()); err != nil {
|
if err := cont.Start(context.Background()); err != nil {
|
||||||
|
@ -76,7 +76,7 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlp.Exporter, mcTr
|
|||||||
|
|
||||||
selector := simple.NewWithInexpensiveDistribution()
|
selector := simple.NewWithInexpensiveDistribution()
|
||||||
processor := processor.New(selector, exportmetric.StatelessExportKindSelector())
|
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))
|
require.NoError(t, cont.Start(ctx))
|
||||||
|
|
||||||
meter := cont.MeterProvider().Meter("test-meter")
|
meter := cont.MeterProvider().Meter("test-meter")
|
||||||
|
@ -185,7 +185,7 @@ func Example_withDifferentSignalCollectors() {
|
|||||||
simple.NewWithExactDistribution(),
|
simple.NewWithExactDistribution(),
|
||||||
exp,
|
exp,
|
||||||
),
|
),
|
||||||
controller.WithPusher(exp),
|
controller.WithExporter(exp),
|
||||||
controller.WithCollectPeriod(2*time.Second),
|
controller.WithCollectPeriod(2*time.Second),
|
||||||
)
|
)
|
||||||
global.SetMeterProvider(pusher.MeterProvider())
|
global.SetMeterProvider(pusher.MeterProvider())
|
||||||
|
@ -67,7 +67,7 @@ func NewExportPipeline(exportOpts []Option, pushOpts []controller.Option) (trace
|
|||||||
),
|
),
|
||||||
append(
|
append(
|
||||||
pushOpts,
|
pushOpts,
|
||||||
controller.WithPusher(exporter),
|
controller.WithExporter(exporter),
|
||||||
)...,
|
)...,
|
||||||
)
|
)
|
||||||
err = pusher.Start(context.Background())
|
err = pusher.Start(context.Background())
|
||||||
|
@ -46,13 +46,13 @@ type Config struct {
|
|||||||
// Default value is 10s. If zero, no Collect timeout is applied.
|
// Default value is 10s. If zero, no Collect timeout is applied.
|
||||||
CollectTimeout time.Duration
|
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
|
// Note: Exporters such as Prometheus that pull data do not implement
|
||||||
// export.Exporter. These will directly call Collect() and ForEach().
|
// 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.
|
// Default value is 10s. If zero, no Export timeout is applied.
|
||||||
PushTimeout time.Duration
|
PushTimeout time.Duration
|
||||||
@ -97,15 +97,15 @@ func (o collectTimeoutOption) Apply(config *Config) {
|
|||||||
config.CollectTimeout = time.Duration(o)
|
config.CollectTimeout = time.Duration(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPusher sets the Pusher configuration option of a Config.
|
// WithExporter sets the exporter configuration option of a Config.
|
||||||
func WithPusher(pusher export.Exporter) Option {
|
func WithExporter(exporter export.Exporter) Option {
|
||||||
return pusherOption{pusher}
|
return exporterOption{exporter}
|
||||||
}
|
}
|
||||||
|
|
||||||
type pusherOption struct{ pusher export.Exporter }
|
type exporterOption struct{ exporter export.Exporter }
|
||||||
|
|
||||||
func (o pusherOption) Apply(config *Config) {
|
func (o exporterOption) Apply(config *Config) {
|
||||||
config.Pusher = o.pusher
|
config.Exporter = o.exporter
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPushTimeout sets the PushTimeout configuration option of a Config.
|
// WithPushTimeout sets the PushTimeout configuration option of a Config.
|
||||||
|
@ -44,7 +44,7 @@ var ErrControllerStarted = fmt.Errorf("controller already started")
|
|||||||
// both "pull" and "push" configurations. This supports two distinct
|
// both "pull" and "push" configurations. This supports two distinct
|
||||||
// modes:
|
// 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
|
// Collect() is called periodically by a background thread after starting
|
||||||
// the controller.
|
// the controller.
|
||||||
// - Pull-Only: Start() is optional in this case, to call Collect periodically.
|
// - Pull-Only: Start() is optional in this case, to call Collect periodically.
|
||||||
@ -59,7 +59,7 @@ type Controller struct {
|
|||||||
accumulator *sdk.Accumulator
|
accumulator *sdk.Accumulator
|
||||||
provider *registry.MeterProvider
|
provider *registry.MeterProvider
|
||||||
checkpointer export.Checkpointer
|
checkpointer export.Checkpointer
|
||||||
pusher export.Exporter
|
exporter export.Exporter
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
stopCh chan struct{}
|
stopCh chan struct{}
|
||||||
clock controllerTime.Clock
|
clock controllerTime.Clock
|
||||||
@ -70,12 +70,12 @@ type Controller struct {
|
|||||||
pushTimeout time.Duration
|
pushTimeout time.Duration
|
||||||
|
|
||||||
// collectedTime is used only in configurations with no
|
// collectedTime is used only in configurations with no
|
||||||
// pusher, when ticker != nil.
|
// exporter, when ticker != nil.
|
||||||
collectedTime time.Time
|
collectedTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// New constructs a Controller using the provided checkpointer and
|
// 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.
|
// export pipeline.
|
||||||
func New(checkpointer export.Checkpointer, opts ...Option) *Controller {
|
func New(checkpointer export.Checkpointer, opts ...Option) *Controller {
|
||||||
c := &Config{
|
c := &Config{
|
||||||
@ -98,7 +98,7 @@ func New(checkpointer export.Checkpointer, opts ...Option) *Controller {
|
|||||||
provider: registry.NewMeterProvider(impl),
|
provider: registry.NewMeterProvider(impl),
|
||||||
accumulator: impl,
|
accumulator: impl,
|
||||||
checkpointer: checkpointer,
|
checkpointer: checkpointer,
|
||||||
pusher: c.Pusher,
|
exporter: c.Exporter,
|
||||||
stopCh: nil,
|
stopCh: nil,
|
||||||
clock: controllerTime.RealClock{},
|
clock: controllerTime.RealClock{},
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ func (c *Controller) collect(ctx context.Context) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c.pusher == nil {
|
if c.exporter == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Note: this is not subject to collectTimeout. This blocks the next
|
// Note: this is not subject to collectTimeout. This blocks the next
|
||||||
@ -259,7 +259,7 @@ func (c *Controller) export(ctx context.Context) error {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.pusher.Export(ctx, ckpt)
|
return c.exporter.Export(ctx, ckpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foreach gives the caller read-locked access to the current
|
// Foreach gives the caller read-locked access to the current
|
||||||
|
@ -284,7 +284,7 @@ func TestExportTimeout(t *testing.T) {
|
|||||||
),
|
),
|
||||||
controller.WithCollectPeriod(time.Second),
|
controller.WithCollectPeriod(time.Second),
|
||||||
controller.WithPushTimeout(time.Millisecond),
|
controller.WithPushTimeout(time.Millisecond),
|
||||||
controller.WithPusher(exporter),
|
controller.WithExporter(exporter),
|
||||||
controller.WithResource(resource.Empty()),
|
controller.WithResource(resource.Empty()),
|
||||||
)
|
)
|
||||||
mock := controllertest.NewMockClock()
|
mock := controllertest.NewMockClock()
|
||||||
@ -340,7 +340,7 @@ func TestCollectAfterStopThenStartAgain(t *testing.T) {
|
|||||||
exp,
|
exp,
|
||||||
),
|
),
|
||||||
controller.WithCollectPeriod(time.Second),
|
controller.WithCollectPeriod(time.Second),
|
||||||
controller.WithPusher(exp),
|
controller.WithExporter(exp),
|
||||||
controller.WithResource(resource.Empty()),
|
controller.WithResource(resource.Empty()),
|
||||||
)
|
)
|
||||||
mock := controllertest.NewMockClock()
|
mock := controllertest.NewMockClock()
|
||||||
|
@ -85,7 +85,7 @@ func TestPushDoubleStop(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
exporter := newExporter()
|
exporter := newExporter()
|
||||||
checkpointer := newCheckpointer()
|
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.Start(ctx))
|
||||||
require.NoError(t, p.Stop(ctx))
|
require.NoError(t, p.Stop(ctx))
|
||||||
require.NoError(t, p.Stop(ctx))
|
require.NoError(t, p.Stop(ctx))
|
||||||
@ -95,7 +95,7 @@ func TestPushDoubleStart(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
exporter := newExporter()
|
exporter := newExporter()
|
||||||
checkpointer := newCheckpointer()
|
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.Start(ctx))
|
||||||
err := p.Start(ctx)
|
err := p.Start(ctx)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@ -108,7 +108,7 @@ func TestPushTicker(t *testing.T) {
|
|||||||
checkpointer := newCheckpointer()
|
checkpointer := newCheckpointer()
|
||||||
p := controller.New(
|
p := controller.New(
|
||||||
checkpointer,
|
checkpointer,
|
||||||
controller.WithPusher(exporter),
|
controller.WithExporter(exporter),
|
||||||
controller.WithCollectPeriod(time.Second),
|
controller.WithCollectPeriod(time.Second),
|
||||||
controller.WithResource(testResource),
|
controller.WithResource(testResource),
|
||||||
)
|
)
|
||||||
@ -188,7 +188,7 @@ func TestPushExportError(t *testing.T) {
|
|||||||
checkpointer := processor.New(processortest.AggregatorSelector(), exporter)
|
checkpointer := processor.New(processortest.AggregatorSelector(), exporter)
|
||||||
p := controller.New(
|
p := controller.New(
|
||||||
checkpointer,
|
checkpointer,
|
||||||
controller.WithPusher(exporter),
|
controller.WithExporter(exporter),
|
||||||
controller.WithCollectPeriod(time.Second),
|
controller.WithCollectPeriod(time.Second),
|
||||||
controller.WithResource(testResource),
|
controller.WithResource(testResource),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user