Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
>I am trying to make a custom receiver that will Collect and receive traces from applications and store it in MySQL database.(An alternative to zipkin). Later on will work on exporting them when asked.

So for my custom receiver this is the code I have written following the otel's official documentation

Link to code: GitHub - Umang01-hash/traceCollectorService[^]

Also after writing the receiver, I included it in components.go file inside otelcol-dev directory.

Changes in compoentns.go
Go
func components() (otelcol.Factories, error) {
    var err error
    factories := otelcol.Factories{}

    factories.Extensions, err = extension.MakeFactoryMap(
    )
    if err != nil {
        return otelcol.Factories{}, err
    }

    factories.Receivers, err = receiver.MakeFactoryMap(
        otlpreceiver.NewFactory(),
        traceCollectorService.NewReceiverFactory(),  // newly addded line
    )
    if err != nil {
        return otelcol.Factories{}, err
    }

And my conifg.yaml looks like this:
YAML
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
  traceCollectorService:
    interval: 1m
    number_of_traces: 1

processors:
  batch:

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    traces:
      receivers: [otlp, traceCollectorService]
      processors: [batch]
      exporters: [debug]
  telemetry:
    logs:
      level: debug

When trying to run it using this command :
./otelcol-dev --config ../config.yaml

Getting the following error:

Error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:

error decoding 'receivers': unknown type: "traceCollectorService" for id: "traceCollectorService" (valid values: [otlp]) 2024/03/20 16:22:02 collector server run finished with error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:

error decoding 'receivers': unknown type: "traceCollectorService" for id: "traceCollectorService" (valid values: [otlp])

Can someone please guide me on how to resolve it. I have checked there is proper consistency in naming of traceCollectorService. Also feel free to tell if anything is wrong in the receiver code. Thank you in advance.

What I have tried:

I have tried several methods like ensuring the naming traceCollectorService is proper throughout, and also renaming it or cleaning modcache and re-doing go mod tidy etc.
Posted
Updated 20-Mar-24 1:49am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900