You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +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
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							569048591c
						
					
				
				
					commit
					bd0bba43b5
				
			| @@ -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) | ||||
|  | ||||
| @@ -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) | ||||
|   | ||||
| @@ -79,7 +79,7 @@ func initProvider() func() { | ||||
| 			simple.NewWithExactDistribution(), | ||||
| 			exp, | ||||
| 		), | ||||
| 		controller.WithPusher(exp), | ||||
| 		controller.WithExporter(exp), | ||||
| 		controller.WithCollectPeriod(2*time.Second), | ||||
| 	) | ||||
|  | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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") | ||||
|   | ||||
| @@ -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()) | ||||
|   | ||||
| @@ -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()) | ||||
|   | ||||
| @@ -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 | ||||
| @@ -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. | ||||
|   | ||||
| @@ -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. | ||||
| @@ -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 | ||||
| @@ -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{ | ||||
| @@ -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{}, | ||||
|  | ||||
| @@ -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 | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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() | ||||
| @@ -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() | ||||
|   | ||||
| @@ -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)) | ||||
| @@ -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) | ||||
| @@ -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), | ||||
| 	) | ||||
| @@ -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), | ||||
| 			) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user