Skip to content

Commit

Permalink
Removes deprecated ErrNilNextConsumer and solves type error for typeS…
Browse files Browse the repository at this point in the history
…tr in 0.97.0
  • Loading branch information
tarsojabbes authored Apr 4, 2024
1 parent b0210a9 commit 3a4dbaf
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions content/en/docs/collector/building/receiver.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ value for it so it can be used as part of the default settings.
Go ahead and add the following code to your `factory.go` file:

```go
const (
typeStr = "tailtracer"
var (
typeStr = component.MustNewType("tailtracer")
defaultInterval = 1 * time.Minute
)
```
Expand Down Expand Up @@ -433,8 +433,8 @@ import (
"go.opentelemetry.io/collector/receiver"
)

const (
typeStr = "tailtracer"
var (
typeStr = component.MustNewType("tailtracer")
defaultInterval = 1 * time.Minute
)

Expand Down Expand Up @@ -544,8 +544,8 @@ import (
"go.opentelemetry.io/collector/receiver"
)

const (
typeStr = "tailtracer"
var (
typeStr = component.MustNewType("tailtracer")
defaultInterval = 1 * time.Minute
)

Expand Down Expand Up @@ -860,11 +860,6 @@ pipeline and the factory is responsible to make sure the next consumer (either a
processor or exporter) in the pipeline is valid otherwise it should generate an
error.

The Collector's API provides some standard error types to help the factory
handle pipeline configurations. Your receiver factory should throw a
`component.ErrNilNextConsumer` in case the next consumer has an issue and is
passed as nil.

The `createTracesReceiver()` function will need a guard clause to make that
validation.

Expand All @@ -888,8 +883,8 @@ import (
"go.opentelemetry.io/collector/receiver"
)

const (
typeStr = "tailtracer"
var (
typeStr = component.MustNewType("tailtracer")
defaultInterval = 1 * time.Minute
)

Expand All @@ -900,9 +895,6 @@ func createDefaultConfig() component.Config {
}

func createTracesReceiver(_ context.Context, params receiver.CreateSettings, baseCfg component.Config, consumer consumer.Traces) (receiver.Traces, error) {
if consumer == nil {
return nil, component.ErrNilNextConsumer
}

logger := params.Logger
tailtracerCfg := baseCfg.(*Config)
Expand All @@ -927,8 +919,6 @@ func NewFactory() receiver.Factory {

{{% alert title="Check your work" color="primary" %}}

- Added a guard clause that verifies if the consumer is properly instantiated
and if not returns the `component.ErrNilNextConsumer`error.
- Added a variable called `logger` and initialized it with the Collector's
logger that is available as a field named `Logger` within the
`receiver.CreateSettings` reference.
Expand Down

0 comments on commit 3a4dbaf

Please sign in to comment.