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

Add test to otelhttp to validate semantic conventions #4701

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

MadVikingGod
Copy link
Contributor

I want to start a conversation about semantic conventions and how we can better validate instrumentation outputs.

I'm looking for some feedback on this approach and what I need to do to get this as the pattern for validating most/all of our instrumentation.

This PR here adds a test in the otelhttp package that uses testcontainers to run https://github.com/MadVikingGod/otel-semconv-checker and capture the output from a wrapped HTTP client and server.

This has a hard dependency on docker, which is why I put the test behind a -docker flag.

How I would see this used in other instrumentation is a similar testcontiner setup, but different config, gprc wouldn't have the same attribute groups, and a different server/client wrap setup.

@MadVikingGod MadVikingGod requested a review from a team December 14, 2023 15:31
wd, err := os.Getwd()
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "ghcr.io/madvikinggod/semantic-convention-checker:0.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that https://github.com/MadVikingGod/otel-semconv-checker is a Go application.
How about simply running the HTTP server in the same process (reuse Go code) instead of running as a docker container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've thought about this a bit, and I don't think it's a good idea.

First, that means putting almost all of the same logic that is in the main executable, config parsing, parsing the semantic conventions, and setting up the grpc server into every test that launches it directly.
Second, that means instead of taking a dependency on the config format not breaking (that is what would change between versions), we take a direct dependency on the API of the server. While eventually, that might be an acceptable idea, right now, I've been working hard to add features, and there is a lot of flux that could be problematic if you rely on the internal API vs. the docker images.

Currently, I've been using this to help design the switch to semconv v1.24.0 with the environment variable, and upgrading the docker version is a much less painful experience than aligning the config.

l.t.Log(string(log.Content))
}

var docker = flag.Bool("docker", false, "Enable tests that use docker.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a specific test suite running this in CI? Or do you plan this for later?
Also, an alternative here rather than use the flag package could be to use a // go:build docker build flag so the file doesn't run by default, but can be enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// go:build docker

Let's not do that. Many tools (IDE, golangci-lint) might stop working.

However, I think we could (should) enable it by default.

We can consider skipping when -short is provided using this pattern: https://pkg.go.dev/testing#hdr-Skipping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it part of the non--short tests. I do want to warn that this makes docker required for running all tests. including make test and make precommit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants