Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes deprecated ErrNilNextConsumer and solves type error for typeStr #4250

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could leave defaultInterval as const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Can you take a second look?

```
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
Loading