Skip to content

Commit

Permalink
log useful error when receiver creation fails. (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
rghetia authored and Paulo Janotti committed Dec 4, 2019
1 parent 84c996b commit 28e7622
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bin/

# GoLand IDEA
/.idea/
*.iml

# VS Code
.vscode
Expand Down
16 changes: 5 additions & 11 deletions service/builder/receivers_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,9 @@ func (rb *ReceiversBuilder) attachReceiverToPipelines(
// Now create the receiver and tell it to send to the junction point.
rcv.trace, err = factory.CreateTraceReceiver(context.Background(), rb.logger, config, junction)

// Check if the factory really created the receiver.
if rcv.trace == nil {
return fmt.Errorf("factory for %q produced a nil receiver", config.Name())
}

case configmodels.MetricsDataType:
junction := buildFanoutMetricConsumer(builtPipelines)
rcv.metrics, err = factory.CreateMetricsReceiver(rb.logger, config, junction)

// The factories can be implemented by third parties, check if they really
// created the exporter.
if rcv.metrics == nil {
return fmt.Errorf("factory for %q produced a nil receiver", config.Name())
}
}

if err != nil {
Expand All @@ -220,6 +209,11 @@ func (rb *ReceiversBuilder) attachReceiverToPipelines(
return fmt.Errorf("cannot create receiver %s: %s", config.Name(), err.Error())
}

// Check if the factory really created the receiver.
if rcv.trace == nil && rcv.metrics == nil {
return fmt.Errorf("factory for %q produced a nil receiver", config.Name())
}

rb.logger.Info("Receiver is enabled.",
zap.String("receiver", config.Name()), zap.String("datatype", dataType.GetString()))

Expand Down

0 comments on commit 28e7622

Please sign in to comment.