Skip to content

Commit d7f2e27

Browse files
Removes deprecated ErrNilNextConsumer and solves type error for typeStr (#4250)
Co-authored-by: Phillip Carter <[email protected]>
1 parent 2f8c2de commit d7f2e27

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

content/en/docs/collector/building/receiver.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,11 @@ value for it so it can be used as part of the default settings.
397397
Go ahead and add the following code to your `factory.go` file:
398398

399399
```go
400+
var (
401+
typeStr = component.MustNewType("tailtracer")
402+
)
403+
400404
const (
401-
typeStr = "tailtracer"
402405
defaultInterval = 1 * time.Minute
403406
)
404407
```
@@ -433,8 +436,11 @@ import (
433436
"go.opentelemetry.io/collector/receiver"
434437
)
435438

439+
var (
440+
typeStr = component.MustNewType("tailtracer")
441+
)
442+
436443
const (
437-
typeStr = "tailtracer"
438444
defaultInterval = 1 * time.Minute
439445
)
440446

@@ -544,8 +550,11 @@ import (
544550
"go.opentelemetry.io/collector/receiver"
545551
)
546552

553+
var (
554+
typeStr = component.MustNewType("tailtracer")
555+
)
556+
547557
const (
548-
typeStr = "tailtracer"
549558
defaultInterval = 1 * time.Minute
550559
)
551560

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

863-
The Collector's API provides some standard error types to help the factory
864-
handle pipeline configurations. Your receiver factory should throw a
865-
`component.ErrNilNextConsumer` in case the next consumer has an issue and is
866-
passed as nil.
867-
868872
The `createTracesReceiver()` function will need a guard clause to make that
869873
validation.
870874

@@ -888,8 +892,11 @@ import (
888892
"go.opentelemetry.io/collector/receiver"
889893
)
890894

895+
var (
896+
typeStr = component.MustNewType("tailtracer")
897+
)
898+
891899
const (
892-
typeStr = "tailtracer"
893900
defaultInterval = 1 * time.Minute
894901
)
895902

@@ -900,9 +907,6 @@ func createDefaultConfig() component.Config {
900907
}
901908

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

907911
logger := params.Logger
908912
tailtracerCfg := baseCfg.(*Config)
@@ -927,8 +931,6 @@ func NewFactory() receiver.Factory {
927931

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

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

0 commit comments

Comments
 (0)