Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous import error with opentelemetry collector builder #10476

Open
zdelagrange opened this issue Jun 27, 2024 · 3 comments
Open

Ambiguous import error with opentelemetry collector builder #10476

zdelagrange opened this issue Jun 27, 2024 · 3 comments
Labels
area:builder bug Something isn't working

Comments

@zdelagrange
Copy link

Describe the bug
cross posting from here: open-telemetry/opentelemetry.io#4738

After following the instructions up to Running and debugging the receiver
I get unexpected output

../go/pkg/mod/google.golang.org/[email protected]/status/status.go:35:2: ambiguous import: found package google.golang.org/genproto/googleapis/rpc/status in multiple modules:
	google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 (/home/hanyang/go/pkg/mod/google.golang.org/[email protected]/googleapis/rpc/status)
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 (/home/hanyang/go/pkg/mod/google.golang.org/genproto/googleapis/[email protected]/status)
../go/pkg/mod/go.opentelemetry.io/collector/exporter/[email protected]/otlp.go:13:2: ambiguous import: found package google.golang.org/genproto/googleapis/rpc/errdetails in multiple modules:
	google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 (/home/hanyang/go/pkg/mod/google.golang.org/[email protected]/googleapis/rpc/errdetails)
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 (/home/hanyang/go/pkg/mod/google.golang.org/genproto/googleapis/[email protected]/errdetails)
../go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/[email protected]/runtime/handler.go:12:2: ambiguous import: found package google.golang.org/genproto/googleapis/api/httpbody in multiple modules:
	google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 (/home/hanyang/go/pkg/mod/google.golang.org/[email protected]/googleapis/api/httpbody)
	google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 (/home/hanyang/go/pkg/mod/google.golang.org/genproto/googleapis/[email protected]/httpbody)
when running the  go run ./otelcol-dev --config config.yaml from the instructions

Steps to reproduce
Builder conf:

  name: otelcol-deb
  description: otel collector distribution for tenable
  output_path: ./otelcol-dev
  otelcol_version: 0.103.0

exporters:
  - gomod:
      go.opentelemetry.io/collector/exporter/debugexporter v0.103.0
  - gomod:
      go.opentelemetry.io/collector/exporter/otlpexporter v0.103.0
processors:
  - gomod:
      go.opentelemetry.io/collector/processor/batchprocessor v0.103.0
receivers:
  - gomod:
      go.opentelemetry.io/collector/receiver/otlpreceiver v0.103.0```

**What did you expect to see?**
a clean build

**What did you see instead?**
ambiguous import error

**What version did you use?**
0.103.0

**What config did you use?**
<!-- Config: (e.g. the yaml config file) -->

**Environment**
macos with asdf golang install

**Additional context**
<!-- Add any other context about the problem here. -->
@zdelagrange zdelagrange added the bug Something isn't working label Jun 27, 2024
@mx-psi
Copy link
Member

mx-psi commented Jul 30, 2024

I am unable to reproduce with OCB v0.106.0 and the following manifest:

name: otelcol-deb
description: otel collector distribution for tenable
output_path: ./otelcol-dev
otelcol_version: 0.106.0

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.106.0
  - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.106.0
processors:
  - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.106.0
receivers:
  - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.106.0

I get the following logs:

2024-07-30T17:19:04.603+0200	INFO	internal/command.go:125	OpenTelemetry Collector Builder	{"version": "0.106.0", "date": "2024-07-29T19:36:07Z"}
2024-07-30T17:19:04.605+0200	INFO	internal/command.go:161	Using config file	{"path": "manifest.yaml"}
2024-07-30T17:19:04.605+0200	INFO	builder/config.go:142	Using go	{"go-executable": "/home/pablo.baeyens/.gvm/gos/go1.22.4/bin/go"}
2024-07-30T17:19:04.606+0200	INFO	builder/main.go:100	Sources created	{"path": "/tmp/otelcol-distribution2888401949"}
2024-07-30T17:19:04.846+0200	INFO	builder/main.go:191	Getting go modules
2024-07-30T17:19:04.896+0200	INFO	builder/main.go:111	Compiling
2024-07-30T17:19:07.021+0200	INFO	builder/main.go:130	Compiled	{"binary": "/tmp/otelcol-distribution2888401949/otelcol-custom"}

@evan361425
Copy link

evan361425 commented Aug 8, 2024

You got same module but different versions, try force the version in go.mod. Something like:

require (
  // you should use the desired version in the error log
  google.golang.org/genproto v0.0.0-20240520151616-dc85e6b867a5
)

If you want to avoid go mod tidy discard your changes, try import any modules of the package, for example type/date:

// This is necessary to avoid ambiguous import error
// see https://github.com/open-telemetry/opentelemetry-collector/issues/10476
import _ "google.golang.org/genproto/googleapis/type/date"

@mattjohnsonpint
Copy link

I encountered the same issue, and found that the following fixed it:

go get google.golang.org/genproto/googleapis/api
go mod tidy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:builder bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants