factory.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package zipkinreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver"
  4. import (
  5. "context"
  6. "go.opentelemetry.io/collector/component"
  7. "go.opentelemetry.io/collector/config/confighttp"
  8. "go.opentelemetry.io/collector/consumer"
  9. "go.opentelemetry.io/collector/receiver"
  10. "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver/internal/metadata"
  11. )
  12. // This file implements factory for Zipkin receiver.
  13. const (
  14. defaultBindEndpoint = "0.0.0.0:9411"
  15. )
  16. // NewFactory creates a new Zipkin receiver factory
  17. func NewFactory() receiver.Factory {
  18. return receiver.NewFactory(
  19. metadata.Type,
  20. createDefaultConfig,
  21. receiver.WithTraces(createTracesReceiver, metadata.TracesStability),
  22. )
  23. }
  24. // createDefaultConfig creates the default configuration for Zipkin receiver.
  25. func createDefaultConfig() component.Config {
  26. return &Config{
  27. HTTPServerSettings: confighttp.HTTPServerSettings{
  28. Endpoint: defaultBindEndpoint,
  29. },
  30. ParseStringTags: false,
  31. }
  32. }
  33. // createTracesReceiver creates a trace receiver based on provided config.
  34. func createTracesReceiver(
  35. _ context.Context,
  36. set receiver.CreateSettings,
  37. cfg component.Config,
  38. nextConsumer consumer.Traces,
  39. ) (receiver.Traces, error) {
  40. rCfg := cfg.(*Config)
  41. return newReceiver(rCfg, nextConsumer, set)
  42. }