Skip to content

Commit

Permalink
remove exporter key
Browse files Browse the repository at this point in the history
  • Loading branch information
timannguyen committed May 23, 2024
1 parent 71e54c9 commit 8305715
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
11 changes: 4 additions & 7 deletions exporter/exporterhelper/batch_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterbatcher"
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
)

// batchSender is a component that places requests into batches before passing them to the downstream senders.
Expand All @@ -39,8 +38,7 @@ type batchSender struct {
mu sync.Mutex
activeBatch *batch

fullName string
logger *zap.Logger
logger *zap.Logger

shutdownCh chan struct{}
stopped *atomic.Bool
Expand All @@ -50,7 +48,6 @@ type batchSender struct {
func newBatchSender(cfg exporterbatcher.Config, set exporter.CreateSettings,
mf exporterbatcher.BatchMergeFunc[Request], msf exporterbatcher.BatchMergeSplitFunc[Request]) *batchSender {
bs := &batchSender{
fullName: set.ID.String(),
activeBatch: newEmptyBatch(),
cfg: cfg,
logger: set.Logger,
Expand Down Expand Up @@ -94,7 +91,7 @@ func (bs *batchSender) Start(_ context.Context, _ component.Host) error {
}
}()

bs.logger.Debug("Started Batch Sender", zap.String(obsmetrics.ExporterKey, bs.fullName))
bs.logger.Debug("Started Batch Sender")
return nil
}

Expand Down Expand Up @@ -217,7 +214,7 @@ func (bs *batchSender) updateActiveBatch(ctx context.Context, req Request) {
}

func (bs *batchSender) Shutdown(context.Context) error {
bs.logger.Debug("Shutting down Batch Sender", zap.String(obsmetrics.ExporterKey, bs.fullName))
bs.logger.Debug("Shutting down Batch Sender")

bs.stopped.Store(true)
close(bs.shutdownCh)
Expand All @@ -226,6 +223,6 @@ func (bs *batchSender) Shutdown(context.Context) error {
time.Sleep(10 * time.Millisecond)
}

bs.logger.Debug("Batch Sender has been shutdown", zap.String(obsmetrics.ExporterKey, bs.fullName))
bs.logger.Debug("Batch Sender has been shutdown")
return nil
}
8 changes: 4 additions & 4 deletions exporter/exporterhelper/queue_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func newQueueSender(q exporterqueue.Queue[Request], set exporter.CreateSettings,

// Start is invoked during service startup.
func (qs *queueSender) Start(ctx context.Context, host component.Host) error {
qs.logger.Debug("Starting Queue Sender", zap.String(obsmetrics.ExporterKey, qs.fullName))
qs.logger.Debug("Starting Queue Sender")

if err := qs.consumers.Start(ctx, host); err != nil {
return err
Expand Down Expand Up @@ -139,19 +139,19 @@ func (qs *queueSender) Start(ctx context.Context, host component.Host) error {
return nil
}))

qs.logger.Debug("Started Queue Sender", zap.String(obsmetrics.ExporterKey, qs.fullName), zap.Error(err))
errs = multierr.Append(errs, err)
qs.logger.Debug("Started Queue Sender", zap.Error(errs))
return errs
}

// Shutdown is invoked during service shutdown.
func (qs *queueSender) Shutdown(ctx context.Context) error {
qs.logger.Debug("Shutting Down Queue Sender", zap.String(obsmetrics.ExporterKey, qs.fullName))
qs.logger.Debug("Shutting Down Queue Sender")

// Stop the queue and consumers, this will drain the queue and will call the retry (which is stopped) that will only
// try once every request.
err := qs.consumers.Shutdown(ctx)
qs.logger.Debug("Queue Sender has shut down", zap.String(obsmetrics.ExporterKey, qs.fullName), zap.Error(err))
qs.logger.Debug("Queue Sender has shut down", zap.Error(err))
return err
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/retry_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newRetrySender(config configretry.BackOffConfig, set exporter.CreateSetting

func (rs *retrySender) Shutdown(context.Context) error {
close(rs.stopCh)
rs.logger.Debug("Retry Sender has been shutdown", zap.String(obsmetrics.ExporterKey, rs.traceAttribute.Value.AsString()))
rs.logger.Debug("Retry Sender has been shutdown")
return nil
}

Expand Down

0 comments on commit 8305715

Please sign in to comment.