@@ -397,8 +397,11 @@ value for it so it can be used as part of the default settings.
397
397
Go ahead and add the following code to your `factory.go` file:
398
398
399
399
```go
400
+ var (
401
+ typeStr = component.MustNewType("tailtracer")
402
+ )
403
+
400
404
const (
401
- typeStr = "tailtracer"
402
405
defaultInterval = 1 * time.Minute
403
406
)
404
407
```
@@ -433,8 +436,11 @@ import (
433
436
" go.opentelemetry.io/collector/receiver"
434
437
)
435
438
439
+ var (
440
+ typeStr = component.MustNewType (" tailtracer" )
441
+ )
442
+
436
443
const (
437
- typeStr = " tailtracer"
438
444
defaultInterval = 1 * time.Minute
439
445
)
440
446
@@ -544,8 +550,11 @@ import (
544
550
" go.opentelemetry.io/collector/receiver"
545
551
)
546
552
553
+ var (
554
+ typeStr = component.MustNewType (" tailtracer" )
555
+ )
556
+
547
557
const (
548
- typeStr = " tailtracer"
549
558
defaultInterval = 1 * time.Minute
550
559
)
551
560
@@ -860,11 +869,6 @@ pipeline and the factory is responsible to make sure the next consumer (either a
860
869
processor or exporter) in the pipeline is valid otherwise it should generate an
861
870
error.
862
871
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
-
868
872
The ` createTracesReceiver() ` function will need a guard clause to make that
869
873
validation.
870
874
@@ -888,8 +892,11 @@ import (
888
892
" go.opentelemetry.io/collector/receiver"
889
893
)
890
894
895
+ var (
896
+ typeStr = component.MustNewType (" tailtracer" )
897
+ )
898
+
891
899
const (
892
- typeStr = " tailtracer"
893
900
defaultInterval = 1 * time.Minute
894
901
)
895
902
@@ -900,9 +907,6 @@ func createDefaultConfig() component.Config {
900
907
}
901
908
902
909
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
- }
906
910
907
911
logger := params.Logger
908
912
tailtracerCfg := baseCfg.(*Config)
@@ -927,8 +931,6 @@ func NewFactory() receiver.Factory {
927
931
928
932
{{% alert title="Check your work" color="primary" %}}
929
933
930
- - Added a guard clause that verifies if the consumer is properly instantiated
931
- and if not returns the ` component.ErrNilNextConsumer ` error.
932
934
- Added a variable called ` logger ` and initialized it with the Collector's
933
935
logger that is available as a field named ` Logger ` within the
934
936
` receiver.CreateSettings ` reference.
0 commit comments