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

mdatagen: metrics.go.tmpl broken filter import #12298

Open
clhain opened this issue Feb 5, 2025 · 1 comment · May be fixed by #12415
Open

mdatagen: metrics.go.tmpl broken filter import #12298

clhain opened this issue Feb 5, 2025 · 1 comment · May be fixed by #12415
Labels
bug Something isn't working

Comments

@clhain
Copy link

clhain commented Feb 5, 2025

Describe the bug
Running the current mdatagen against receivers in collector-contrib directly breaks tests due to removal of the collector/filter import in

https://github.com/open-telemetry/opentelemetry-collector/pull/12092/files#diff-27825b678880d103cd17473d56b87f9fe90fe62f67eae7180bb85186e8742e32L19

Steps to reproduce
Here's an example for elasticsearch but seems to happen on other receivers as well.

$ cd opentelemetry-collector-contrib/receiver/elasticsearchreceiver/
$ git diff
$ mdatagen -v
mdatagen version v0.119.0
$ git diff internal/metadata/generated_metrics.go
diff --git a/receiver/elasticsearchreceiver/internal/metadata/generated_metrics.go b/receiver/elasticsearchreceiver/internal/metadata/generated_metrics.go
index 62fb59e3a8..0ca4bf71fb 100644
--- a/receiver/elasticsearchreceiver/internal/metadata/generated_metrics.go
+++ b/receiver/elasticsearchreceiver/internal/metadata/generated_metrics.go
@@ -6,7 +6,6 @@ import (
        "time"
 
        "go.opentelemetry.io/collector/component"
-       "go.opentelemetry.io/collector/filter"
        "go.opentelemetry.io/collector/pdata/pcommon"
        "go.opentelemetry.io/collector/pdata/pmetric"
        "go.opentelemetry.io/collector/receiver"
$ make test
...
# github.com/open-telemetry/opentelemetry-collector-contrib/receiver/elasticsearchreceiver/internal/metadata
internal/metadata/generated_metrics.go:5305:77: undefined: filter
internal/metadata/generated_metrics.go:5306:77: undefined: filter
...

What did you expect to see?
tests continue to pass

What did you see instead?
tests fail

What version did you use?
otel-collector-contrib@HEAD
mdatagen 0.119.0, reverting to 0.118.0 has the same issue, 0.117.0 worked as expected

What config did you use?
metadata file in elasticsearch receiver otel collector contrib

Environment
Ubuntu 20.04

Additional context
Contrib collector is still building, and those filter imports are still there, so wholly possible my setup is broken somehow - but at a basic level I don't see how removing the filter import from the template and relying on it later in the file is correct.

@alexandreLamarre
Copy link

alexandreLamarre commented Feb 7, 2025

Also, that same PR that introduced generating scrapers doesn't correctly do so since it includes consumertest which is unused, it's likely automatically removed when run make gofmt.

When running make mdatagen-test, you can see this issue

diff --git a/cmd/mdatagen/internal/samplescraper/generated_component_test.go b/cmd/mdatagen/internal/samplescraper/generated_component_test.go
index 2cf588df5..484a941a0 100644
--- a/cmd/mdatagen/internal/samplescraper/generated_component_test.go
+++ b/cmd/mdatagen/internal/samplescraper/generated_component_test.go
@@ -8,10 +8,10 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/require"
-
 	"go.opentelemetry.io/collector/component"
 	"go.opentelemetry.io/collector/component/componenttest"
 	"go.opentelemetry.io/collector/confmap/confmaptest"
+	"go.opentelemetry.io/collector/consumer/consumertest"
 	"go.opentelemetry.io/collector/scraper"
 	"go.opentelemetry.io/collector/scraper/scrapertest"
 )

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
None yet
2 participants