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

Examples built with 'golang:alpine' Docker image no longer work #623

Open
matej-g opened this issue Mar 16, 2021 · 2 comments
Open

Examples built with 'golang:alpine' Docker image no longer work #623

matej-g opened this issue Mar 16, 2021 · 2 comments
Labels
bug Something isn't working
Projects

Comments

@matej-g
Copy link
Contributor

matej-g commented Mar 16, 2021

It seems that instrumentation examples which are based on the golang:alpine image can no longer be brought up with docker-compose.

Example from gin-gonic, which fails with:

Step 5/6 : RUN go install ./example/server.go
 ---> Running in dbf8d4e69071
go: downloading go.opentelemetry.io/otel v0.18.0
go: downloading github.com/gin-gonic/gin v1.6.3
go: downloading go.opentelemetry.io/otel/trace v0.18.0
go: downloading go.opentelemetry.io/otel/metric v0.18.0
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/go-playground/validator/v10 v10.2.0
go: downloading github.com/golang/protobuf v1.3.3
go: downloading github.com/ugorji/go v1.1.7
go: downloading gopkg.in/yaml.v2 v2.2.8
go: downloading golang.org/x/sys v0.0.0-20200116001909-b77594299b42go: downloading github.com/ugorji/go/codec v1.1.7
go: downloading github.com/leodido/go-urn v1.2.0
go: downloading github.com/go-playground/universal-translator v0.17.0
go: downloading github.com/go-playground/locales v0.13.0
example/server.go:27:2: no required module provides package go.opentelemetry.io/otel/exporters/stdout; to add it:
        go get go.opentelemetry.io/otel/exporters/stdout
example/server.go:29:2: no required module provides package go.opentelemetry.io/otel/sdk/trace; to add it:
        go get go.opentelemetry.io/otel/sdk/trace
ERROR: Service 'gin-server' failed to build: The command '/bin/sh -c go install ./example/server.go' returned a non-zero code: 1

Since this behavior is not present in examples built with golang:1.14-alpine, I presume the issue is related to the fact that the golang:alpine is now based on Go 1.16, which introduced some changes to module-aware mode for the go install command.

One possible way to fix this would be to ensure all examples use image version with Go version < 1.16. Otherwise it should be investigated what is the exact cause why Go fails to fetch the mentioned modules and how to mitigate it.

@matej-g matej-g changed the title Examples build with golang:alpine' Examples build with 'golang:alpine' Docker image no longer work Mar 16, 2021
@matej-g matej-g changed the title Examples build with 'golang:alpine' Docker image no longer work Examples built with 'golang:alpine' Docker image no longer work Mar 16, 2021
@matej-g
Copy link
Contributor Author

matej-g commented Mar 16, 2021

Or maybe rather this might give the right context:
https://blog.golang.org/go116-module-changes

In Go 1.16, module-aware commands report an error after discovering a problem in go.mod or go.sum instead of attempting to fix the problem automatically.

It seems like building with Go < 1.16 resolves the issue 'automatically' and fixes go.mod:

go: finding module for package go.opentelemetry.io/otel/exporters/stdout
go: finding module for package go.opentelemetry.io/otel/sdk/trace
go: found go.opentelemetry.io/otel/exporters/stdout in go.opentelemetry.io/otel/exporters/stdout v0.18.0
go: found go.opentelemetry.io/otel/sdk/trace in go.opentelemetry.io/otel/sdk v0.18.0

Whereas with Go 1.16 we are getting an error by default.

@MrAlias
Copy link
Contributor

MrAlias commented Mar 16, 2021

Thanks catching and documenting this!

Otherwise it should be investigated what is the exact cause why Go fails to fetch the mentioned modules and how to mitigate it.

This sounds like the appropriate resolution. That way we ensure other users that use Go 1.16 will not encounter this error as well. This also motivates me to add 1.16 to the versions we validate in our CI system.

@MrAlias MrAlias added the bug Something isn't working label Mar 16, 2021
@MrAlias MrAlias added this to Needs triage in Bugs via automation Mar 16, 2021
@MrAlias MrAlias moved this from Needs triage to High priority in Bugs Mar 16, 2021
plantfansam referenced this issue in plantfansam/opentelemetry-go-contrib Mar 18, 2022
Instead of batching based on the Resource pointer which is not guaranteed
to uniquely identify common Resources, use the `String` method which is.

Renames the external test package to be identified as the integration
testing. This testing structure (the mock exporter) batches exported
resources transmitted from the resource. This is needed as there is no
guarantees that a batch will be exported in a single payload, therefore,
it is not an ideal place to add resource batch testing for the exporter
itself.

Add unit tests to ensure the Exporter is correctly batching spans by
resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Bugs
High priority
Development

No branches or pull requests

2 participants