@@ -5,6 +5,7 @@ package connector // import "go.opentelemetry.io/collector/connector"
5
5
6
6
import (
7
7
"context"
8
+ "errors"
8
9
"fmt"
9
10
10
11
"go.uber.org/zap"
@@ -13,6 +14,10 @@ import (
13
14
"go.opentelemetry.io/collector/consumer"
14
15
)
15
16
17
+ var (
18
+ errNilNextConsumer = errors .New ("nil next Consumer" )
19
+ )
20
+
16
21
// A Traces connector acts as an exporter from a traces pipeline and a receiver
17
22
// to one or more traces, metrics, or logs pipelines.
18
23
// Traces feeds a consumer.Traces, consumer.Metrics, or consumer.Logs with data.
@@ -456,6 +461,9 @@ func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.
456
461
457
462
// CreateTracesToTraces creates a Traces connector based on the settings and config.
458
463
func (b * Builder ) CreateTracesToTraces (ctx context.Context , set CreateSettings , next consumer.Traces ) (Traces , error ) {
464
+ if next == nil {
465
+ return nil , errNilNextConsumer
466
+ }
459
467
cfg , existsCfg := b .cfgs [set .ID ]
460
468
if ! existsCfg {
461
469
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -472,6 +480,9 @@ func (b *Builder) CreateTracesToTraces(ctx context.Context, set CreateSettings,
472
480
473
481
// CreateTracesToMetrics creates a Traces connector based on the settings and config.
474
482
func (b * Builder ) CreateTracesToMetrics (ctx context.Context , set CreateSettings , next consumer.Metrics ) (Traces , error ) {
483
+ if next == nil {
484
+ return nil , errNilNextConsumer
485
+ }
475
486
cfg , existsCfg := b .cfgs [set .ID ]
476
487
if ! existsCfg {
477
488
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -488,6 +499,9 @@ func (b *Builder) CreateTracesToMetrics(ctx context.Context, set CreateSettings,
488
499
489
500
// CreateTracesToLogs creates a Traces connector based on the settings and config.
490
501
func (b * Builder ) CreateTracesToLogs (ctx context.Context , set CreateSettings , next consumer.Logs ) (Traces , error ) {
502
+ if next == nil {
503
+ return nil , errNilNextConsumer
504
+ }
491
505
cfg , existsCfg := b .cfgs [set .ID ]
492
506
if ! existsCfg {
493
507
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -504,6 +518,9 @@ func (b *Builder) CreateTracesToLogs(ctx context.Context, set CreateSettings, ne
504
518
505
519
// CreateMetricsToTraces creates a Metrics connector based on the settings and config.
506
520
func (b * Builder ) CreateMetricsToTraces (ctx context.Context , set CreateSettings , next consumer.Traces ) (Metrics , error ) {
521
+ if next == nil {
522
+ return nil , errNilNextConsumer
523
+ }
507
524
cfg , existsCfg := b .cfgs [set .ID ]
508
525
if ! existsCfg {
509
526
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -520,6 +537,9 @@ func (b *Builder) CreateMetricsToTraces(ctx context.Context, set CreateSettings,
520
537
521
538
// CreateMetricsToMetrics creates a Metrics connector based on the settings and config.
522
539
func (b * Builder ) CreateMetricsToMetrics (ctx context.Context , set CreateSettings , next consumer.Metrics ) (Metrics , error ) {
540
+ if next == nil {
541
+ return nil , errNilNextConsumer
542
+ }
523
543
cfg , existsCfg := b .cfgs [set .ID ]
524
544
if ! existsCfg {
525
545
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -536,6 +556,9 @@ func (b *Builder) CreateMetricsToMetrics(ctx context.Context, set CreateSettings
536
556
537
557
// CreateMetricsToLogs creates a Metrics connector based on the settings and config.
538
558
func (b * Builder ) CreateMetricsToLogs (ctx context.Context , set CreateSettings , next consumer.Logs ) (Metrics , error ) {
559
+ if next == nil {
560
+ return nil , errNilNextConsumer
561
+ }
539
562
cfg , existsCfg := b .cfgs [set .ID ]
540
563
if ! existsCfg {
541
564
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -552,6 +575,9 @@ func (b *Builder) CreateMetricsToLogs(ctx context.Context, set CreateSettings, n
552
575
553
576
// CreateLogsToTraces creates a Logs connector based on the settings and config.
554
577
func (b * Builder ) CreateLogsToTraces (ctx context.Context , set CreateSettings , next consumer.Traces ) (Logs , error ) {
578
+ if next == nil {
579
+ return nil , errNilNextConsumer
580
+ }
555
581
cfg , existsCfg := b .cfgs [set .ID ]
556
582
if ! existsCfg {
557
583
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -568,6 +594,9 @@ func (b *Builder) CreateLogsToTraces(ctx context.Context, set CreateSettings, ne
568
594
569
595
// CreateLogsToMetrics creates a Logs connector based on the settings and config.
570
596
func (b * Builder ) CreateLogsToMetrics (ctx context.Context , set CreateSettings , next consumer.Metrics ) (Logs , error ) {
597
+ if next == nil {
598
+ return nil , errNilNextConsumer
599
+ }
571
600
cfg , existsCfg := b .cfgs [set .ID ]
572
601
if ! existsCfg {
573
602
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
@@ -584,6 +613,9 @@ func (b *Builder) CreateLogsToMetrics(ctx context.Context, set CreateSettings, n
584
613
585
614
// CreateLogsToLogs creates a Logs connector based on the settings and config.
586
615
func (b * Builder ) CreateLogsToLogs (ctx context.Context , set CreateSettings , next consumer.Logs ) (Logs , error ) {
616
+ if next == nil {
617
+ return nil , errNilNextConsumer
618
+ }
587
619
cfg , existsCfg := b .cfgs [set .ID ]
588
620
if ! existsCfg {
589
621
return nil , fmt .Errorf ("connector %q is not configured" , set .ID )
0 commit comments