opentelemetry-collector-contrib icon indicating copy to clipboard operation
opentelemetry-collector-contrib copied to clipboard

[mongodbreceiver] change 'Hosts' configuration type

Open li-zeyuan opened this issue 4 months ago • 2 comments

Description: <Describe what has changed.>

what changed:mongodbreceiver Hosts configuration use confignet.TCPAddrConfig.

Hi master, I looked at the mongodbreceiver code:

  1. The error is caused by AddrConfig.Validate() return error.
func (na *AddrConfig) Validate() error {
	switch na.Transport {
	case TransportTypeTCP,
		...
		return nil
	default:
		return fmt.Errorf("invalid transport type %q", na.Transport)
	}
}
  1. mongodbreceiver use go.mongodb.org/mongo-driverto connect mongodb.

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/mongodbreceiver/go.mod#L13

module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver

go 1.21

require (
	...
	go.mongodb.org/mongo-driver v1.15.0
	...
)
  1. go.mongodb.org/mongo-driver based on TCP.

https://github.com/mongodb/mongo-go-driver/blob/v1/x/mongo/driver/dns/dns.go#L82

_, addresses, err := r.LookupSRV(srvName, "tcp", host)

So I think mongodbreceiver only supporting TCP.

Link to tracking Issue: <Issue number if applicable> https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32199

li-zeyuan avatar Apr 19 '24 06:04 li-zeyuan

Hi @TylerHelmuth , Thanks for your suggestion, the last commit has been fixed

li-zeyuan avatar Apr 23 '24 02:04 li-zeyuan

Please make corresponding changes to the README. The example still shows setting transport: tcp. I think we should also add a note to the parameters section stating that the transport option is no longer available.

djaglowski avatar Apr 24 '24 14:04 djaglowski